Introspector/Probe/Host.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 91.1% 31 / 34 CC 2 SCAR 2.4
CC
2
Cov
96%
_gather_uname_info
2.0
__ANON__
1.1
BEGIN
1.0
CRAP 1.3
« Introspector/Probe/FileHandles.pm ↑ Summary Introspector/Probe/Hosts.pm »
1 package System::Introspector::Probe::Host;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use System::Introspector::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
5 handle_from_command
6 output_from_command
7 output_from_file
8 transform_exceptions
9 1 );
10  
11 0 ▶has hostname_file => (is => 'ro', default => sub {'/etc/hostname' });
Subroutine __ANON__: not called CC=1 SCAR=1.2
12  
13 1 ▶sub gather {
Subroutine gather: called CC=1 SCAR=0.0
Pod undocumented
14 1 my ($self) = @_;
15 1 ▶ return transform_exceptions {
Subroutine __ANON__: called CC=1 SCAR=0.0
16 return {
17 1 hostname => $self->_gather_hostname,
18 uname => $self->_gather_uname_info,
19 };
20 1 };
21 }
22  
23 1 my @UnameFields = qw(
24 kernel_name
25 kernel_release
26 kernel_version
27 nodename
28 machine
29 processor
30 hardware_platform
31 operating_system
32 );
33  
34 1 ▶sub _gather_uname_info {
Subroutine _gather_uname_info: called CC=2 SCAR=6.9
35 1 my ($self) = @_;
36 1 my %uname;
37 1 for my $field (@UnameFields) {
38 8 (my $option = $field) =~ s{_}{-}g;
39 8 my $value = output_from_command [uname => "--$option"];
40 8 chomp $value;
41 8 $uname{ $field } = $value;
42 }
43 1 return \%uname;
44 }
45  
46 1 ▶sub _gather_hostname {
Subroutine _gather_hostname: called CC=1 SCAR=0.0
47 1 my ($self) = @_;
48 1 my $hostname = output_from_file $self->hostname_file;
49 1 chomp $hostname;
50 1 $hostname =~ s{(?:^\s+|\s+$)}{}g;
51 1 return $hostname;
52 }
53  
54 1 1;
55  
56 __END__
« Introspector/Probe/FileHandles.pm ↑ Summary Introspector/Probe/Hosts.pm »