@@ -1,5 +1,15 @@
Revision history for Perl extension Perl-PrereqScanner-Lite
+0.23 2015-02-22T10:59:30Z
+
+ - Fix lexical analysis processing
+ (#5, Thank you for reporting @perlancar)
+
+0.22 2015-02-19T02:46:39Z
+
+ - Fix the problem is that it truncates v-string if it has underscore
+ (#6, Thank you for reporting @miyagawa)
+
0.21 2014-09-05T15:22:30Z
- Fix the bug that mixes the blank in dependencies (Thank you for reporting @jscook)
@@ -24,11 +24,13 @@ t/04_scan_module.t
t/10_moose_extends.t
t/11_version_method.t
t/20_left_paran_is_behind_at_module_name.t
+t/30_v_string.t
t/Util.pm
t/resources/basic.pl
t/resources/left_paren_is_behind_at_module_name/basic.pl
t/resources/left_paren_is_behind_at_module_name/with_version.pl
t/resources/moose.pl
+t/resources/v_string.pl
t/resources/version.pl
xt/perlcritic.t
xt/perlcriticrc
@@ -4,7 +4,7 @@
"moznion <moznion@gmail.com>"
],
"dynamic_config" : 0,
- "generated_by" : "Minilla/v2.1.1",
+ "generated_by" : "Minilla/v2.3.0",
"license" : [
"perl_5"
],
@@ -49,7 +49,7 @@
"runtime" : {
"requires" : {
"CPAN::Meta::Requirements" : "2.125",
- "Compiler::Lexer" : "0.19",
+ "Compiler::Lexer" : "0.22",
"Module::Path" : "0",
"parent" : "0",
"perl" : "5.008005"
@@ -65,7 +65,7 @@
"provides" : {
"Perl::PrereqScanner::Lite" : {
"file" : "lib/Perl/PrereqScanner/Lite.pm",
- "version" : "0.21"
+ "version" : "0.23"
},
"Perl::PrereqScanner::Lite::Constants" : {
"file" : "lib/Perl/PrereqScanner/Lite/Constants.pm"
@@ -84,9 +84,9 @@
},
"homepage" : "https://github.com/moznion/Perl-PrereqScanner-Lite",
"repository" : {
- "url" : "git://github.com/moznion/Perl-PrereqScanner-Lite",
+ "url" : "git://github.com/moznion/Perl-PrereqScanner-Lite.git",
"web" : "https://github.com/moznion/Perl-PrereqScanner-Lite"
}
},
- "version" : "0.21"
+ "version" : "0.23"
}
@@ -10,7 +10,7 @@ configure_requires:
CPAN::Meta::Prereqs: '0'
Module::Build: '0.38'
dynamic_config: 0
-generated_by: 'Minilla/v2.1.1, CPAN::Meta::Converter version 2.142060'
+generated_by: 'Minilla/v2.3.0, CPAN::Meta::Converter version 2.143240'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -29,7 +29,7 @@ no_index:
provides:
Perl::PrereqScanner::Lite:
file: lib/Perl/PrereqScanner/Lite.pm
- version: '0.21'
+ version: '0.23'
Perl::PrereqScanner::Lite::Constants:
file: lib/Perl/PrereqScanner/Lite/Constants.pm
Perl::PrereqScanner::Lite::Scanner::Moose:
@@ -38,12 +38,12 @@ provides:
file: lib/Perl/PrereqScanner/Lite/Scanner/Version.pm
requires:
CPAN::Meta::Requirements: '2.125'
- Compiler::Lexer: '0.19'
+ Compiler::Lexer: '0.22'
Module::Path: '0'
parent: '0'
perl: '5.008005'
resources:
bugtracker: https://github.com/moznion/Perl-PrereqScanner-Lite/issues
homepage: https://github.com/moznion/Perl-PrereqScanner-Lite
- repository: git://github.com/moznion/Perl-PrereqScanner-Lite
-version: '0.21'
+ repository: git://github.com/moznion/Perl-PrereqScanner-Lite.git
+version: '0.23'
@@ -1,4 +1,4 @@
-[![Build Status](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite.png?branch=master)](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite) [![Coverage Status](https://coveralls.io/repos/moznion/Perl-PrereqScanner-Lite/badge.png?branch=master)](https://coveralls.io/r/moznion/Perl-PrereqScanner-Lite?branch=master)
+[![Build Status](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite.svg?branch=master)](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite) [![Coverage Status](https://img.shields.io/coveralls/moznion/Perl-PrereqScanner-Lite/master.svg)](https://coveralls.io/r/moznion/Perl-PrereqScanner-Lite?branch=master)
# NAME
Perl::PrereqScanner::Lite - Lightweight Prereqs Scanner for Perl
@@ -1,4 +1,4 @@
-requires 'Compiler::Lexer', '0.19';
+requires 'Compiler::Lexer', '0.22';
requires 'CPAN::Meta::Requirements', '2.125';
requires 'Module::Path';
requires 'parent', 0;
@@ -11,6 +11,7 @@ our @EXPORT = qw(
SEMI_COLON USE_DECL USED_NAME REG_LIST REG_EXP LEFT_PAREN
RIGHT_PAREN STRING RAW_STRING VERSION_STRING INT DOUBLE KEY
METHOD WHITESPACE COMMENT LEFT_BRACE LEFT_BRACKET BUILTIN_FUNC
+ IF_STMT
);
use constant {
@@ -32,6 +33,7 @@ use constant {
METHOD => Compiler::Lexer::TokenType::T_Method,
WHITESPACE => Compiler::Lexer::TokenType::T_WhiteSpace,
COMMENT => Compiler::Lexer::TokenType::T_Comment,
+ IF_STMT => Compiler::Lexer::TokenType::T_IfStmt,
LEFT_PAREN => Compiler::Lexer::TokenType::T_LeftParenthesis,
RIGHT_PAREN => Compiler::Lexer::TokenType::T_RightParenthesis,
@@ -6,7 +6,7 @@ use Compiler::Lexer;
use CPAN::Meta::Requirements;
use Perl::PrereqScanner::Lite::Constants;
-our $VERSION = "0.21";
+our $VERSION = "0.23";
sub new {
my ($class, $opt) = @_;
@@ -47,8 +47,7 @@ sub scan_file {
open my $fh, '<', $file or die "Cannot open file: $file";
my $script = do { local $/; <$fh>; };
- my $tokens = $self->{lexer}->tokenize($script);
- $self->_scan($tokens);
+ $self->scan_string($script);
}
sub scan_tokens {
@@ -138,7 +137,14 @@ sub _scan {
# e.g.
# use Foo;
# use parent qw/Foo/;
- if ($token_type == USED_NAME) {
+ #
+ if ($token_type == USED_NAME || $token_type == IF_STMT) {
+ # XXX ~~~~~~~~~~~~~~~~~~~~~~
+ # Workaround for `use if` statement
+ # It is a matter of Compiler::Lexer (maybe).
+ #
+ # use if $] < 5.009_005, 'MRO::Compat';
+
$module_name = $token->{data};
if ($module_name eq 'lib' || $module_name eq 'constant') {
@@ -272,6 +278,16 @@ sub _scan {
last if --$left_paren_num <= 0;
}
}
+ next;
+ }
+
+ # XXX Workaround for v-strings which has underscore at tail (e.g. v1.1_1).
+ # It is a matter of Compiler::Lexer.
+ #
+ # ref: https://github.com/moznion/Perl-PrereqScanner-Lite/issues/6
+ if ($is_prev_version && $token_type == KEY) {
+ $module_version .= $token->{data};
+ next;
}
if ($token_type != WHITESPACE) {
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+use utf8;
+use FindBin;
+use File::Spec::Functions qw/catfile/;
+use Perl::PrereqScanner::Lite;
+
+use t::Util;
+use Test::More;
+use Test::Deep;
+
+my $scanner = Perl::PrereqScanner::Lite->new;
+
+subtest 'basic' => sub {
+ my $got = $scanner->scan_file(catfile($FindBin::Bin, 'resources', 'v_string.pl'));
+ cmp_deeply(get_reqs_hash($got), {
+ 'File::Temp' => 'v0.1_2',
+ });
+};
+
+done_testing;
+
@@ -58,6 +58,7 @@ sub prereqs_ok {
'Locale::MakeText::Lexicon' => 0,
'Moose' => 0,
'Any::Moose' => 0,
+ 'if' => 0,
});
}
@@ -0,0 +1,2 @@
+use File::Temp v0.1_2;
+use File::Temp v0.1_1;