blib/lib/Pinto/Chrome/Net.pm

filter: Statementstmt 76.0% 35 / 46 Branchbran 33.3% 6 / 18 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 4 totaltotal 60.4% 49 / 81 CC 11 SCAR 18.9
CC
11
Cov
64%
show_progress
12.0
should_render_progress
12.0
diag
7.5
CRAP 6.6
« blib/lib/Pinto/Locator/Mirror.pm ↑ Summary blib/lib/App/Pinto/Command/nop.pm »
1 # ABSTRACT: Interface for network-based interaction
2  
3 package Pinto::Chrome::Net;
4  
5 14 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 14 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 ▶use Pinto::Types qw(Io);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use Pinto::Util qw(itis);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 14 ▶use Pinto::Constants qw(:protocol);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #-----------------------------------------------------------------------------
14  
15 14 our $VERSION = '0.14'; # VERSION
16  
17 #-----------------------------------------------------------------------------
18  
19 14 extends qw( Pinto::Chrome::Term );
20  
21 #-----------------------------------------------------------------------------
22  
23 14 has stdout => (
24 is => 'ro',
25 isa => Io,
26 required => 1,
27 coerce => 1,
28 );
29  
30 14 has stderr => (
31 is => 'ro',
32 isa => Io,
33 required => 1,
34 coerce => 1,
35 );
36  
37 #-----------------------------------------------------------------------------
38  
39 5 ▶sub diag {
Subroutine diag: called CC=7 SCAR=20.2
Pod undocumented
40 5 my ( $self, $msg, $opts ) = @_;
41  
42 5 ▶ $opts ||= {};
Condition50%1/2
$opts ||= {}
l!l
50
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
43  
44 5 ▶ $msg = $msg->() if ref $msg eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $msg eq "CODE" 0 5 5
45  
46 5 ▶ if ( itis( $msg, 'Pinto::Exception' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (itis($msg, "Pinto::Exception")) 4 1 5
47  
48 # Show full stack trace if we are debugging
49 4 ▶ $msg = $ENV{PINTO_DEBUG} ? $msg->as_string : $msg->message;
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PINTO_DEBUG'} ? : 0 4 4
50 }
51  
52 5 chomp $msg;
53 5 $msg = $self->colorize( $msg, $opts->{color} );
54 5 ▶ $msg .= "\n" unless $opts->{no_newline};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts->{"no_newline"} 5 0 5
55  
56 # Prepend prefix to each line (not just at the start of the message)
57 # The prefix is used by Pinto::Remote to distinguish between
58 # messages that go to stderr and those that should go to stdout
59 5 $msg =~ s/^/$PINTO_PROTOCOL_DIAG_PREFIX/gmx;
60  
61 5 ▶ print { $self->stderr } $msg or croak $!;
Branch: 1 branch
BranchTrueFalseTotal
print {$self->stderr;} $msg or $!->croak 5 0 5
62 }
63  
64 #-----------------------------------------------------------------------------
65  
66 0 ▶sub show_progress {
Subroutine show_progress: not called CC=3 SCAR=24.8
Pod undocumented
67 0 my ($self) = @_;
68  
69 0 ▶ return if not $self->should_render_progress;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->should_render_progress 0 0 0
70  
71 0 $self->stderr->autoflush; # Make sure pipes are hot
72  
73 0 ▶ print { $self->stderr } $PINTO_PROTOCOL_PROGRESS_MESSAGE . "\n" or croak $!;
Branch: 1 branch
BranchTrueFalseTotal
print {$self->stderr;} $Pinto::Chrome::Net::PINTO_PROTOCOL_PROGRESS_MESSAGE . "\n" or $!->croak 0 0 0
74 }
75  
76 #-----------------------------------------------------------------------------
77  
78 0 ▶sub should_render_progress {
Subroutine should_render_progress: not called CC=3 SCAR=24.8
Pod undocumented
79 0 my ($self) = @_;
80  
81 0 ▶ return 0 if $self->verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $self->verbose 0 0 0
82 0 ▶ return 0 if $self->quiet;
Branch: 1 branch
BranchTrueFalseTotal
if $self->quiet 0 0 0
83 0 return 1;
84 }
85  
86 #-----------------------------------------------------------------------------
87  
88 0 ▶sub edit {
Subroutine edit: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my ( $self, $document ) = @_;
90  
91 0 return $document; # TODO!
92 }
93  
94 #-----------------------------------------------------------------------------
95  
96 14 __PACKAGE__->meta->make_immutable;
97  
98 #-----------------------------------------------------------------------------
99 14 1;
100  
101 __END__
« blib/lib/Pinto/Locator/Mirror.pm ↑ Summary blib/lib/App/Pinto/Command/nop.pm »