File Coverage

blib/lib/Siebel/AssertOS.pm
Criterion Covered Total %
statement 22 29 75.8
branch 3 14 21.4
condition 1 3 33.3
subroutine 7 7 100.0
pod 3 3 100.0
total 36 56 64.2


line stmt bran cond sub pod time code
1             package Siebel::AssertOS;
2 2     2   2684 use warnings;
  2         4  
  2         55  
3 2     2   6 use strict;
  2         2  
  2         44  
4 2     2   575 use Siebel::AssertOS::Linux::Distribution qw(distribution_name);
  2         3  
  2         386  
5              
6             our $VERSION = "0.07";
7              
8             sub import {
9              
10 1     1   5 shift;
11 1         2 die_if_os_isnt();
12             }
13              
14             sub die_if_os_isnt {
15              
16 1   33 1 1 4 my $os = shift || $^O;
17              
18 1 50       1 os_is($os) ? 1 : die_unsupported($os);
19              
20             }
21              
22             sub die_unsupported {
23              
24 1     1 1 2 my $os = shift;
25 1         10 die "The operation system $os is not supported";
26              
27             }
28              
29             sub os_is {
30              
31 1     1 1 1 my $os = shift;
32              
33 1 50       3 if ( $os eq 'linux' ) {
34              
35             # supported Linux distribuitions
36 1         2 my %distros =
37             ( redhat => 1, suse => 1, 'oracle enterprise linux' => 1 );
38              
39 1         3 my $distro = distribution_name();
40              
41 1 50       2 if ( exists( $distros{$distro} ) ) {
42              
43 0         0 return 1;
44              
45             }
46             else {
47              
48 1         30 warn "The Linux distribution '$distro' is not supported";
49 1         5 return 0;
50              
51             }
52              
53             }
54              
55 0 0         return 1 if ( $os eq 'MSWin32' );
56 0 0         return 1 if ( $os eq 'aix' );
57 0 0         return 1 if ( $os eq 'solaris' );
58 0 0         if ( $os eq 'hpux' ) {
59              
60 0           return 1;
61              
62             }
63             else {
64              
65 0           return 0;
66              
67             }
68              
69             }
70              
71             1;
72              
73             __END__