Commit abd0cb34 authored by gregor herrmann's avatar gregor herrmann

Imported Upstream version 0.33

parents 878e463e 54dd5f57
......@@ -18,7 +18,7 @@ sub process_grammar_files {
open(my $fh,'<',$grammar) || die "cannot read $grammar: $!";
my @content = <$fh>;
close $fh;
splice(@content,1,0,'our $VERSION=0.32;'."\n");
splice(@content,1,0,'our $VERSION=0.33;'."\n");
open(my $out,">",$grammar) || die "cannot write $grammer: $!";
print $out @content;
close $out;
......@@ -52,10 +52,11 @@ my %module_build_args = (
},
'dist_abstract' => 'Find out what modules are used',
'dist_author' => [
'Thomas Klausner <domm@cpan.org>'
'Thomas Klausner <domm@cpan.org>',
'Kenichi Ishigaki <kishigaki@gmail.com>'
],
'dist_name' => 'Module-ExtractUse',
'dist_version' => '0.32',
'dist_version' => '0.33',
'license' => 'perl',
'module_name' => 'Module::ExtractUse',
'module_name' => 'Module::ExtractUse',
......
......@@ -2,6 +2,14 @@
# Changes for Module::ExtractUse
#-----------------------------------------------------------------
0.33 2014-04-11T21:04:52+0200
- added base() handling to no (Thomas Klausner)
- support 'no MODULE' etc (for RT-94305) (Kenichi Ishigaki)
- typo fix (David Steinbrunner)
- ignore __DATA|END__ sections (see https://rt.cpan.org/Ticket/Display.html?id=88969 ) (Kenichi Ishigaki)
- ignore use/require method calls (Kenichi Ishigaki)
0.32 2013-09-04T16:48:07+0200
- not to include cached results (Kenichi Ishigaki)
- Fix handling module beginning with v and pragma with version.
......
This software is copyright (c) 2012 by Thomas Klausner.
This software is copyright (c) 2014 by Thomas Klausner.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
......@@ -12,7 +12,7 @@ b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2012 by Thomas Klausner.
This software is Copyright (c) 2014 by Thomas Klausner.
This is free software, licensed under:
......@@ -272,7 +272,7 @@ That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2012 by Thomas Klausner.
This software is Copyright (c) 2014 by Thomas Klausner.
This is free software, licensed under:
......
......@@ -6,6 +6,16 @@ MANIFEST
META.json
META.yml
README
_build/auto_features
_build/build_params
_build/cleanup
_build/config_data
_build/features
_build/lib/MyModuleBuilder.pm
_build/magicnum
_build/notes
_build/prereqs
_build/runtime_params
dist.ini
example/cpan.pl
grammar
......
{
"abstract" : "Find out what modules are used",
"author" : [
"Thomas Klausner <domm@cpan.org>"
"Thomas Klausner <domm@cpan.org>",
"Kenichi Ishigaki <kishigaki@gmail.com>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 4.300028, CPAN::Meta::Converter version 2.120921",
......@@ -52,6 +53,6 @@
"web" : "http://github.com/domm/Module-ExtractUse"
}
},
"version" : "0.32"
"version" : "0.33"
}
......@@ -2,6 +2,7 @@
abstract: 'Find out what modules are used'
author:
- 'Thomas Klausner <domm@cpan.org>'
- 'Kenichi Ishigaki <kishigaki@gmail.com>'
build_requires:
Module::Build: 0.3601
Test::Deep: 0
......@@ -27,4 +28,4 @@ requires:
warnings: 0
resources:
repository: git://github.com/domm/Module-ExtractUse.git
version: 0.32
version: 0.33
This archive contains the distribution Module-ExtractUse,
version 0.32:
version 0.33:
Find out what modules are used
This software is copyright (c) 2012 by Thomas Klausner.
This software is copyright (c) 2014 by Thomas Klausner.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
......
do{ my $x = {};
$x; }
\ No newline at end of file
do{ my $x = [
{
'ARGV' => []
},
{},
{
'verbose' => undef,
'dist_suffix' => undef,
'PL_files' => undef,
'pollute' => undef,
'metafile2' => 'META.json',
'bindoc_dirs' => [
'blib/script'
],
'conflicts' => {},
'recommends' => {},
'scripts' => undef,
'pod_files' => undef,
'config_dir' => '_build',
'dist_version' => '##{$version##}',
'sign' => undef,
'recurse_into' => [],
'build_bat' => 0,
'extra_linker_flags' => [],
'build_class' => 'MyModuleBuilder',
'prereq_action_types' => [
'requires',
'build_requires',
'test_requires',
'conflicts',
'recommends'
],
'base_dir' => '/home/domm/perl/Module-ExtractUse',
'allow_mb_mismatch' => 0,
'xs_files' => undef,
'destdir' => undef,
'metafile' => 'META.yml',
'mb_version' => '0.4205',
'use_tap_harness' => 0,
'test_file_exts' => [
'.t'
],
'dist_name' => '##{$dist##}',
'has_config_data' => undef,
'install_base' => '/home/domm/.perlbrew/libs/perl-5.16.1@domm',
'module_name' => 'Module::ExtractUse',
'recursive_test_files' => 1,
'libdoc_dirs' => [
'blib/lib',
'blib/arch'
],
'perl' => '/home/domm/perl5/perlbrew/perls/perl-5.16.1/bin/perl',
'dist_author' => undef,
'bundle_inc' => [],
'use_rcfile' => 1,
'configure_requires' => {},
'pureperl_only' => 0,
'extra_manify_args' => undef,
'test_files' => undef,
'dist_abstract' => undef,
'create_readme' => undef,
'prefix_relpaths' => {},
'share_dir' => undef,
'debug' => undef,
'meta_merge' => {},
'get_options' => {},
'dist_version_from' => undef,
'_added_to_INC' => [
'/home/domm/perl/Module-ExtractUse/_build/lib',
'/home/domm/.perlbrew/libs/perl-5.16.1@domm/lib/perl5/x86_64-linux',
'/home/domm/.perlbrew/libs/perl-5.16.1@domm/lib/perl5'
],
'auto_configure_requires' => 1,
'create_license' => undef,
'debugger' => undef,
'html_css' => '',
'cpan_client' => 'cpan',
'mymetafile2' => 'MYMETA.json',
'bundle_inc_preload' => [],
'build_elements' => [
'PL',
'support',
'pm',
'xs',
'share_dir',
'pod',
'script',
'grammar'
],
'release_status' => 'stable',
'needs_compiler' => '',
'orig_dir' => '/home/domm/perl/Module-ExtractUse',
'include_dirs' => [],
'test_requires' => {},
'installdirs' => 'site',
'mymetafile' => 'MYMETA.yml',
'create_makefile_pl' => undef,
'magic_number' => undef,
'dynamic_config' => 1,
'tap_harness_args' => {},
'install_sets' => {},
'install_base_relpaths' => {},
'create_packlist' => 1,
'meta_add' => {},
'requires' => {},
'install_path' => {},
'pm_files' => undef,
'quiet' => undef,
'script_files' => undef,
'extra_compiler_flags' => [],
'build_script' => 'Build',
'original_prefix' => {},
'c_source' => undef,
'program_name' => undef,
'license' => 'unknown',
'autosplit' => undef,
'build_requires' => {},
'allow_pureperl' => 0,
'config' => undef,
'blib' => 'blib',
'prefix' => undef
}
];
$x; }
\ No newline at end of file
do{ my $x = {};
$x; }
\ No newline at end of file
do{ my $x = {};
$x; }
\ No newline at end of file
do{ my $x = {};
$x; }
\ No newline at end of file
package MyModuleBuilder;
use Module::Build;
@ISA = qw(Module::Build);
use File::Copy;
use File::Spec::Functions;
sub process_grammar_files {
my $self = shift;
my $grammar='Grammar.pm';
# precompile grammar
system("$^X -MParse::RecDescent - grammar Module::ExtractUse::Grammar");
# add $VERSION to grammer
open(my $fh,'<',$grammar) || die "cannot read $grammar: $!";
my @content = <$fh>;
close $fh;
splice(@content,1,0,'our $VERSION=##{$version##};'."\n");
open(my $out,">",$grammar) || die "cannot write $grammer: $!";
print $out @content;
close $out;
# move Grammer.pm to right place
my $target = catfile(qw(lib Module ExtractUse),$grammar);
move($grammar, $target) || die "Could not move precompiled $grammar to lib/Module/ExtractUse/Grammer.pm: $!";
}
1;
642008
\ No newline at end of file
do{ my $x = {};
$x; }
\ No newline at end of file
do{ my $x = {
'build_requires' => {},
'test_requires' => {},
'conflicts' => {},
'requires' => {},
'recommends' => {}
};
$x; }
\ No newline at end of file
do{ my $x = {
'install_base' => '/home/domm/.perlbrew/libs/perl-5.16.1@domm'
};
$x; }
\ No newline at end of file
name = Module-ExtractUse
author = Thomas Klausner <domm@cpan.org>
author = Kenichi Ishigaki <kishigaki@gmail.com>
license = Perl_5
copyright_holder = Thomas Klausner
copyright_year = 2012
copyright_year = 2014
[GatherDir]
[PruneCruft]
......
......@@ -36,6 +36,15 @@ require_name: <perl_quotelike>
$return=$name;
}
#-----------------------------------------------------------------
# Rules for no
#-----------------------------------------------------------------
token_no: /\bno\s/ no_stuff /[;}]/
{ $return=$item{no_stuff} }
no_stuff: (base | version | module)
#-----------------------------------------------------------------
# General Rules
#-----------------------------------------------------------------
......
......@@ -8,7 +8,7 @@ use Pod::Strip;
use Parse::RecDescent 1.967009;
use Module::ExtractUse::Grammar;
use Carp;
use version; our $VERSION=version->new('0.32');
use version; our $VERSION=version->new('0.33');
# ABSTRACT: Find out what modules are used
......@@ -93,6 +93,9 @@ sub extract_use {
# Strip obvious comments.
$podless =~ s/(^|[\};])\s*#.*$/$1/mg;
# Strip __(DATA|END)__ sections.
$podless =~ s/\n__(?:DATA|END)__\b.*$//s;
my @statements;
while($podless =~ /$re/gc) {
# to keep parsing time short, split code in statements
......@@ -112,25 +115,39 @@ sub extract_use {
# now that we've got some code containing 'use' or 'require',
# parse it! (using different entry point to save some more
# time)
my $type;
if ($statement=~/\buse/) {
$statement=~s/^(.*?)use\b/use/;
next if $1 && $1 =~ /->\s*$/;
eval {
my $parser=Module::ExtractUse::Grammar->new();
$result=$parser->token_use($statement.';');
};
$type = 'use';
}
elsif ($statement=~/\brequire/) {
$statement=~s/^(.*?)require\b/require/s;
next if $1 && $1 =~ /->\s*$/;
eval {
my $parser=Module::ExtractUse::Grammar->new();
$result=$parser->token_require($statement.';');
};
$type = 'require';
}
elsif ($statement=~/\bno/) {
$statement=~s/^(.*?)no\b/no/s;
next if $1 && $1 =~ /->\s*$/;
eval {
my $parser=Module::ExtractUse::Grammar->new();
$result=$parser->token_no($statement.';');
};
$type = 'no';
}
next unless $result;
foreach (split(/\s+/,$result)) {
$self->_add($_, $eval) if($_);
$self->_add($_, $eval, $type) if($_);
}
}
......@@ -166,6 +183,54 @@ sub used_out_of_eval {
}
sub required {
my $self=shift;
my $key=shift;
return $self->{require}{$key} if ($key);
return $self->{require};
}
sub required_in_eval {
my $self=shift;
my $key=shift;
return $self->{require_in_eval}{$key} if ($key);
return $self->{require_in_eval};
}
sub required_out_of_eval {
my $self=shift;
my $key=shift;
return $self->{require_not_in_eval}{$key} if ($key);
return $self->{require_not_in_eval};
}
sub noed {
my $self=shift;
my $key=shift;
return $self->{no}{$key} if ($key);
return $self->{no};
}
sub noed_in_eval {
my $self=shift;
my $key=shift;
return $self->{no_in_eval}{$key} if ($key);
return $self->{no_in_eval};
}
sub noed_out_of_eval {
my $self=shift;
my $key=shift;
return $self->{no_not_in_eval}{$key} if ($key);
return $self->{no_not_in_eval};
}
sub string {
my $self=shift;
my $sep=shift || ' ';
......@@ -232,9 +297,16 @@ sub _add {
my $self=shift;
my $found=shift;
my $eval=shift;
my $type=shift;
$self->{found}{$found}++;
$self->{found_in_eval}{$found}++ if $eval;
$self->{found_not_in_eval}{$found}++ unless $eval;
$self->{$type}{$found}++;
if ($eval) {
$self->{found_in_eval}{$found}++;
$self->{"${type}_in_eval"}{$found}++;
} else {
$self->{found_not_in_eval}{$found}++;
$self->{"${type}_not_in_eval"}{$found}++;
}
}
sub _found {
......@@ -257,7 +329,7 @@ Module::ExtractUse - Find out what modules are used
=head1 VERSION
version 0.32
version 0.33
=head1 SYNOPSIS
......@@ -326,7 +398,7 @@ The code will be stripped from POD (using Pod::Strip) and split on ";"
(semicolon). Each statement (i.e. the stuff between two semicolons) is
checked by a simple regular expression.
If the statement contains either 'use' or 'require', the statment is
If the statement contains either 'use' or 'require', the statement is
handed over to the parser, who then tries to figure out, B<what> is
used or required. The results will be saved in a data structure that
you can examine afterwards.
......@@ -364,6 +436,30 @@ Same as C<used>, except for considering in-eval-context only.
Same as C<used>, except for considering NOT-in-eval-context only.
=head3 required
Same as C<used>, except for considering 'require'd modules only.
=head3 required_in_eval
Same as C<required>, except for considering in-eval-context only.
=head3 required_out_of_eval
Same as C<required>, except for considering NOT-in-eval-context only.
=head3 noed
Same as C<used>, except for considering 'no'ed modules only.
=head3 noed_in_eval
Same as C<noed>, except for considering in-eval-context only.
=head3 noed_out_of_eval
Same as C<noed>, except for considering NOT-in-eval-context only.
=head3 string
print $p->string($seperator)
......@@ -430,13 +526,23 @@ Nothing.
Parse::RecDescent, Module::ScanDeps, Module::Info, Module::CPANTS::Analyse
=head1 AUTHOR
=head1 AUTHORS
=over 4
=item *
Thomas Klausner <domm@cpan.org>
=item *
Kenichi Ishigaki <kishigaki@gmail.com>
=back
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Thomas Klausner.
This software is copyright (c) 2014 by Thomas Klausner.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
......
This diff is collapsed.
......@@ -102,6 +102,27 @@ Test::Pod::all_pod_files_ok( 'lib', -d $generated_pod_dir ? $generated_pod_dir :
['do { use Foo::Bar33 };',[qw(Foo::Bar33)],undef,[qw(Foo::Bar33)]],
['use version;',[qw(version)],undef,[qw(version)]],
['use version 0.77;',[qw(version)],undef,[qw(version)]],
['$config->use or die;',undef,undef,undef],
['$config->require or die;',undef,undef,undef],
[q{
__DATA__
@@ some template
use strict;
__END__
use warnings;
},undef,undef,undef],
['noSome::Module1;',undef,undef,undef],
['no Some::Module2;',[qw(Some::Module2)],undef,[qw(Some::Module2)]],
["yadda yadda noless stuff;".'no Some::Module3 qw/$VERSION @EXPORT @EXPORT_OK/;',[qw(Some::Module3)],undef,[qw(Some::Module3)]],
['no base qw(Class::DBI4 Foo::Bar5);',[qw(Class::DBI4 Foo::Bar5)],undef,[qw(Class::DBI4 Foo::Bar5)]],
['if ($foo) { no Foo::Bar6; }',[qw(Foo::Bar6)],undef,[qw(Foo::Bar6)]],
#6
['no constant dl_ext => ".$Config{dlext}";',[qw(constant)],undef,[qw(constant)]],
['no strict;',[qw(strict)],undef,[qw(strict)]],
['no Foo8 qw/asdfsdf/;',[qw(Foo8)],undef,[qw(Foo8)]],
['$no=stuff;',undef,undef,undef],
['abno Stuff;',undef,undef,undef],
);
......@@ -119,11 +140,11 @@ foreach my $t (@tests) {
for(my $i = 0; $i < @used; ++$i) {
if (ref($expected[$i]) eq 'ARRAY') {
cmp_bag($used[$i]||[],$expected[$i]);
cmp_bag($used[$i]||[],$expected[$i],$i.": ".$code);
} elsif (!defined $expected[$i]) {
is(undef,$used[$i],'');
is(undef,$used[$i],$i.": ".$code);
} else {
is($used[$i],$expected[$i]);
is($used[$i],$expected[$i],$i.": ".$code);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment