blib/lib/Net/Link.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary
1  
2 package Net::Link;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 0 ▶use Net::Interface;
Subroutine BEGIN: called CC=1 SCAR=2.6
8 use Carp;
9 use IO::File;
10  
11 our $VERSION = '0.01';
12  
13 our @ISA = qw( Net::Interface );
14  
15 croak(__PACKAGE__ . " requires Linux") if $^O ne 'linux';
16 croak(__PACKAGE__ . " requires /sys/") unless -d '/sys/';
17  
18 sub up {
19 my ($self) = @_;
20  
21 my $carrier = '/sys/class/net/' . $self->name . '/carrier';
22  
23 my $io = new IO::File($carrier);
24 if($io) {
25 my $line = $io->getline;
26 return ($line and $line =~ /^1/);
27 }
28  
29 return;
30 }
31  
32  
33 sub down { return ! $_[0]->up }
34  
35  
36 !0;
37  
38  
39 __END__
↑ Summary