| 1 | |||||||||||||
| 2 | 2 | ▶ | use 5.010; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | package Perl::PrereqScanner::Scanner::Zim; | ||||||||||||
| 7 | 2 | $Perl::PrereqScanner::Scanner::Zim::VERSION = '0.2.0'; | |||||||||||
| 8 | # ABSTRACT: Scan for modules loaded with Importer::Zim | ||||||||||||
| 9 | |||||||||||||
| 10 | 2 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 2 | with 'Perl::PrereqScanner::Scanner'; | |||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use PPIx::Literal (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 2 | ▶ | sub scan_for_prereqs { | ||||||||||
|
Subroutine
scan_for_prereqs: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||
| 16 | 2 | my ( $self, $ppi_doc, $req ) = @_; | |||||||||||
| 17 | |||||||||||||
| 18 | # regular use, require, and no | ||||||||||||
| 19 | 2 | ▶ | 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 | 2 | for my $node (@$includes) { | |||||||||||
| 21 | |||||||||||||
| 22 | 6 | ▶ | if ( $self->_is_base_module( $node->module ) ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | |||||||||||||
| 24 | 6 | my @args = PPIx::Literal->convert( $node->arguments ); | |||||||||||
| 25 | |||||||||||||
| 26 | 6 | ▶ | if (@args) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | 6 | my $module = shift @args; | |||||||||||
| 28 | 6 | ▶ | my $opts = ref $args[0] eq 'HASH' ? shift @args : {}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | my $version = | ||||||||||||
| 30 | 6 | ▶ | exists $opts->{-version} ? $opts->{-version} : '0'; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | 6 | $req->add_minimum( $module => $version ); | |||||||||||
| 32 | } | ||||||||||||
| 33 | } | ||||||||||||
| 34 | } | ||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 6 | ▶ | sub _is_base_module { | ||||||||||
|
Subroutine
_is_base_module: called CC=1 SCAR=0.0
| |||||||||||||
| 38 | state $IS_BASE = { | ||||||||||||
| 39 | 6 | map { $_ => 1 } | |||||||||||
| 40 | qw( | ||||||||||||
| 41 | zim | ||||||||||||
| 42 | Importer::Zim | ||||||||||||
| 43 | Importer::Zim::Lexical | ||||||||||||
| 44 | Importer::Zim::EndOfScope | ||||||||||||
| 45 | Importer::Zim::Unit | ||||||||||||
| 46 | Importer::Zim::Bogus | ||||||||||||
| 47 | ) | ||||||||||||
| 48 | }; | ||||||||||||
| 49 | 6 | return $IS_BASE->{ $_[1] }; | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | 2 | 1; | |||||||||||
| 53 | |||||||||||||
| 54 | #pod =encoding utf8 | ||||||||||||
| 55 | #pod | ||||||||||||
| 56 | #pod =head1 SYNOPSIS | ||||||||||||
| 57 | #pod | ||||||||||||
| 58 | #pod use Perl::PrereqScanner; | ||||||||||||
| 59 | #pod my $scanner = Perl::PrereqScanner->new( { extra_scanners => ['Zim'] } ); | ||||||||||||
| 60 | #pod my $prereqs = $scanner->scan_ppi_document($ppi_doc); | ||||||||||||
| 61 | #pod my $prereqs = $scanner->scan_file($file_path); | ||||||||||||
| 62 | #pod my $prereqs = $scanner->scan_string($perl_code); | ||||||||||||
| 63 | #pod my $prereqs = $scanner->scan_module($module_name); | ||||||||||||
| 64 | #pod | ||||||||||||
| 65 | #pod =head1 DESCRIPTION | ||||||||||||
| 66 | #pod | ||||||||||||
| 67 | #pod This scanner will look for dependencies from the L<Importer::Zim> module: | ||||||||||||
| 68 | #pod | ||||||||||||
| 69 | #pod use zim 'Carp' => 'croak'; | ||||||||||||
| 70 | #pod | ||||||||||||
| 71 | #pod use Importer::Zim 'Scalar::Util' => qw(blessed); | ||||||||||||
| 72 | #pod | ||||||||||||
| 73 | #pod use zim 'Test::More' => { -version => 0.88 } => qw(ok done_testing); | ||||||||||||
| 74 | |||||||||||||
| 75 | __END__ | ||||||||||||