| 1 | package App::Midgen::Role::UseOk; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use constant {BLANK => q{ }, NONE => q{}, TWO => 2, THREE => 3,}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | requires | |||||||||||||||||||||||||||||||||||||||||
| 7 | qw( ppi_document debug verbose format xtest _process_found_modules develop meta2 ); | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | # Load time and dependencies negate execution time | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | our $VERSION = '0.34'; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | $VERSION = eval $VERSION; ## no critic | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use PPI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Data::Printer {caller_info => 1,}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use Tie::Static qw(static); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | #use List::MoreUtils qw( lastidx ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | ####### | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # composed method - _xtests_in_single_quote | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ####### | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub xtests_use_ok { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xtests_use_ok: not called CC=30 SCAR=68.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $phase_relationship = shift || NONE; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my @modules; | |||||||||||||||||||||||||||||||||||||||||
| 29 | my @version_strings; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | #PPI::Document | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # PPI::Statement::Scheduled | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # PPI::Token::Word 'BEGIN' | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # PPI::Token::Whitespace ' ' | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # PPI::Structure::Block { ... } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # PPI::Token::Whitespace '\n' | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # PPI::Token::Whitespace '\t' | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # PPI::Statement | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # PPI::Token::Word 'use_ok' | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # PPI::Structure::List ( ... ) | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # PPI::Token::Whitespace ' ' | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # PPI::Statement::Expression | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # PPI::Token::Quote::Single ''Term::ReadKey'' | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # PPI::Token::Operator ',' | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # PPI::Token::Whitespace ' ' | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # PPI::Token::Quote::Single ''2.30'' | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | my @chunks = | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | map { [$_->schildren] } | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | grep { $_->child(0)->literal =~ m{\A(?:BEGIN)\z} } | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | grep { $_->child(0)->isa('PPI::Token::Word') } | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | @{$self->ppi_document->find('PPI::Statement::Scheduled') || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->ppi_document->find('PPI::Statement::Scheduled') || []
MC/DC0%0/1
$self->ppi_document->find('PPI::Statement::Scheduled') || []
$self->ppi_document->find('PPI::Statement::Scheduled')
Truth table0%0/2
A
A= $self->ppi_document->find('PPI::Statement::Scheduled')
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach my $hunk (@chunks) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # looking for use_ok { 'Term::ReadKey' => '2.30' }; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (grep { $_->isa('PPI::Structure::Block') } @$hunk) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | # hack for List | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my @hunkdata = @$hunk; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | foreach my $ppi_sb (@hunkdata) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($ppi_sb->isa('PPI::Structure::Block')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | foreach my $ppi_s (@{$ppi_sb->{children}}) { | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($ppi_s->isa('PPI::Statement')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | p $ppi_s if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($ppi_s->{children}[0]->content eq 'use_ok') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $ppi_sl = $ppi_s->{children}[1]; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | foreach my $ppi_se (@{$ppi_sl->{children}}) { | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($ppi_se->isa('PPI::Statement::Expression')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | foreach my $element (@{$ppi_se->{children}}) { | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | # some fudge to remember the module name if falied | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | static \my $previous_module; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ( $element->isa('PPI::Token::Quote::Single') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
MC/DC0%0/2
$element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
$element->isa("PPI::Token::Quote::Single")
$element->isa("PPI::Token::Quote::Double")
Truth table0%0/3
A or B
A= $element->isa("PPI::Token::Quote::Single")B= $element->isa("PPI::Token::Quote::Double")
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | || $element->isa('PPI::Token::Quote::Double')) | ||||||||||||||||||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $module = $element->content; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $module =~ s/^(?:['|"])//; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $module =~ s/(?:['|"])$//; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($module =~ m{\A(?:[[a-zA-Z])}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | print "found module - $module\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | push @modules, $module; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $version_strings[$#modules] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $previous_module = $module; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if ( $element->isa('PPI::Token::Number::Float') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single")
MC/DC0%0/3
$element->isa("PPI::Token::Number::Float") or $element->isa("PPI::Token::Quote::Single") or $element->isa("PPI::Token::Quote::Double")
$element->isa("PPI::Token::Number::Float")
$element->isa("PPI::Token::Quote::Single")
$element->isa("PPI::Token::Quote::Double")
Truth table0%0/4
A or B or C
A= $element->isa("PPI::Token::Number::Float")B= $element->isa("PPI::Token::Quote::Single")C= $element->isa("PPI::Token::Quote::Double")
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | || $element->isa('PPI::Token::Quote::Single') | ||||||||||||||||||||||||||||||||||||||||||
| 95 | || $element->isa('PPI::Token::Quote::Double')) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $version_string = $element->content; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $version_string =~ s/^(?:['|"])//; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $version_string =~ s/(?:['|"])$//; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | next if $version_string !~ m{\A(?:[\d|v])}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $version_string | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | = version::is_lax($version_string) | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ? $version_string | ||||||||||||||||||||||||||||||||||||||||||
| 107 | : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | print "found version_string - $version_string\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($previous_module) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->{found_version}{$previous_module} | |||||||||||||||||||||||||||||||||||||||||
| 114 | = $version_string; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $version_strings[$#modules] = $version_string; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $previous_module = undef; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | @version_strings = map { defined $_ ? $_ : 0 } @version_strings; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | p @modules if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | p @version_strings if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if (scalar @modules > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | for (0 .. $#modules) { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | print "Info: UseOk -> Sending $modules[$_] - $version_strings[$_]\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | if ($self->verbose == TWO); | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->_process_found_modules( | |||||||||||||||||||||||||||||||||||||||||
| 143 | $phase_relationship, $modules[$_], $version_strings[$_], | ||||||||||||||||||||||||||||||||||||||||||
| 144 | __PACKAGE__, $phase_relationship, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | ▶ | no Moo::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | __END__ | ||||||||||||||||||||||||||||||||||||||||||