blib/lib/Sys/Info.pm

filter: Statementstmt 69.3% 52 / 75 Branchbran 22.7% 5 / 22 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 93.7% 15 / 16 Podpod 100% 5 / 5 totaltotal 62.2% 79 / 127 CC 17 SCAR 22.8
CC
17
Cov
57%
httpd
30.5
perl_build
12.2
_legacy_perl
12.0
CRAP 9.7
↑ Summary
1 package Sys::Info;
2 2 $Sys::Info::VERSION = '0.7811';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Sys::Info::Constants qw( OSID );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use base qw( Sys::Info::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our @EXPORT_OK = qw( OSID );
11  
12 2 __PACKAGE__->_mk_object( $_ ) for qw( OS Device );
13  
14 1 ▶sub import {
Subroutine import: called CC=5 SCAR=16.2
15 1 my($class, @names) = @_;
16 1 my $caller = caller;
17 1 my %cache = map { $_ => 1 } @EXPORT_OK;
18 2 ▶ no strict qw( refs );
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 foreach my $name ( @names ) {
20 1 ▶ croak "Bogus import: $name" if not $class->can($name);
Branch: 1 branch
BranchTrueFalseTotal
unless $class->can($name) 0 1 1
21 1 ▶ croak "Caller already has the $name method" if $caller->can($name);
Branch: 1 branch
BranchTrueFalseTotal
if $caller->can($name) 0 1 1
22 1 ▶ croak "Access denied for $name" if not exists $cache{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $cache{$name} 0 1 1
23 1 *{ $caller . q{::} . $name } = *{ $class . q{::} . $name };
24 }
25 1 return;
26 }
27  
28 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
29 1 my $class = shift;
30 1 my $self = {};
31 1 bless $self, $class;
32 1 return $self;
33 }
34  
35 2 ▶sub perl { return defined $^V ? sprintf( '%vd', $^V ) : _legacy_perl( $] ) }
Subroutine perl: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $^V ? : 2 0 2
36  
37 2 ▶sub perl_build {
Subroutine perl_build: called CC=4 SCAR=25.0
Pod documented
38 2 ▶ return 0 if OSID ne 'Windows';
Branch: 1 branch
BranchTrueFalseTotal
if &OSID() ne "Windows" 2 0 2
39 0 ▶ require Win32 if $] >= 5.006;
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.006" 0 0 0
40 0 ▶ return 0 if not defined &Win32::BuildNumber;
Branch: 1 branch
BranchTrueFalseTotal
unless defined &Win32::BuildNumber 0 0 0
41 0 return Win32::BuildNumber();
42 }
43  
44 1 ▶sub perl_long { return join q{.}, perl(), perl_build() }
Subroutine perl_long: called CC=1 SCAR=0.0
Pod documented
45  
46 1 ▶sub httpd {
Subroutine httpd: called CC=6 SCAR=34.2
Pod documented
47 1 my $self = shift;
48 1 ▶ my $server = $ENV{SERVER_SOFTWARE} || return;
Condition50%1/2
$ENV{'SERVER_SOFTWARE'} || (return)
l!l
01
MC/DC0%0/1
$ENV{'SERVER_SOFTWARE'} || (return)
$ENV{'SERVER_SOFTWARE'}
Truth table50%1/2
A
A= $ENV{'SERVER_SOFTWARE'}
Aresult
11
00
49  
50 0 ▶ if ( $server =~ m{\A Microsoft\-IIS/ (.+?) \z}xms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server =~ m[\A Microsoft\-IIS/ (.+?) \z]msx) 0 0 0
51 0 return 'Microsoft Internet Information Server ' . $1;
52 }
53  
54 0 ▶ if ( $server =~ m{\A (Apache)/(.+?) \z}xmsi ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server =~ m[\A (Apache)/(.+?) \z]imsx) 0 0 0
55 0 my $apache = $1;
56 0 my @data = split /\s+/xms, $2;
57 0 my $v = shift @data;
58 0 my @mods;
59 0 my($mn, $mv);
60 0 foreach my $e (@data) {
61 0 ▶ next if $e =~ m{ \A \( .+? \) \z}xms;
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ / \A \( .+? \) \z/msx 0 0 0
62 0 ($mn,$mv) = split m{/}xms, $e;
63 0 $mn =~ s{ \-(.+?) \z }{}xms;
64 0 push @mods, $mn .'(' . $mv . ')';
65 }
66 0 return "$apache $v. Modules: " . join q{ }, @mods;
67 }
68  
69 0 return $server;
70 }
71  
72 # ------------------------[ P R I V A T E ]------------------------ #
73  
74 4 ▶sub _mk_object {
Subroutine _mk_object: called CC=2 SCAR=6.9
75 4 my $self = shift;
76 4 ▶ my $name = shift || croak '_mk_object() needs a name';
Condition50%1/2
shift() || croak('_mk_object() needs a name')
l!l
40
MC/DC0%0/1
shift() || croak('_mk_object() needs a name')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
77 2 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
78 4 ▶ *{ lc $name } = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
79 2 shift->load_module( 'Sys::Info::' . $name )->new( @_ );
80 4 };
81 4 return;
82 }
83  
84 0 ▶sub _legacy_perl { # function
Subroutine _legacy_perl: not called CC=3 SCAR=24.8
85 0 ▶ my $v = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $v = shift() or return 0 0 0
86 0 my($rev, $patch_sub) = split m{[.]}xms, $v;
87 0 $patch_sub =~ s{[0_]}{}xmsg;
88 0 my @v = split m{}xms, $patch_sub;
89 0 ▶ return sprintf '%d.%d.%d', $rev, $v[0], $v[1] || '0';
Condition0%0/2
$v[1] || '0'
l!l
00
MC/DC0%0/1
$v[1] || '0'
$v[1]
Truth table0%0/2
A
A= $v[1]
Aresult
11
00
90 }
91  
92 2 1;
93  
94 __END__
↑ Summary