| 1 | |||||||||||||||||||||
| 2 | 3 | ▶ | use 5.010; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | package Perl::PrereqScanner::Scanner::Mojo; | ||||||||||||||||||||
| 7 | 3 | $Perl::PrereqScanner::Scanner::Mojo::VERSION = '0.3.0'; | |||||||||||||||||||
| 8 | # ABSTRACT: Scan for modules loaded with Mojo::Base | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 3 | with 'Perl::PrereqScanner::Scanner'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | ▶ | use PPIx::Literal; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 6 | ▶ | sub scan_for_prereqs { | ||||||||||||||||||
|
Subroutine
scan_for_prereqs: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||
| 16 | 6 | my ( $self, $ppi_doc, $req ) = @_; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | # regular use, require, and no | ||||||||||||||||||||
| 19 | 6 | ▶ | my $includes = $ppi_doc->find('Statement::Include') || []; | ||||||||||||||||||
|
Condition50%1/2
$ppi_doc->find('Statement::Include') || []
MC/DC0%0/1
$ppi_doc->find('Statement::Include') || []
$ppi_doc->find('Statement::Include')
Truth table50%1/2
A
A= $ppi_doc->find('Statement::Include')
| |||||||||||||||||||||
| 20 | 6 | for my $node (@$includes) { | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | # inheritance | ||||||||||||||||||||
| 23 | 15 | ▶ | if ( $self->_is_base_module( $node->module ) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 13 | my @args = PPIx::Literal->convert( $node->arguments ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # skip arguments like '-base', '-strict', '-role', '-signatures' | ||||||||||||||||||||
| 28 | 13 | ▶ | @args = grep { !ref && !/^-/ } @args; | ||||||||||||||||||
|
Condition66%2/3
ref $_ || /^-/
MC/DC50%1/2
ref $_ || /^-/
ref $_
/^-/
Truth table66%2/3
A || B
A= ref $_B= /^-/
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 13 | ▶ | if (@args) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | 7 | my $module = shift @args; | |||||||||||||||||||
| 32 | 7 | my $version = '0'; | |||||||||||||||||||
| 33 | 7 | $req->add_minimum( $module => $version ); | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 12 | ▶ | sub _is_base_module { $_[1] eq 'Mojo::Base' } | ||||||||||||||||||
|
Subroutine
_is_base_module: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 3 | 1; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | #pod =encoding utf8 | ||||||||||||||||||||
| 44 | #pod | ||||||||||||||||||||
| 45 | #pod =head1 SYNOPSIS | ||||||||||||||||||||
| 46 | #pod | ||||||||||||||||||||
| 47 | #pod use Perl::PrereqScanner; | ||||||||||||||||||||
| 48 | #pod my $scanner = Perl::PrereqScanner->new( { extra_scanners => ['Mojo'] } ); | ||||||||||||||||||||
| 49 | #pod my $prereqs = $scanner->scan_ppi_document($ppi_doc); | ||||||||||||||||||||
| 50 | #pod my $prereqs = $scanner->scan_file($file_path); | ||||||||||||||||||||
| 51 | #pod my $prereqs = $scanner->scan_string($perl_code); | ||||||||||||||||||||
| 52 | #pod my $prereqs = $scanner->scan_module($module_name); | ||||||||||||||||||||
| 53 | #pod | ||||||||||||||||||||
| 54 | #pod =head1 DESCRIPTION | ||||||||||||||||||||
| 55 | #pod | ||||||||||||||||||||
| 56 | #pod This scanner will look for dependencies from the L<Mojo::Base> module: | ||||||||||||||||||||
| 57 | #pod | ||||||||||||||||||||
| 58 | #pod use Mojo::Base 'SomeBaseClass'; | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | __END__ | ||||||||||||||||||||