File Coverage

blib/lib/Devel/Platform/Info.pm
Criterion Covered Total %
statement 25 25 100.0
branch 1 2 50.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 2 2 100.0
total 34 36 94.4


line stmt bran cond sub pod time code
1             package Devel::Platform::Info;
2              
3 6     6   89289 use strict;
  6         11  
  6         178  
4 6     6   24 use warnings;
  6         6  
  6         148  
5              
6 6     6   20 use vars qw($VERSION);
  6         8  
  6         1753  
7             $VERSION = '0.15';
8              
9             #----------------------------------------------------------------------------
10              
11             my %map = (
12             # Unix (and like) family OSes
13             'freebsd' => 'BSD',
14             'openbsd' => 'BSD',
15             'netbsd' => 'BSD',
16             'mirbsd' => 'BSD',
17             'dragonfly' => 'BSD',
18             'midnightbsd' => 'BSD',
19            
20             'irix' => 'Irix',
21            
22             'linux' => 'Linux',
23             'aix' => 'Linux',
24             'bsdos' => 'Linux',
25             'dgux' => 'Linux',
26             'dynixptx' => 'Linux',
27             'hpux' => 'Linux',
28             'dec_osf' => 'Linux',
29             'svr4' => 'Linux',
30             'unicos' => 'Linux',
31             'unicosmk' => 'Linux',
32             'ultrix' => 'Linux',
33            
34             'sco_sv' => 'SCO',
35             'sco3' => 'SCO',
36             'sco' => 'SCO',
37              
38             'solaris' => 'Solaris',
39             'sunos' => 'Solaris',
40              
41             'beos' => 'BeOS',
42              
43             # Windows family OSes
44             'dos' => 'Win32',
45             'os2' => 'Win32',
46             'mswin32' => 'Win32',
47             'netware' => 'Win32',
48             'cygwin' => 'Win32',
49              
50             # Mac family OSes
51             'macos' => 'Mac',
52             'rhapsody' => 'Mac',
53             'darwin' => 'Mac',
54              
55             # Other OSes
56             'vms' => 'Linux',
57             'vos' => 'Linux',
58             'os390' => 'Linux',
59             'vmesa' => 'Linux',
60             'riscos' => 'Linux',
61             'amigaos' => 'Linux',
62             'beos' => 'Linux',
63             'machten' => 'Linux',
64             'mpeix' => 'Linux',
65             'bitrig' => 'Linux',
66             'minix' => 'Linux',
67             'nto' => 'Linux',
68             );
69              
70             #----------------------------------------------------------------------------
71              
72             sub new {
73 1     1 1 7 my ($class) = @_;
74 1         2 my $self = {};
75 1         1 bless $self, $class;
76 1         3 return $self;
77             }
78              
79             sub get_info {
80 1     1 1 3 my $self = shift;
81 1         1 my $data;
82              
83 1   50     5 my $plugin = $map{ lc $^O } || 'Linux';
84              
85 1         3 my $driver = 'Devel::Platform::Info::' . $plugin;
86 1         2 my $require = "$driver.pm";
87 1         4 $require =~ s!::!/!g;
88              
89 1         1 eval {
90 1         385 require $require;
91 1         7 $self->{driver} = $driver->new();
92 1         3 $data = $self->{driver}->get_info();
93             };
94              
95 1 50       14 $data->{error} = $@ if($@);
96              
97 1         12 return $data;
98             }
99              
100             1;
101              
102             __END__