| 1 | |||||||||||||
| 2 | package Morris::Message; | ||||||||||||
| 3 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use namespace::clean -except => qw(meta); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 2 | class_type 'Morris::Message::Address'; | |||||||||||
| 8 | |||||||||||||
| 9 | coerce 'Morris::Message::Address' | ||||||||||||
| 10 | => from 'Str' | ||||||||||||
| 11 | 0 | ▶ | => via { Morris::Message::Address->new($_) } | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 12 | 2 | ; | |||||||||||
| 13 | |||||||||||||
| 14 | 2 | has from => ( | |||||||||||
| 15 | is => 'ro', | ||||||||||||
| 16 | isa => 'Morris::Message::Address', | ||||||||||||
| 17 | coerce => 1, | ||||||||||||
| 18 | required => 1, | ||||||||||||
| 19 | handles => [ qw(modifier nickname username hostname) ] | ||||||||||||
| 20 | ); | ||||||||||||
| 21 | |||||||||||||
| 22 | 2 | has channel => ( | |||||||||||
| 23 | is => 'ro', | ||||||||||||
| 24 | isa => 'Str', | ||||||||||||
| 25 | ); | ||||||||||||
| 26 | |||||||||||||
| 27 | 2 | has message => ( | |||||||||||
| 28 | is => 'ro', | ||||||||||||
| 29 | isa => 'Str', | ||||||||||||
| 30 | ); | ||||||||||||
| 31 | |||||||||||||
| 32 | has timestamp => ( | ||||||||||||
| 33 | is => 'ro', | ||||||||||||
| 34 | isa => 'Int', | ||||||||||||
| 35 | 0 | ▶ | default => sub { time() } | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 36 | 2 | ); | |||||||||||
| 37 | |||||||||||||
| 38 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 39 | |||||||||||||
| 40 | package Morris::Message::Address; | ||||||||||||
| 41 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | |||||||||||||
| 43 | has str_ref => ( | ||||||||||||
| 44 | is => 'ro', | ||||||||||||
| 45 | isa => 'ScalarRef', | ||||||||||||
| 46 | required => 1, | ||||||||||||
| 47 | 0 | ▶ | trigger => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 48 | 0 | my $self = shift; | |||||||||||
| 49 | 0 | $self->__parsed(0); | |||||||||||
| 50 | }, | ||||||||||||
| 51 | 2 | ); | |||||||||||
| 52 | |||||||||||||
| 53 | 2 | has __parsed => ( | |||||||||||
| 54 | is => 'rw', | ||||||||||||
| 55 | isa => 'Bool', | ||||||||||||
| 56 | required => 1, | ||||||||||||
| 57 | default => 0, | ||||||||||||
| 58 | ); | ||||||||||||
| 59 | |||||||||||||
| 60 | 2 | has modifier => ( | |||||||||||
| 61 | is => 'ro', | ||||||||||||
| 62 | isa => 'Maybe[Str]', | ||||||||||||
| 63 | writer => 'set_modifier', | ||||||||||||
| 64 | ); | ||||||||||||
| 65 | |||||||||||||
| 66 | 2 | has nickname => ( | |||||||||||
| 67 | is => 'ro', | ||||||||||||
| 68 | isa => 'Maybe[Str]', | ||||||||||||
| 69 | writer => 'set_nickname', | ||||||||||||
| 70 | ); | ||||||||||||
| 71 | |||||||||||||
| 72 | 2 | has username => ( | |||||||||||
| 73 | is => 'ro', | ||||||||||||
| 74 | isa => 'Maybe[Str]', | ||||||||||||
| 75 | writer => 'set_username', | ||||||||||||
| 76 | ); | ||||||||||||
| 77 | |||||||||||||
| 78 | 2 | has hostname => ( | |||||||||||
| 79 | is => 'ro', | ||||||||||||
| 80 | isa => 'Maybe[Str]', | ||||||||||||
| 81 | writer => 'set_hostname', | ||||||||||||
| 82 | ); | ||||||||||||
| 83 | |||||||||||||
| 84 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||
| 85 | 0 | my ($next, $class, @args) = @_; | |||||||||||
| 86 | |||||||||||||
| 87 | 0 | ▶ | if (@args == 1) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 88 | 0 | @args = (str_ref => \$args[0]); | |||||||||||
| 89 | } | ||||||||||||
| 90 | 0 | $next->($class, @args); | |||||||||||
| 91 | 2 | }; | |||||||||||
| 92 | |||||||||||||
| 93 | 2 | around qw(modifier nickname username hostname) => \&__check_parsed; | |||||||||||
| 94 | |||||||||||||
| 95 | 0 | ▶ | sub __check_parsed { | ||||||||||
|
Subroutine
:around: not called CC=7 SCAR=40.3
| |||||||||||||
| 96 | 0 | my ($next, $self, @args) = @_; | |||||||||||
| 97 | |||||||||||||
| 98 | 0 | ▶ | if (@args) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 99 | 0 | return $next->($self, @args); | |||||||||||
| 100 | } | ||||||||||||
| 101 | |||||||||||||
| 102 | 0 | ▶ | if (! $self->__parsed) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 103 | 0 | my $ref = $self->str_ref; | |||||||||||
| 104 | |||||||||||||
| 105 | 0 | $$ref =~ /^(\W)?([^!]+)!([^@]+)@(.*)$/; | |||||||||||
| 106 | 0 | ▶ | $self->set_modifier( $1 || '' ); | ||||||||||
|
Condition0%0/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
| |||||||||||||
| 107 | 0 | ▶ | $self->set_nickname( $2 || '' ); | ||||||||||
|
Condition0%0/2
$2 || ''
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
| |||||||||||||
| 108 | 0 | ▶ | $self->set_username( $3 || '' ); | ||||||||||
|
Condition0%0/2
$3 || ''
MC/DC0%0/1
$3 || ''
$3
Truth table0%0/2
A
A= $3
| |||||||||||||
| 109 | 0 | ▶ | $self->set_hostname( $4 || '' ); | ||||||||||
|
Condition0%0/2
$4 || ''
MC/DC0%0/1
$4 || ''
$4
Truth table0%0/2
A
A= $4
| |||||||||||||
| 110 | 0 | $self->__parsed(1); | |||||||||||
| 111 | } | ||||||||||||
| 112 | 0 | return $next->($self); | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | 2 | __PACKAGE__->meta->make_immutable(); | |||||||||||
| 116 | |||||||||||||
| 117 | 2 | 1; | |||||||||||