File Coverage

blib/lib/Perl/PrereqScanner/Scanner/Superclass.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition 8 8 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 39 40 97.5


line stmt bran cond sub pod time code
1 2     2   12 use strict;
  2         4  
  2         60  
2 2     2   10 use warnings;
  2         3  
  2         79  
3              
4             package Perl::PrereqScanner::Scanner::Superclass 1.024;
5             # ABSTRACT: scan for modules loaded with superclass.pm
6              
7 2     2   21 use Moose;
  2         3  
  2         14  
8             with 'Perl::PrereqScanner::Scanner';
9              
10             #pod =head1 DESCRIPTION
11             #pod
12             #pod This scanner will look for dependencies from the L<superclass> module:
13             #pod
14             #pod use superclass 'Foo', Bar => 1.23;
15             #pod
16             #pod =cut
17              
18             my $mod_re = qr/^[A-Z_a-z][0-9A-Z_a-z]*(?:(?:::|')[0-9A-Z_a-z]+)*$/;
19              
20             sub scan_for_prereqs {
21 265     265 0 764 my ( $self, $ppi_doc, $req ) = @_;
22              
23             # regular use, require, and no
24 265   100     920 my $includes = $ppi_doc->find('Statement::Include') || [];
25 265         138761 for my $node (@$includes) {
26             # inheritance
27 171 100       1529 if ( $node->module eq 'superclass' ) {
28             # rt#55713: skip arguments like '-norequires', focus only on inheritance
29             my @meat = grep {
30 27 100 100     653 $_->isa('PPI::Token::QuoteLike::Words')
  69         1517  
31             || $_->isa('PPI::Token::Quote')
32             || $_->isa('PPI::Token::Number')
33             } $node->arguments;
34              
35 27         75 my @args = map { $self->_q_contents($_) } @meat;
  42         168  
36              
37 27         77 while (@args) {
38 33         482 my $module = shift @args;
39 33 100 100     284 my $version = ( @args && $args[0] !~ $mod_re ) ? shift(@args) : 0;
40 33         122 $req->add_minimum( $module => $version );
41             }
42             }
43             }
44             }
45              
46             1;
47              
48             __END__
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             Perl::PrereqScanner::Scanner::Superclass - scan for modules loaded with superclass.pm
57              
58             =head1 VERSION
59              
60             version 1.024
61              
62             =head1 DESCRIPTION
63              
64             This scanner will look for dependencies from the L<superclass> module:
65              
66             use superclass 'Foo', Bar => 1.23;
67              
68             =head1 PERL VERSION
69              
70             This library should run on perls released even a long time ago. It should work
71             on any version of perl released in the last five years.
72              
73             Although it may work on older versions of perl, no guarantee is made that the
74             minimum required version will not be increased. The version may be increased
75             for any reason, and there is no promise that patches will be accepted to lower
76             the minimum required perl.
77              
78             =head1 AUTHORS
79              
80             =over 4
81              
82             =item *
83              
84             Jerome Quelin
85              
86             =item *
87              
88             Ricardo Signes <rjbs@semiotic.systems>
89              
90             =back
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2009 by Jerome Quelin.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut