| 1 | 9 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use Kavorka::Parameter (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use Role::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 9 | my $DETECT_OO = do { | |||||||||||||||||||||||||||
| 9 | 9 | my %_detect_oo; # memoize | |||||||||||||||||||||||||||
| 10 | 24 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||
| 11 | 24 | my $pkg = $_[0]; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 24 | ▶ | return $_detect_oo{$pkg} if exists $_detect_oo{$pkg}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 22 | ▶ | if ($pkg->can("meta")) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | { | ||||||||||||||||||||||||||||
| 17 | 19 | my $meta = $pkg->meta; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 19 | ▶ | return $_detect_oo{$pkg} = "Moo::Role" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
"Role::Tiny"->is_role($pkg) and ref $meta eq "Moo::HandleMoose::FakeMetaClass"
MC/DC50%1/2
"Role::Tiny"->is_role($pkg) and ref $meta eq "Moo::HandleMoose::FakeMetaClass"
"Role::Tiny"->is_role($pkg)
ref $meta eq "Moo::HandleMoose::FakeMetaClass"
Truth table66%2/3
A and B
A= "Role::Tiny"->is_role($pkg)B= ref $meta eq "Moo::HandleMoose::FakeMetaClass"
| |||||||||||||||||||||||||||||
| 20 | if 'Role::Tiny'->is_role($pkg) | ||||||||||||||||||||||||||||
| 21 | && ref($meta) eq "Moo::HandleMoose::FakeMetaClass"; | ||||||||||||||||||||||||||||
| 22 | 17 | ▶ | return $_detect_oo{$pkg} = "Moo" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | if ref($meta) eq "Moo::HandleMoose::FakeMetaClass"; | ||||||||||||||||||||||||||||
| 24 | 12 | ▶ | return $_detect_oo{$pkg} = "Mouse" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | if $meta->isa("Mouse::Meta::Module"); | ||||||||||||||||||||||||||||
| 26 | 9 | ▶ | return $_detect_oo{$pkg} = "Moose" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | if $meta->isa("Moose::Meta::Class"); | ||||||||||||||||||||||||||||
| 28 | 2 | ▶ | return $_detect_oo{$pkg} = "Moose" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | if $meta->isa("Moose::Meta::Role"); | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 3 | ▶ | return $_detect_oo{$pkg} = "Role::Tiny" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | if 'Role::Tiny'->is_role($pkg); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | return $_detect_oo{$pkg} = ""; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | 9 | }; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 22 | ▶ | my $INSTALL_MM = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 40 | 22 | my ($modification, $names, $code) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 22 | for my $name (@$names) | |||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 24 | my ($package, $method) = ($name =~ /\A(.+)::(\w+)\z/); | |||||||||||||||||||||||||||
| 45 | 24 | my $OO = $package->$DETECT_OO; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 24 | ▶ | if ($OO eq 'Moose') | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 9 | require Moose::Util; | |||||||||||||||||||||||||||
| 50 | 9 | my $installer = sprintf('add_%s_method_modifier', $modification); | |||||||||||||||||||||||||||
| 51 | 9 | Moose::Util::find_meta($package)->$installer($method, $code); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | elsif ($OO eq 'Mouse') | ||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 3 | require Mouse::Util; | |||||||||||||||||||||||||||
| 57 | 3 | my $installer = sprintf('add_%s_method_modifier', $modification); | |||||||||||||||||||||||||||
| 58 | 3 | Mouse::Util::find_meta($package)->$installer($method, $code); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | elsif ($OO eq 'Role::Tiny') | ||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | 1 | require Class::Method::Modifiers; | |||||||||||||||||||||||||||
| 64 | 1 | ▶ | push @{$Role::Tiny::INFO{$package}{modifiers}||=[]}, [ $modification, $method, $code ]; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Role::Tiny::INFO{$package}{"modifiers"} ||= []
MC/DC0%0/1
$Role::Tiny::INFO{$package}{"modifiers"} ||= []
$Role::Tiny::INFO{$package}{"modifiers"}
Truth table50%1/2
A
A= $Role::Tiny::INFO{$package}{"modifiers"}
| |||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | elsif ($OO eq 'Moo::Role') | ||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||
| 69 | 2 | require Class::Method::Modifiers; | |||||||||||||||||||||||||||
| 70 | 2 | ▶ | push @{$Role::Tiny::INFO{$package}{modifiers}||=[]}, [ $modification, $method, $code ]; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Role::Tiny::INFO{$package}{"modifiers"} ||= []
MC/DC0%0/1
$Role::Tiny::INFO{$package}{"modifiers"} ||= []
$Role::Tiny::INFO{$package}{"modifiers"}
Truth table50%1/2
A
A= $Role::Tiny::INFO{$package}{"modifiers"}
| |||||||||||||||||||||||||||||
| 71 | 2 | $OO->_maybe_reset_handlemoose($package); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | elsif ($OO eq 'Moo') | ||||||||||||||||||||||||||||
| 75 | { | ||||||||||||||||||||||||||||
| 76 | 7 | require Class::Method::Modifiers; | |||||||||||||||||||||||||||
| 77 | 7 | require Moo::_Utils; | |||||||||||||||||||||||||||
| 78 | 7 | Moo::_Utils::_install_modifier($package, $modification, $method, $code); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | else | ||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||
| 83 | 2 | require Class::Method::Modifiers; | |||||||||||||||||||||||||||
| 84 | 2 | Class::Method::Modifiers::install_modifier($package, $modification, $method, $code); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 9 | }; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | package Kavorka::MethodModifier; | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 9 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 92 | 9 | our $VERSION = '0.039'; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 9 | ▶ | use Parse::Keyword {}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 95 | 9 | ▶ | use Parse::KeywordX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | 9 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 9 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | 9 | with 'Kavorka::Sub'; | |||||||||||||||||||||||||||
| 100 | 9 | ▶ | use namespace::sweep; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 9 | requires 'method_modifier'; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 19 | ▶ | has more_names => (is => 'ro', default => sub { [] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | sub bypass_custom_parsing | ||||||||||||||||||||||||||||
| 107 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
bypass_custom_parsing: called CC=5 SCAR=17.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 3 | my $class = shift; | |||||||||||||||||||||||||||
| 109 | 3 | my ($keyword, $caller, $args) = @_; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 3 | my $coderef = pop @$args; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | reftype($coderef) eq reftype(sub {}) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 114 | 3 | ▶ | or croak('Not a valid coderef'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | my @qnames = | ||||||||||||||||||||||||||||
| 117 | 3 | ▶ | map { /::/ ? $_ : sprintf('%s::%s', $caller, $_) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 3 | ▶ | map { !ref($_) ? $_ : reftype($_) eq reftype([]) ? @$_ : croak("Not an array or string: $_") } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 119 | @$args; | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 3 | $INSTALL_MM->( | |||||||||||||||||||||||||||
| 122 | $class->method_modifier, | ||||||||||||||||||||||||||||
| 123 | \@qnames, | ||||||||||||||||||||||||||||
| 124 | $coderef, | ||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | after parse_subname => sub | ||||||||||||||||||||||||||||
| 129 | 19 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 130 | 19 | my $self = shift; | |||||||||||||||||||||||||||
| 131 | 19 | lex_read_space; | |||||||||||||||||||||||||||
| 132 | 19 | ▶ | while (lex_peek eq ',') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||
| 134 | 2 | lex_read(1); | |||||||||||||||||||||||||||
| 135 | 2 | lex_read_space; | |||||||||||||||||||||||||||
| 136 | 2 | push @{$self->more_names}, scalar Kavorka::_fqname(parse_name('method', 1)); | |||||||||||||||||||||||||||
| 137 | 2 | lex_read_space; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | 9 | }; | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub allow_anonymous { 0 } | ||||||||||||||||||||||||||
|
Subroutine
allow_anonymous: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub allow_lexical { 0 } | ||||||||||||||||||||||||||
|
Subroutine
allow_lexical: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | sub default_invocant | ||||||||||||||||||||||||||||
| 145 | 14 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
default_invocant: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 146 | 14 | my $self = shift; | |||||||||||||||||||||||||||
| 147 | return ( | ||||||||||||||||||||||||||||
| 148 | 14 | 'Kavorka::Parameter'->new( | |||||||||||||||||||||||||||
| 149 | name => '$self', | ||||||||||||||||||||||||||||
| 150 | traits => { invocant => 1 }, | ||||||||||||||||||||||||||||
| 151 | ), | ||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | sub install_sub | ||||||||||||||||||||||||||||
| 156 | 19 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
install_sub: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | 19 | my $self = shift; | |||||||||||||||||||||||||||
| 158 | 19 | my $code = $self->body; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 19 | my $modification = $self->method_modifier; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 19 | ▶ | my @names = $self->qualified_name or die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 19 | push @names, @{$self->more_names}; | |||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 19 | $INSTALL_MM->($modification, \@names, $code); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 9 | 1; | |||||||||||||||||||||||||||