@@ -34,14 +34,6 @@ my $class = Module::Build->subclass( code => <<'END_SUBCLASS' );
return;
} # end ACTION_authortest()
- sub ACTION_distdir {
- my ($self) = @_;
-
- $self->depends_on('authortest');
-
- return $self->SUPER::ACTION_distdir();
- } # end ACTION_distdir
-
END_SUBCLASS
my $builder = $class->new(
@@ -59,11 +51,12 @@ my $builder = $class->new(
},
requires => {
+ 'Const::Fast' => 0,
'English' => 0,
'Exporter' => 5.57,
'File::Next' => 1.02,
- 'PPI::Document' => 1.203,
- 'Readonly' => 1.03,
+ 'Module::Path' => 0.01,
+ 'PPI::Document' => 1.205,
'strict' => 0,
'utf8' => 0,
'version' => 0.74,
@@ -96,6 +89,7 @@ my $builder = $class->new(
qw<
MANIFEST
MANIFEST.bak
+ META.json
META.yml
Makefile
Makefile.old
@@ -1,5 +1,9 @@
Revision history for Module::Used.
+1.3.0 2012-09-27
+
+ New modules_used_by_modules(), thanks to Neil Bowers.
+
1.2.0 2008-12-08
Case-insensitive sort.
@@ -18,3 +18,4 @@ xt/author/pod_coverage.t
xt/author/pod_syntax.t
xt/author/README
META.yml
+META.json
@@ -0,0 +1,62 @@
+{
+ "abstract" : "Find modules loaded by Perl code without running it.",
+ "author" : [
+ "Elliot Shank <perl@galumph.com>"
+ ],
+ "dynamic_config" : 0,
+ "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Module-Used",
+ "no_index" : {
+ "directory" : [
+ "xt"
+ ],
+ "file" : []
+ },
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "Test::Deep" : "0.098",
+ "Test::More" : "0.72"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "Module::Build" : "0.2808"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Const::Fast" : "0",
+ "English" : "0",
+ "Exporter" : "5.57",
+ "File::Next" : "1.02",
+ "Module::Path" : "0.01",
+ "PPI::Document" : "1.205",
+ "strict" : "0",
+ "utf8" : "0",
+ "version" : "0.74",
+ "warnings" : "0"
+ }
+ }
+ },
+ "provides" : {
+ "Module::Used" : {
+ "file" : "lib/Module/Used.pm",
+ "version" : "v1.3.0"
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "license" : [
+ "http://dev.perl.org/licenses/"
+ ]
+ },
+ "version" : "v1.3.0"
+}
@@ -1,37 +1,38 @@
---
-name: Module-Used
-version: v1.002000
+abstract: 'Find modules loaded by Perl code without running it.'
author:
- 'Elliot Shank <perl@galumph.com>'
-abstract: Find modules loaded by Perl code without running it.
-license: perl
-resources:
- license: http://dev.perl.org/licenses/
-requires:
- English: 0
- Exporter: 5.57
- File::Next: 1.02
- PPI::Document: 1.203
- Readonly: 1.03
- strict: 0
- utf8: 0
- version: 0.74
- warnings: 0
build_requires:
Test::Deep: 0.098
Test::More: 0.72
+configure_requires:
+ Module::Build: 0.2808
dynamic_config: 0
-provides:
- Module::Used:
- file: lib/Module/Used.pm
- version: v1.002000
-generated_by: Module::Build version 0.3
+generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921'
+license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
+name: Module-Used
no_index:
directory:
- xt
file: []
-configure_requires:
- Module::Build: 0.2808
+provides:
+ Module::Used:
+ file: lib/Module/Used.pm
+ version: v1.3.0
+requires:
+ Const::Fast: 0
+ English: 0
+ Exporter: 5.57
+ File::Next: 1.02
+ Module::Path: 0.01
+ PPI::Document: 1.205
+ strict: 0
+ utf8: 0
+ version: 0.74
+ warnings: 0
+resources:
+ license: http://dev.perl.org/licenses/
+version: v1.3.0
@@ -27,7 +27,7 @@ a bug in those tools and not in this distribution.
COPYRIGHT AND LICENCE
-Copyright ©2008, Elliot Shank <perl@galumph.com>. All rights reserved.
+Copyright ©2008-2012, Elliot Shank <perl@galumph.com>.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
@@ -6,16 +6,16 @@ use 5.008003;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.2.0');
+use version; our $VERSION = qv('v1.3.0');
+use Const::Fast qw< const >;
use English qw< -no_match_vars >;
-use Readonly;
use File::Next ();
use Module::Used qw< modules_used_in_files >;
-Readonly my %IGNORED_DIRECTORIES =>
+const my %IGNORED_DIRECTORIES =>
map { $_ => 1 }
qw<
.bzr
@@ -79,7 +79,7 @@ sub _get_files {
sub _is_ignored_directory {
my ($directory) = @_;
- return 1 if $IGNORED_DIRECTORIES{$directory};
+ return 1 if exists $IGNORED_DIRECTORIES{$directory};
return 0;
}
@@ -87,15 +87,15 @@ sub _is_ignored_file {
my ($file) = @_;
return 1 if $file =~ qr< (?: [.] bak | ~ ) \z >xms;
- return 1 if $file =~ qr< [#] .+ [#] \z >xms;
- return 1 if $file =~ qr< [._] .* \.swp \z >xms;
- return $file =~ qr< core [.] \d+ \z >xms;
+ return 1 if $file =~ qr< [#] .+ [#] \z >xms;
+ return 1 if $file =~ qr< [._] .* [.]sw[op] \z >xms;
+ return $file =~ qr< core [.] \d+ \z >xms;
}
sub _is_perl_file {
my ($file) = @_;
- return 1 if $file =~ m/ [.] (?: p (?: l x? | m ) | t | PL ) \z /xms; ## no critic (ProhibitSingleCharAlternation)
+ return 1 if $file =~ m/ [.] (?: p (?: l x? | m ) | t | PL ) \z /xms;
return 0 if index($file, q<.>) >= 0;
return _is_perl_program($file);
}
@@ -129,7 +129,7 @@ modules-used - List modules used by a set of Perl source files without running t
=head1 VERSION
-This document describes modules-used version 1.2.0.
+This document describes modules-used version 1.3.0.
=head1 USAGE
@@ -167,6 +167,12 @@ None.
=over
+=item Could not find module "%s" in @INC.
+
+Cannot find the location of the named module. Note that this program will not
+find any dynamically loaded modules.
+
+
=item "%s" does not exist.
Cannot find the file.
@@ -209,9 +215,8 @@ None known.
None reported.
-Please report any bugs or feature requests to
-C<bug-module-used@rt.cpan.org>, or through the web
-interface at L<http://rt.cpan.org>.
+Please report any bugs or feature requests to C<bug-module-used@rt.cpan.org>,
+or through the web interface at L<http://rt.cpan.org>.
=head1 SEE ALSO
@@ -229,8 +234,7 @@ Elliot Shank C<< <perl@galumph.com> >>
=head1 LICENSE AND COPYRIGHT
-Copyright ©2008, Elliot Shank C<< <perl@galumph.com> >>. All
-rights reserved.
+Copyright ©2008-2012, Elliot Shank C<< <perl@galumph.com> >>.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself. See L<perlartistic>.
@@ -6,23 +6,25 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.2.0');
+use version; our $VERSION = qv('v1.3.0');
-use English qw<-no_match_vars>;
-use Readonly;
+use English qw< -no_match_vars >;
+use Const::Fast qw< const >;
use Exporter qw< import >;
-our @EXPORT_OK =
- qw<
- modules_used_in_files
- modules_used_in_string
- modules_used_in_document
- >;
+our @EXPORT_OK = qw<
+ modules_used_in_files
+ modules_used_in_string
+ modules_used_in_document
+ modules_used_in_modules
+>;
our %EXPORT_TAGS = (
all => [@EXPORT_OK],
);
+
+use Module::Path qw< module_path >;
use PPI::Document ();
@@ -41,6 +43,22 @@ sub modules_used_in_files {
} # end modules_used_in_files()
+sub modules_used_in_modules {
+ my (@modules) = @_;
+ my @files;
+ my $fullpath;
+
+ foreach my $module (@modules) {
+ $fullpath = module_path($module)
+ or die qq<Could not find module "$module" in \@INC.\n>;
+
+ push @files, $fullpath;
+ }
+
+ return modules_used_in_files(@files);
+} # end modules_used_in_modules()
+
+
sub modules_used_in_string {
my ($string) = @_;
@@ -114,7 +132,7 @@ sub _create_document_from_file {
} # end _create_document_from_file()
-Readonly::Scalar my $QUOTE_WORDS_DELIMITER_OFFSET => length 'qw<';
+const my $QUOTE_WORDS_DELIMITER_OFFSET => length 'qw<';
sub _modules_loaded_by_base_or_parent {
my ($statement) = @_;
@@ -135,7 +153,7 @@ sub _modules_loaded_by_base_or_parent {
if ( $child->isa('PPI::Token::Quote') ) {
push @modules, $child->string();
} elsif ( $child->isa('PPI::Token::QuoteLike::Words') ) {
- push @modules, _quotelike_words_literal($child);
+ push @modules, $child->literal();
} # end if
} # end foreach
@@ -143,18 +161,6 @@ sub _modules_loaded_by_base_or_parent {
} # end _modules_loaded_by_base_or_parent()
-# Delete this once next PPI version is released.
-sub _quotelike_words_literal {
- my ($quotelike_words) = @_;
-
- my $content = $quotelike_words->content();
-
- $content = substr $content, $QUOTE_WORDS_DELIMITER_OFFSET;
- chop $content;
- return split q< >, $content;
-} # end _quotelike_words_literal()
-
-
sub _modules_loaded_by_moose_sugar {
my ($document, $sugar) = @_;
@@ -171,7 +177,7 @@ sub _modules_loaded_by_moose_sugar {
if ( $child->isa('PPI::Token::Quote') ) {
push @modules, $child->string();
} elsif ( $child->isa('PPI::Token::QuoteLike::Words') ) {
- push @modules, _quotelike_words_literal($child);
+ push @modules, $child->literal();
} # end if
} # end foreach
} # end foreach
@@ -215,7 +221,7 @@ Module::Used - Find modules loaded by Perl code without running it.
=head1 VERSION
-This document describes Module::Used version 1.2.0.
+This document describes Module::Used version 1.3.0.
=head1 SYNOPSIS
@@ -223,6 +229,7 @@ This document describes Module::Used version 1.2.0.
use Module::Used qw< :all >;
@modules = modules_used_in_files(@files);
+ @modules = modules_used_in_modules(@module_names);
# "strict", "Find::Bin", "warnings"
@modules = modules_used_in_string(
@@ -258,6 +265,12 @@ Return a list of modules used in the specified files.
C<die>s if there is a problem reading a file.
+=item C< modules_used_in_modules( @module_names ) >
+
+Return a list of modules used in the specified modules.
+
+C<die>s if there any of the modules weren't found in C<@INC>.
+
=item C< modules_used_in_string( $string ) >
@@ -276,6 +289,12 @@ Return a list of modules used in the specified L<PPI::Document>.
=over
+=item Could not find module "%s" in @INC.
+
+Cannot find the location of the named module. Note that this module will not
+find any dynamically loaded modules.
+
+
=item "%s" does not exist.
Cannot find the file.
@@ -306,7 +325,10 @@ None, currently.
=head1 DEPENDENCIES
+L<Const::Fast>
+L<Module::Path>
L<PPI::Document>
+L<version>
=head1 INCOMPATIBILITIES
@@ -337,7 +359,7 @@ Elliot Shank C<< <perl@galumph.com> >>
=head1 LICENSE AND COPYRIGHT
-Copyright ©2008, Elliot Shank C<< <perl@galumph.com> >>. All rights reserved.
+Copyright ©2008-2012, Elliot Shank C<< <perl@galumph.com> >>.
This module is free software; you can redistribute it and/or modify it under
the same terms as Perl itself. See L<perlartistic>.
@@ -5,8 +5,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::More tests => 1;
use_ok('Module::Used') or BAIL_OUT('No point in continuing.');
@@ -5,12 +5,10 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
-use Module::Used qw< modules_used_in_string modules_used_in_files >;
+use Module::Used qw< modules_used_in_string modules_used_in_files modules_used_in_modules >;
use Test::Deep qw< bag cmp_deeply >;
-use Test::More tests => 21;
+use Test::More tests => 22;
{
@@ -72,6 +70,24 @@ use Test::More tests => 21;
$code,
);
+ cmp_deeply(
+ [ modules_used_in_modules( 'Module::Used' ) ],
+ bag(
+ qw<
+ Const::Fast
+ English
+ Exporter
+ Module::Path
+ PPI::Document
+ strict
+ utf8
+ version
+ warnings
+ >
+ ),
+ 'Module::Used',
+ );
+
$code = q<use base 'A', "B", q[C], qq[D::E];>;
cmp_deeply(
@@ -99,7 +115,7 @@ use Test::More tests => 21;
cmp_deeply(
[ modules_used_in_files( __FILE__ ) ],
- bag( qw< utf8 strict warnings version Module::Used Test::Deep Test::More > ),
+ bag( qw< utf8 strict warnings Module::Used Test::Deep Test::More > ),
$code,
);
@@ -9,8 +9,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use File::Find;
use File::Slurp;
@@ -9,17 +9,15 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
+use Const::Fast qw< const >;
use File::Find;
use File::Slurp;
-use Readonly;
use Test::More qw(no_plan); ## no critic (Bangs::ProhibitNoPlan)
-Readonly my $LOCALTIME_YEAR_FIELD_NUMBER => 5;
-Readonly my $LOCALTIME_YEAR_OFFSET => 1900;
+const my $LOCALTIME_YEAR_FIELD_NUMBER => 5;
+const my $LOCALTIME_YEAR_OFFSET => 1900;
my $this_year =
@@ -9,8 +9,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
# No POD coverage due to complaints about builtins when using Fatal.
use Test::Distribution ( distversion => 1, not => 'podcover' );
@@ -6,8 +6,6 @@ use 5.008003;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::More;
use Test::Kwalitee;
@@ -5,8 +5,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::Perl::Critic (
-severity => 1,
-profile => 'xt/author/perlcriticrc-code'
@@ -5,8 +5,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::Perl::Critic (
-severity => 1,
-profile => 'xt/author/perlcriticrc-tests'
@@ -19,6 +19,8 @@ verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n
[Documentation::PodSpelling]
stop_words = PPI regex subclasses
+[-Documentation::RequirePodLinksIncludeText]
+
[Documentation::RequirePodSections]
source = module_starter_pbp_0_0_3
language = en_US
@@ -23,6 +23,8 @@ verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n
[InputOutput::RequireCheckedSyscalls]
functions = open close
+[-Modules::RequireVersionVar]
+
[RegularExpressions::ProhibitUnusualDelimiters]
allow_all_brackets = 1
@@ -6,8 +6,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::More;
use Test::Pod::Coverage;
@@ -6,8 +6,6 @@ use utf8;
use strict;
use warnings;
-use version; our $VERSION = qv('v1.1.0');
-
use Test::More;
use Test::Pod;