File Coverage

blib/lib/Perl/PrereqScanner/Lite/Scanner/Version.pm
Criterion Covered Total %
statement 29 29 100.0
branch 9 10 90.0
condition 15 18 83.3
subroutine 5 5 100.0
pod 0 1 0.0
total 58 63 92.0


line stmt bran cond sub pod time code
1             package Perl::PrereqScanner::Lite::Scanner::Version;
2 2     2   634 use strict;
  2         4  
  2         48  
3 2     2   8 use warnings;
  2         4  
  2         36  
4 2     2   8 use utf8;
  2         4  
  2         7  
5 2     2   35 use Perl::PrereqScanner::Lite::Constants;
  2         4  
  2         496  
6              
7             sub scan {
8 28     28 0 44 my ($class, $c, $token, $token_type) = @_;
9              
10 28 50 66     83 if ($token_type == KEY || $token_type == NAMESPACE || $token_type == NAMESPACE_RESOLVER) {
      66        
11 4         7 $c->{not_decl_module_name} .= $token->{data};
12 4         10 return 1;
13             }
14              
15 24 100 66     49 if ($token_type == METHOD && $token->{data} eq 'VERSION') {
16 4         5 $c->{is_version_decl} = 1;
17 4         9 return 1;
18             }
19              
20 20 100 100     72 if ($c->{is_version_decl} && $token_type == INT || $token_type == DOUBLE || $token_type == VERSION_STRING) {
      100        
      100        
21 4 100       9 if ($c->{module_reqs}->{requirements}->{$c->{not_decl_module_name}}) {
22 3         8 $c->add_minimum($c->{not_decl_module_name} => $token->{data});
23             }
24 4         6 $c->{is_version_decl} = 0;
25 4         6 $c->{not_decl_module_name} = '';
26 4         9 return 1;
27             }
28              
29 16 100       47 if ($token_type == SEMI_COLON) {
30 4         5 $c->{is_version_decl} = 0;
31 4         7 $c->{not_decl_module_name} = '';
32 4         14 return 1;
33             }
34             }
35              
36             1;
37              
38             =encoding utf-8
39              
40             =head1 NAME
41              
42             Perl::PrereqScanner::Lite::Scanner::Version - Extra Perl::PrereqScanner::Lite Scanner for VERSION method
43              
44             =head1 SYNOPSIS
45              
46             use Perl::PrereqScanner::Lite;
47              
48             my $scanner = Perl::PrereqScanner::Lite->new;
49             $scanner->add_extra_scanner('Version');
50              
51             =head1 DESCRIPTION
52              
53             Perl::PrereqScanner::Lite::Scanner::Version is the extra scanner for Perl::PrereqScanner::Lite.
54             This scanner supports C method. It retrieves version from the argument of C.
55              
56             For example,
57              
58             require Foo::Bar;
59             Foo::Bar->VERSION(1.00);
60              
61             =head1 LICENSE
62              
63             Copyright (C) moznion.
64              
65             This library is free software; you can redistribute it and/or modify
66             it under the same terms as Perl itself.
67              
68             =head1 AUTHOR
69              
70             moznion Emoznion@gmail.comE
71              
72             =cut
73