| 1 | package Tangerine::hook::mooselike; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 16 | $Tangerine::hook::mooselike::VERSION = '0.23'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use parent 'Tangerine::Hook'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use Tangerine::Hook; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Tangerine::HookData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use Tangerine::Utils qw(any none stripquotelike); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 162 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=17 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 162 | my ($self, $s) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 162 | ▶ | if ($self->type eq 'compile' && $s->[0] eq 'use' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition88%8/9
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1 and &any(sub {
$s->[1] eq $_;
}
, "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1
$self->type eq "compile" and $s->[0] eq "use"
MC/DC75%3/4
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1 and &any(sub {
$s->[1] eq $_;
}
, "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
$self->type eq "compile"
$s->[0] eq "use"
scalar @$s > 1
&any(sub {
$s->[1] eq $_;
}
, "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
Truth table80%4/5
A and B and C and D
A= $self->type eq "compile"B= $s->[0] eq "use"C= scalar @$s > 1D= &any(sub {
$s->[1] eq $_;
}
, "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 396 | ▶ | scalar(@$s) > 1 && (any { $s->[1] eq $_ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | qw(Moose Mouse Moo Mo Role::Tiny::With))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | return Tangerine::HookData->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | hooks => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Tangerine::hook::mooselike->new(type => 'runtime'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 45 | ▶ | } elsif ($self->type eq 'runtime' && any { $s->[0] eq $_ } qw(extends with)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition100%3/3
$self->type eq "runtime" and &any(sub {
$s->[0] eq $_;
}
, "extends", "with")
MC/DC100%2/2
$self->type eq "runtime" and &any(sub {
$s->[0] eq $_;
}
, "extends", "with")
$self->type eq "runtime"
&any(sub {
$s->[0] eq $_;
}
, "extends", "with")
Truth table100%3/3
A and B
A= $self->type eq "runtime"B= &any(sub {
$s->[0] eq $_;
}
, "extends", "with")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | ▶ | if (scalar(@$s) > 2 && none { $s->[2] eq $_ } ('=>', ',', ';')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
scalar @$s > 2 and &none(sub {
$s->[2] eq $_;
}
, "=>", ",", ";")
MC/DC100%2/2
scalar @$s > 2 and &none(sub {
$s->[2] eq $_;
}
, "=>", ",", ";")
scalar @$s > 2
&none(sub {
$s->[2] eq $_;
}
, "=>", ",", ";")
Truth table100%3/3
A and B
A= scalar @$s > 2B= &none(sub {
$s->[2] eq $_;
}
, "=>", ",", ";")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Bail out; most likely an indirect object method call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | my %modules; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | ▶ | for (my $i = 1; $i < scalar(@$s); $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 22 | ▶ | next if any { $s->[$i] eq $_ } ('=>', ','); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 16 | ▶ | last if $s->[$i] eq ';'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 10 | ▶ | $s->[$i] = substr($s->[$i], 1, -1) if substr($s->[$i], 0, 1) eq '('; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | ▶ | if (substr($s->[$i], 0, 1) ne '{') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 6 | my @parents = stripquotelike($s->[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 6 | $last = $parents[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | $modules{$_} = undef for @parents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | ▶ | next unless $last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $modules{$last} = $+{version} if | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | $s->[$i] =~ /^\{.*-version\s*?(?:=>|,)\s*?(?:(?:qq?\s*?[^\w]\s*)|'|")?v? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | (?<version>\d+?(?:\.\d+)*)(?:(?:\s*?[^\w])|'|")?.*\}\s*$/xso; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | $last = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | return Tangerine::HookData->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | modules => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ( $_ => Tangerine::Occurence->new(version => $modules{$_}) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } keys %modules, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 149 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||