File Coverage

blib/lib/Perl/PrereqScanner/Scanner/Aliased.pm
Criterion Covered Total %
statement 19 19 100.0
branch 5 6 83.3
condition 2 2 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 30 32 93.7


line stmt bran cond sub pod time code
1 2     2   22 use strict;
  2         4  
  2         56  
2 2     2   12 use warnings;
  2         3  
  2         71  
3              
4             package Perl::PrereqScanner::Scanner::Aliased 1.025;
5             # ABSTRACT: scan for OO module aliases via aliased.pm
6              
7 2     2   9 use Moose;
  2         4  
  2         9  
8             with 'Perl::PrereqScanner::Scanner';
9              
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This scanner will look for aliased OO modules:
13             #pod
14             #pod use aliased 'Some::Long::Long::Name' => 'Short::Name';
15             #pod
16             #pod Short::Name->new;
17             #pod ...
18             #pod
19             #pod =cut
20              
21             sub scan_for_prereqs {
22 265     265 0 568 my ($self, $ppi_doc, $req) = @_;
23              
24             # regular use and require
25 265   100     604 my $includes = $ppi_doc->find('Statement::Include') || [];
26 265         131746 for my $node ( @$includes ) {
27             # aliasing
28 171 100       1352 if (grep { $_ eq $node->module } qw{ aliased }) {
  171         425  
29             # We only want the first argument to aliased
30             my @args = grep {
31 12 50       321 $_->isa('PPI::Token::QuoteLike::Words')
  15         333  
32             || $_->isa('PPI::Token::Quote')
33             } $node->arguments;
34              
35 12 100       97 next unless @args;
36 9         38 my ($module) = $self->_q_contents($args[0]);
37 9         27 $req->add_minimum($module => 0);
38             }
39             }
40             }
41              
42             1;
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             Perl::PrereqScanner::Scanner::Aliased - scan for OO module aliases via aliased.pm
53              
54             =head1 VERSION
55              
56             version 1.025
57              
58             =head1 DESCRIPTION
59              
60             This scanner will look for aliased OO modules:
61              
62             use aliased 'Some::Long::Long::Name' => 'Short::Name';
63              
64             Short::Name->new;
65             ...
66              
67             =head1 PERL VERSION
68              
69             This library should run on perls released even a long time ago. It should work
70             on any version of perl released in the last five years.
71              
72             Although it may work on older versions of perl, no guarantee is made that the
73             minimum required version will not be increased. The version may be increased
74             for any reason, and there is no promise that patches will be accepted to lower
75             the minimum required perl.
76              
77             =head1 AUTHORS
78              
79             =over 4
80              
81             =item *
82              
83             Jerome Quelin
84              
85             =item *
86              
87             Ricardo Signes <cpan@semiotic.systems>
88              
89             =back
90              
91             =head1 COPYRIGHT AND LICENSE
92              
93             This software is copyright (c) 2009 by Jerome Quelin.
94              
95             This is free software; you can redistribute it and/or modify it under
96             the same terms as the Perl 5 programming language system itself.
97              
98             =cut