« lib/Perl/PrereqScanner/NotQuiteLite/Parser/PackageVariant.pm
↑ Summary
lib/Perl/PrereqScanner/NotQuiteLite/Util/CPANfile.pm »
| 1 | package Perl::PrereqScanner::NotQuiteLite::Parser::Moose; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 90 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 90 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 90 | ▶ | use Perl::PrereqScanner::NotQuiteLite::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # There are so many Moose-like variants | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # Like Moose; modules that are not listed here but have Moose | ||||||||||||||||||||||||||||
| 10 | # in their name are implicitly treated like these as well | ||||||||||||||||||||||||||||
| 11 | 90 | my @ExportsExtendsAndWith = qw/ | |||||||||||||||||||||||||||
| 12 | Moose Moo Mouse MooX Moo::Lax Moos | ||||||||||||||||||||||||||||
| 13 | MooseX::App MooseX::Singleton MooseX::SingletonMethod | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | HTML::FormHandler::Moose Test::Class::Moose | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | App::GHPT::Wrapper::OurMoose App::wmiirc::Plugin Ark | ||||||||||||||||||||||||||||
| 18 | Bot::Backbone::Service Bubblegum::Class CatalystX::Declare | ||||||||||||||||||||||||||||
| 19 | Cogwheel CPAN::Testers::Backend::Base Dancer2::Plugin | ||||||||||||||||||||||||||||
| 20 | Data::Object::Class DBICx::Modeler::Model Digital::Driver | ||||||||||||||||||||||||||||
| 21 | Elastic::Doc Fey::ORM::Table Form::Factory::Processor | ||||||||||||||||||||||||||||
| 22 | Jedi::App Momo Moonshine::Magic Moxie Nile::Base | ||||||||||||||||||||||||||||
| 23 | Parse::FixedRecord Pcore Reaction::Class Reaction::UI::WidgetClass | ||||||||||||||||||||||||||||
| 24 | Squirrel Statocles::Base TAEB::OO Test::Able Test::Roo | ||||||||||||||||||||||||||||
| 25 | Web::Simple XML::Rabbit | ||||||||||||||||||||||||||||
| 26 | /; | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | # Like Moose::Role; modules that are not listed here but have Role | ||||||||||||||||||||||||||||
| 29 | # in their name are implicitly treated like these as well | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 90 | my @ExportsWith = qw/ | |||||||||||||||||||||||||||
| 32 | Moose::Role Moo::Role Mouse::Role | ||||||||||||||||||||||||||||
| 33 | MooseX::Role::Parameterized | ||||||||||||||||||||||||||||
| 34 | Mason::PluginRole Mojo::RoleTiny MooX::Cmd | ||||||||||||||||||||||||||||
| 35 | Role::Basic Role::Tiny Role::Tiny::With Reflex::Role | ||||||||||||||||||||||||||||
| 36 | Template::Caribou Test::Routine App::SimulateReads::Base | ||||||||||||||||||||||||||||
| 37 | /; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Like Mo | ||||||||||||||||||||||||||||
| 40 | 90 | my @ExportsExtends = qw/ | |||||||||||||||||||||||||||
| 41 | Mo | ||||||||||||||||||||||||||||
| 42 | Lingy::Base OptArgs2::Mo Parse::SAMGov::Mo Pegex::Base | ||||||||||||||||||||||||||||
| 43 | Sub::Mage TestML::Base Type::Utils VSO | ||||||||||||||||||||||||||||
| 44 | /; | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | sub register { | ||||||||||||||||||||||||||||
| 47 | 89 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
register: called CC=12 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | # Make sure everything is unique | ||||||||||||||||||||||||||||
| 50 | 89 | ▶ | my %exports_extends_and_with = map {$_ => 1} (@ExportsExtendsAndWith, @{$args{exports_extends_and_with} || []}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 89 | ▶ | my %exports_extends = map {$_ => 1} (@ExportsExtends, @{$args{exports_extends} || []}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 89 | ▶ | my %exports_with = map {$_ => 1} (@ExportsWith, @{$args{exports_with} || []}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 89 | for my $module (keys %exports_with) { | |||||||||||||||||||||||||||
| 55 | 1246 | ▶ | if (exists $exports_extends_and_with{$module}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | delete $exports_with{$module}; | |||||||||||||||||||||||||||
| 57 | 0 | next; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 1246 | ▶ | if (exists $exports_extends{$module}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | $exports_extends_and_with{$module} = 1; | |||||||||||||||||||||||||||
| 61 | 0 | delete $exports_with{$module}; | |||||||||||||||||||||||||||
| 62 | 0 | next; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 89 | for my $module (keys %exports_extends) { | |||||||||||||||||||||||||||
| 66 | 801 | ▶ | if (exists $exports_extends_and_with{$module}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | delete $exports_extends{$module}; | |||||||||||||||||||||||||||
| 68 | 0 | next; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 89 | my %mapping; | |||||||||||||||||||||||||||
| 73 | 89 | for my $module (keys %exports_with) { | |||||||||||||||||||||||||||
| 74 | 1246 | $mapping{use}{$module} = 'register_with'; | |||||||||||||||||||||||||||
| 75 | 1246 | $mapping{no}{$module} = 'remove_with'; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 89 | for my $module (keys %exports_extends) { | |||||||||||||||||||||||||||
| 78 | 801 | $mapping{use}{$module} = 'register_extends'; | |||||||||||||||||||||||||||
| 79 | 801 | $mapping{no}{$module} = 'remove_extends'; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 89 | for my $module (keys %exports_extends_and_with) { | |||||||||||||||||||||||||||
| 82 | 3738 | $mapping{use}{$module} = 'register_extends_and_with'; | |||||||||||||||||||||||||||
| 83 | 3738 | $mapping{no}{$module} = 'remove_extends_and_with'; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 89 | return \%mapping; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub register_extends_and_with { | ||||||||||||||||||||||||||||
| 90 | 56 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
register_extends_and_with: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 56 | $c->register_keyword_parser( | |||||||||||||||||||||||||||
| 93 | 'extends', | ||||||||||||||||||||||||||||
| 94 | [$class, 'parse_extends_args', $used_module], | ||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||
| 96 | 56 | $c->register_keyword_parser( | |||||||||||||||||||||||||||
| 97 | 'with', | ||||||||||||||||||||||||||||
| 98 | [$class, 'parse_with_args', $used_module], | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | sub register_with { | ||||||||||||||||||||||||||||
| 103 | 3 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
register_with: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 3 | $c->register_keyword_parser( | |||||||||||||||||||||||||||
| 106 | 'with', | ||||||||||||||||||||||||||||
| 107 | [$class, 'parse_with_args', $used_module], | ||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub register_extends { | ||||||||||||||||||||||||||||
| 112 | 2 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
register_extends: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | $c->register_keyword_parser( | |||||||||||||||||||||||||||
| 115 | 'extends', | ||||||||||||||||||||||||||||
| 116 | [$class, 'parse_extends_args', $used_module], | ||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub remove_extends_and_with { | ||||||||||||||||||||||||||||
| 121 | 1 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
remove_extends_and_with: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 1 | $c->remove_keyword('extends'); | |||||||||||||||||||||||||||
| 124 | 1 | $c->remove_keyword('with'); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub remove_with { | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
remove_with: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | $c->remove_keyword('with'); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | sub remove_extends { | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
remove_extends: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | $c->remove_keyword('extends'); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 27 | ▶ | sub parse_extends_args { shift->_parse_loader_args(@_) } | ||||||||||||||||||||||||||
|
Subroutine
parse_extends_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 140 | 35 | ▶ | sub parse_with_args { shift->_parse_loader_args(@_) } | ||||||||||||||||||||||||||
|
Subroutine
parse_with_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | sub _parse_loader_args { | ||||||||||||||||||||||||||||
| 143 | 62 | ▶ | my ($class, $c, $used_module, $raw_tokens) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_parse_loader_args: called CC=12 SCAR=25.0
| |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 62 | my $tokens = convert_string_tokens($raw_tokens); | |||||||||||||||||||||||||||
| 146 | 62 | shift @$tokens; # discard extends, with; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 62 | my $prev; | |||||||||||||||||||||||||||
| 149 | 62 | for my $token (@$tokens) { | |||||||||||||||||||||||||||
| 150 | 244 | ▶ | if (!ref $token) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 91 | $c->add($token => 0); | |||||||||||||||||||||||||||
| 152 | 91 | $prev = $token; | |||||||||||||||||||||||||||
| 153 | 91 | next; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 153 | ▶ | my $desc = $token->[1] || ''; | ||||||||||||||||||||||||||
|
Condition100%2/2
$token->[1] || ''
MC/DC100%1/1
$token->[1] || ''
$token->[1]
Truth table100%2/2
A
A= $token->[1]
| |||||||||||||||||||||||||||||
| 156 | 153 | ▶ | if ($desc eq '{}') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 29 | ▶ | my @hash_tokens = @{$token->[0] || []}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 29 | ▶ | for(my $i = 0, my $len = @hash_tokens; $i < $len; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 104 | ▶ | if ($hash_tokens[$i][0] eq '-version' and $i < $len - 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$hash_tokens[$i][0] eq "-version" and $i < $len - 2
MC/DC50%1/2
$hash_tokens[$i][0] eq "-version" and $i < $len - 2
$hash_tokens[$i][0] eq "-version"
$i < $len - 2
Truth table66%2/3
A and B
A= $hash_tokens[$i][0] eq "-version"B= $i < $len - 2
| |||||||||||||||||||||||||||||
| 160 | 27 | my $maybe_version_token = $hash_tokens[$i + 2]; | |||||||||||||||||||||||||||
| 161 | 27 | my $maybe_version = $maybe_version_token->[0]; | |||||||||||||||||||||||||||
| 162 | 27 | ▶ | if (ref $maybe_version) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 18 | $maybe_version = $maybe_version->[0]; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 27 | ▶ | if ($prev and is_version($maybe_version)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$prev and is_version($maybe_version)
MC/DC0%0/2
$prev and is_version($maybe_version)
$prev
is_version($maybe_version)
Truth table33%1/3
A and B
A= $prevB= is_version($maybe_version)
| |||||||||||||||||||||||||||||
| 166 | 27 | $c->add($prev => $maybe_version); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 90 | 1; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | __END__ | ||||||||||||||||||||||||||||