| 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 ||= {}
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||
| 43 | |||||||||||||
| 44 | 5 | ▶ | $msg = $msg->() if ref $msg eq 'CODE'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | |||||||||||||
| 46 | 5 | ▶ | if ( itis( $msg, 'Pinto::Exception' ) ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | |||||||||||||
| 48 | # Show full stack trace if we are debugging | ||||||||||||
| 49 | 4 | ▶ | $msg = $ENV{PINTO_DEBUG} ? $msg->as_string : $msg->message; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 82 | 0 | ▶ | return 0 if $self->quiet; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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__ | ||||||||||||