« lib/Perl/PrereqScanner/NotQuiteLite/Parser/ClassAccessor.pm
↑ Summary
lib/Perl/PrereqScanner/NotQuiteLite/Util.pm »
| 1 | package Perl::PrereqScanner::NotQuiteLite::Parser::ClassLoad; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 88 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 88 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 88 | ▶ | use Perl::PrereqScanner::NotQuiteLite::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 88 | my %known_functions = map {$_ => 1} qw/ | |||||||||||||||||||||||||||||||||||||||||
| 8 | load_class try_load_class load_optional_class | ||||||||||||||||||||||||||||||||||||||||||
| 9 | load_first_existing_class | ||||||||||||||||||||||||||||||||||||||||||
| 10 | /; | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | sub register { return { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 87 | ▶ | use => { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 'Class::Load' => 'parse_class_load_args', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 16 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | sub register_fqfn { return { | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 743 | ▶ | map { "Class::Load::".$_ => "parse_".$_."_args" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register_fqfn: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | keys %known_functions | ||||||||||||||||||||||||||||||||||||||||||
| 21 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub parse_class_load_args { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_class_load_args: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | my $tokens = convert_string_tokens($raw_tokens); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | ▶ | if (is_version($tokens->[0])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $c->add($used_module => shift @$tokens); | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | for my $token (@$tokens) { | |||||||||||||||||||||||||||||||||||||||||
| 32 | 21 | ▶ | next if ref $token; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | ▶ | if ($known_functions{$token}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 7 | $c->register_keyword_parser( | |||||||||||||||||||||||||||||||||||||||||
| 36 | $token, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | [$class, 'parse_'.$token.'_args', $used_module], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } elsif ($token eq ':all') { | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | for my $func (keys %known_functions) { | |||||||||||||||||||||||||||||||||||||||||
| 41 | 12 | $c->register_keyword_parser( | |||||||||||||||||||||||||||||||||||||||||
| 42 | $func, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | [$class, 'parse_'.$func.'_args', $used_module], | ||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | sub parse_load_class_args { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_load_class_args: called CC=7 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | my $tokens = convert_string_tokens($raw_tokens); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | shift @$tokens; # function | |||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my ($module, undef, $options) = @$tokens; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | my $version = 0; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | if (ref $options and $options->[1] eq '{}') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $options and $options->[1] eq "{}"
MC/DC50%1/2
ref $options and $options->[1] eq "{}"
ref $options
$options->[1] eq "{}"
Truth table66%2/3
A and B
A= ref $optionsB= $options->[1] eq "{}"
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my $tokens_in_hashref = convert_string_tokens($options->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | if (ref $key and $key->[0] eq '-version' and is_version($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key and $key->[0] eq "-version"
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key
$key->[0] eq "-version"
is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | $version = $value; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 6 | $c->add_conditional($module => $version); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | sub parse_try_load_class_args { | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_try_load_class_args: called CC=7 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $tokens = convert_string_tokens($raw_tokens); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | shift @$tokens; # function | |||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | my ($module, undef, $options) = @$tokens; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | my $version = 0; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | if (ref $options and $options->[1] eq '{}') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $options and $options->[1] eq "{}"
MC/DC50%1/2
ref $options and $options->[1] eq "{}"
ref $options
$options->[1] eq "{}"
Truth table66%2/3
A and B
A= ref $optionsB= $options->[1] eq "{}"
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $tokens_in_hashref = convert_string_tokens($options->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | if (ref $key and $key->[0] eq '-version' and is_version($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key and $key->[0] eq "-version"
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key
$key->[0] eq "-version"
is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | $version = $value; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | $c->add_suggestion($module => $version); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub parse_load_optional_class_args { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_load_optional_class_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $class->parse_try_load_class_args($c, $used_module, $raw_tokens); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | sub parse_load_first_existing_class_args { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_load_first_existing_class_args: called CC=12 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | my $tokens = convert_string_tokens($raw_tokens); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | shift @$tokens; # function | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my ($module, $version); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | for my $token (@$tokens) { | |||||||||||||||||||||||||||||||||||||||||
| 99 | 14 | ▶ | if (is_module_name($token)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | if ($module) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | $c->add_suggestion($module => $version); | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | $module = $token; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | $version = 0; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 9 | ▶ | if (ref $token and ($token->[1] || '') eq '{}') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
ref $token and ($token->[1] || "") eq "{}"
$token->[1] || ''
MC/DC0%0/2
ref $token and ($token->[1] || "") eq "{}"
ref $token
$token->[1]
Truth table33%1/3
A and B
A= ref $tokenB= $token->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | my $tokens_in_hashref = convert_string_tokens($token->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | while(my ($key, undef, $value, undef) = splice @$tokens_in_hashref, 0, 4) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2 | ▶ | if (ref $key and $key->[0] eq '-version' and is_version($value)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key and $key->[0] eq "-version"
MC/DC0%0/3
ref $key and $key->[0] eq "-version" and is_version($value)
ref $key
$key->[0] eq "-version"
is_version($value)
Truth table25%1/4
A and B and C
A= ref $keyB= $key->[0] eq "-version"C= is_version($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | $version = $value; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | if ($module) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $c->add_suggestion($module => $version); | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 88 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||||||||||||||||