| 1 | # ============================================================================ | ||||||||||||||||||||||||||||||||||
| 2 | package MooseX::App::Message::Envelope; | ||||||||||||||||||||||||||||||||||
| 3 | # ============================================================================ | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 16 | ▶ | use MooseX::App::Message::Block; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | use overload | ||||||||||||||||||||||||||||||||||
| 14 | 16 | ▶ | '""' => "overload"; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | 16 | has 'blocks' => ( | |||||||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 18 | isa => 'ArrayRef[MooseX::App::Message::Block]', | ||||||||||||||||||||||||||||||||||
| 19 | traits => ['Array'], | ||||||||||||||||||||||||||||||||||
| 20 | handles => { | ||||||||||||||||||||||||||||||||||
| 21 | add_block => 'push', | ||||||||||||||||||||||||||||||||||
| 22 | list_blocks => 'elements', | ||||||||||||||||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 16 | has 'exitcode' => ( | |||||||||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||||||||
| 28 | isa => 'Int', | ||||||||||||||||||||||||||||||||||
| 29 | predicate => 'has_exitcode', | ||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 37 | ▶ | around 'BUILDARGS' => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=26.0
| |||||||||||||||||||||||||||||||||||
| 33 | 37 | my $orig = shift; | |||||||||||||||||||||||||||||||||
| 34 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 35 | 37 | my @args = @_; | |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 37 | my $params; | |||||||||||||||||||||||||||||||||
| 38 | 37 | ▶ | if (scalar @args == 1 | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @args == 1 and ref $args[0] eq "HASH"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "HASH"
scalar @args == 1
ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= scalar @args == 1B= ref $args[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||
| 39 | && ref($args[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||
| 40 | 0 | $params = $args[0]; | |||||||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||||||||
| 42 | 37 | $params = { | |||||||||||||||||||||||||||||||||
| 43 | blocks => [], | ||||||||||||||||||||||||||||||||||
| 44 | }; | ||||||||||||||||||||||||||||||||||
| 45 | 37 | my @blocks; | |||||||||||||||||||||||||||||||||
| 46 | 37 | foreach my $element (@args) { | |||||||||||||||||||||||||||||||||
| 47 | next | ||||||||||||||||||||||||||||||||||
| 48 | 188 | ▶ | unless defined $element; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 49 | 188 | ▶ | if (blessed $element | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($element) and $element->isa("MooseX::App::Message::Block")
MC/DC50%1/2
builtin::blessed($element) and $element->isa("MooseX::App::Message::Block")
builtin::blessed($element)
$element->isa("MooseX::App::Message::Block")
Truth table66%2/3
A and B
A= builtin::blessed($element)B= $element->isa("MooseX::App::Message::Block")
| |||||||||||||||||||||||||||||||||||
| 50 | && $element->isa('MooseX::App::Message::Block')) { | ||||||||||||||||||||||||||||||||||
| 51 | 161 | push(@{$params->{blocks}},$element); | |||||||||||||||||||||||||||||||||
| 52 | ▶ | } elsif ($element =~ /^\d+$/ | |||||||||||||||||||||||||||||||||
|
Condition33%2/6
$element =~ /^\d+$/ and $element <= 255 and $element >= 0
$element =~ /^\d+$/ and $element <= 255
MC/DC0%0/3
$element =~ /^\d+$/ and $element <= 255 and $element >= 0
$element =~ /^\d+$/
$element <= 255
$element >= 0
Truth table25%1/4
A and B and C
A= $element =~ /^\d+$/B= $element <= 255C= $element >= 0
| |||||||||||||||||||||||||||||||||||
| 53 | && $element <= 255 | ||||||||||||||||||||||||||||||||||
| 54 | && $element >= 0) { | ||||||||||||||||||||||||||||||||||
| 55 | 27 | $params->{exitcode} = $element; | |||||||||||||||||||||||||||||||||
| 56 | } else { | ||||||||||||||||||||||||||||||||||
| 57 | 0 | push(@{$params->{blocks}},MooseX::App::Message::Block->new( | |||||||||||||||||||||||||||||||||
| 58 | header => $element, | ||||||||||||||||||||||||||||||||||
| 59 | )); | ||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 37 | return $self->$orig($params); | |||||||||||||||||||||||||||||||||
| 65 | 16 | }; | |||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub overload { | ||||||||||||||||||||||||||||||||
|
Subroutine
overload: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 68 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($self->has_exitcode) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 71 | 0 | my $exitcode = $self->exitcode; | |||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ($exitcode == 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 73 | 0 | print $self->stringify; | |||||||||||||||||||||||||||||||||
| 74 | } else { | ||||||||||||||||||||||||||||||||||
| 75 | 0 | print STDERR $self->stringify; | |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||
| 77 | 0 | exit $exitcode; | |||||||||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||||||||
| 79 | 0 | print $self->stringify; | |||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||
| 81 | 0 | return; | |||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | 2 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 85 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 2 | my $message = ''; | |||||||||||||||||||||||||||||||||
| 88 | 2 | foreach my $block ($self->list_blocks) { | |||||||||||||||||||||||||||||||||
| 89 | 3 | $message .= $block->stringify; | |||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | 2 | return $message; | |||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 96 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 97 | 0 | $self->overload; | |||||||||||||||||||||||||||||||||
| 98 | 0 | return $MooseX::App::Null::NULL; | |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||
| 102 | package MooseX::App::Null; | ||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||
| 104 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 105 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | use overload | ||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | 'bool' => sub { 0 }, | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | '""' => sub { '' }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | '0+' => sub { 0 }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||
| 111 | 16 | our $NULL = bless {}, __PACKAGE__; | |||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub AUTOLOAD { return $NULL } | ||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | 16 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||
| 116 | 16 | 1; | |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||
| 118 | __END__ | ||||||||||||||||||||||||||||||||||