Module-Used-v1.3.0000755000766000766 012017025061 13775 5ustar00elliotelliot000000000000Module-Used-v1.3.0/Build.PL000444000766000766 507612017025061 15436 0ustar00elliotelliot000000000000use 5.008003; use utf8; use strict; use warnings; use English qw< -no_match_vars >; use Module::Build; my $class = Module::Build->subclass( code => <<'END_SUBCLASS' ); sub ACTION_test { my ($self) = @_; $self->depends_on('manifest'); return $self->SUPER::ACTION_test(); } sub ACTION_authortest { my ($self) = @_; $self->depends_on('build'); $self->depends_on('manifest'); $self->depends_on('distmeta'); $self->test_files( qw< t xt/author > ); $self->recursive_test_files(1); $self->depends_on('test'); return; } # end ACTION_authortest() END_SUBCLASS my $builder = $class->new( module_name => 'Module::Used', dist_author => 'Elliot Shank ', license => 'perl', dynamic_config => 0, create_readme => 0, create_packlist => 1, sign => 0, build_requires => { 'Test::Deep' => 0.098, 'Test::More' => 0.72, }, 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, }, recommends => { }, meta_merge => { configure_requires => { 'Module::Build' => 0.2808, }, no_index => { file => [ qw< > ], directory => [ qw< xt > ], }, }, script_files => [ glob('bin/*') ], add_to_cleanup => [ qw< MANIFEST MANIFEST.bak META.json META.yml Makefile Makefile.old Makefile.PL pod2htm?.tmp pm_to_blib *.tmp *.bak */*.tmp */*.bak */*/*.tmp */*/*.bak */*/*/*.tmp */*/*/*.bak */*/*/*/*.tmp */*/*/*/*.bak Module-Used-* > ], ); $builder->create_build_script(); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/Changes000444000766000766 70712017025061 15411 0ustar00elliotelliot000000000000Revision 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. Now looks for "extends" and "with" when Moose or Moose::Role are used. 1.1.0 2008-07-06 Now recursivly finds Perl code. 1.0.1 2008-06-16 Require perl 5.8.3. Due to site/core @INC issues, requiring Exporter 5.57 isn't good enough. 1.0.0 2008-06-15 Initial release. Module-Used-v1.3.0/MANIFEST000444000766000766 65312017025061 15247 0ustar00elliotelliot000000000000bin/modules-used Build.PL Changes lib/Module/Used.pm MANIFEST This list of files README t/a_use_ok.t t/b_modules_used.t xt/author/consistent_version_numbers.t xt/author/copyright.t xt/author/distribution.t xt/author/kwalitee.t xt/author/perlcritic-code.t xt/author/perlcritic-tests.t xt/author/perlcriticrc-code xt/author/perlcriticrc-tests xt/author/pod_coverage.t xt/author/pod_syntax.t xt/author/README META.yml META.json Module-Used-v1.3.0/META.json000444000766000766 264012017025061 15555 0ustar00elliotelliot000000000000{ "abstract" : "Find modules loaded by Perl code without running it.", "author" : [ "Elliot Shank " ], "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" } Module-Used-v1.3.0/META.yml000444000766000766 143412017025061 15405 0ustar00elliotelliot000000000000--- abstract: 'Find modules loaded by Perl code without running it.' author: - 'Elliot Shank ' build_requires: Test::Deep: 0.098 Test::More: 0.72 configure_requires: Module::Build: 0.2808 dynamic_config: 0 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: [] 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 Module-Used-v1.3.0/README000444000766000766 135212017025061 15013 0ustar00elliotelliot000000000000Module::Used version 1.2.0. List modules used by a set of Perl code. INSTALLATION To install this module, ensure Module::Build is installed, then run the following commands: perl Build.PL ./Build ./Build test ./Build install NOTE ON ENCODINGS All files in this distribution should be considered to be in UTF-8 format. Some standard documentation tools do not presently deal very well with this and their output is mangled. Give that it is the 21st century, this is considered a bug in those tools and not in this distribution. COPYRIGHT AND LICENCE Copyright ©2008-2012, Elliot Shank . This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Module-Used-v1.3.0/bin000755000766000766 012017025061 14545 5ustar00elliotelliot000000000000Module-Used-v1.3.0/bin/modules-used000555000766000766 1264612017025061 17267 0ustar00elliotelliot000000000000#!/usr/bin/env perl use utf8; use 5.008003; use strict; use warnings; use version; our $VERSION = qv('v1.3.0'); use Const::Fast qw< const >; use English qw< -no_match_vars >; use File::Next (); use Module::Used qw< modules_used_in_files >; const my %IGNORED_DIRECTORIES => map { $_ => 1 } qw< .bzr .cdv ~.dep ~.dot ~.nib ~.plst .git .hg .pc .svn blib CVS RCS SCCS _darcs _sgbak autom4te.cache cover_db _build >; return 1 if caller; exit run(@ARGV); sub run { my (@argv) = @_; my @modules = modules_used_in_files( _get_files(@argv) ); foreach my $module ( sort { lc $a cmp lc $b } @modules ) { print "$module\n"; } # end foreach return 0; } # end run() sub _get_files { my @paths = @_; my $iterator = File::Next::files( { file_filter => sub { not _is_ignored_file($_) and _is_perl_file($File::Next::name) }, descend_filter => sub { not _is_ignored_directory($_) }, }, @paths, ); my @files; while ( defined ( my $file = $iterator->() ) ) { push @files, $file; } return @files; } sub _is_ignored_directory { my ($directory) = @_; return 1 if exists $IGNORED_DIRECTORIES{$directory}; return 0; } 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< [._] .* [.]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; return 0 if index($file, q<.>) >= 0; return _is_perl_program($file); } sub _is_perl_program { my ($file) = @_; if (open my $handle, '<', $file) { my $first_line = <$handle>; if (not close $handle) { die qq; } return $first_line =~ m< \A [#]! .* \bperl >xms; } die qq; } __END__ =encoding utf8 =for stopwords =head1 NAME modules-used - List modules used by a set of Perl source files without running them. =head1 VERSION This document describes modules-used version 1.3.0. =head1 USAGE modules-used source-file [...] =head1 DESCRIPTION Dumps a list of modules used by some Perl code. Modules are found statically based upon C and C statements. If use of the L or L is found, both that module and the referenced ones will be emitted. Dynamically loaded modules will not be found. =head1 REQUIRED ARGUMENTS =over =item · source-file [...] A list of files to search. =back =head1 OPTIONS None. =head1 DIAGNOSTICS =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. =item "%s" is not readable. Cannot read the file. =item "%s" is a directory. The "file" was actually a directory. =item Could not parse "%s". L could not interpret the file as a Perl document. =back =head1 CONFIGURATION AND ENVIRONMENT None. =head1 DEPENDENCIES L =head1 INCOMPATIBILITIES None known. =head1 BUGS AND LIMITATIONS None reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 SEE ALSO L L L L =head1 AUTHOR Elliot Shank C<< >> =head1 LICENSE AND COPYRIGHT Copyright ©2008-2012, Elliot Shank C<< >>. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/lib000755000766000766 012017025061 14543 5ustar00elliotelliot000000000000Module-Used-v1.3.0/lib/Module000755000766000766 012017025061 15770 5ustar00elliotelliot000000000000Module-Used-v1.3.0/lib/Module/Used.pm000444000766000766 2303512017025061 17406 0ustar00elliotelliot000000000000package Module::Used; use 5.008003; use utf8; use strict; use warnings; use version; our $VERSION = qv('v1.3.0'); 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 modules_used_in_modules >; our %EXPORT_TAGS = ( all => [@EXPORT_OK], ); use Module::Path qw< module_path >; use PPI::Document (); sub modules_used_in_files { my (@files) = @_; my %modules; foreach my $file (@files) { my $document = _create_document_from_file($file); my @loaded_modules = modules_used_in_document($document); @modules{@loaded_modules} = (1) x @loaded_modules; } # end foreach return keys %modules; } # 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; push @files, $fullpath; } return modules_used_in_files(@files); } # end modules_used_in_modules() sub modules_used_in_string { my ($string) = @_; my $document = PPI::Document->new(\$string, readonly => 1) or die qq, PPI::Document->errstr(), ".\n"; return modules_used_in_document($document); } # end modules_used_in_string() sub modules_used_in_document { my ($document) = @_; my %modules; my $includes = $document->find('PPI::Statement::Include'); if ($includes) { foreach my $statement ( @{$includes} ) { my $module = $statement->module(); if ($module) { $modules{$module} = 1; if ($module eq 'base' or $module eq 'parent') { my @loaded_modules = _modules_loaded_by_base_or_parent($statement); @modules{@loaded_modules} = (1) x @loaded_modules; } # end if } # end if } # end foreach my @moose_modules; if ( $modules{Moose} ) { @moose_modules = _modules_loaded_by_moose_sugar($document, 'extends'); push @moose_modules, _modules_loaded_by_moose_sugar($document, 'with'); } elsif ( $modules{'Moose::Role'} ) { @moose_modules = _modules_loaded_by_moose_sugar($document, 'with'); } # end if @modules{@moose_modules} = (1) x @moose_modules; } # end if return keys %modules; } # end modules_used_in_document() sub _create_document_from_file { my ($source) = @_; -e $source or die qq<"$source" does not exist.\n>; -r _ or die qq<"$source" is not readable.\n>; not -d _ or die qq<"$source" is a directory.\n>; if ( -z _ ) { # PPI barfs on empty documents for some reason. return PPI::Document->new(); } my $document = PPI::Document->new($source, readonly => 1) or die qq, PPI::Document->errstr(), ".\n"; return $document; } # end _create_document_from_file() const my $QUOTE_WORDS_DELIMITER_OFFSET => length 'qw<'; sub _modules_loaded_by_base_or_parent { my ($statement) = @_; my @modules; my @children = $statement->schildren(); shift @children; # use/require/my shift @children; # 'base'/'parent' if (@children and $children[0] =~ m< v? [\d.]+ >xms) { # Skip version requirement for 'base'/'parent'. Not worrying about # the potential following comma. shift @children; } foreach my $child (@children) { if ( $child->isa('PPI::Token::Quote') ) { push @modules, $child->string(); } elsif ( $child->isa('PPI::Token::QuoteLike::Words') ) { push @modules, $child->literal(); } # end if } # end foreach return @modules; } # end _modules_loaded_by_base_or_parent() sub _modules_loaded_by_moose_sugar { my ($document, $sugar) = @_; my @modules; my $statements = $document->find( _create_wanted_moose_sugar($sugar) ); return if not $statements; foreach my $statement ( @{$statements} ) { my @children = $statement->schildren(); shift @children; # 'with' foreach my $child (@children) { if ( $child->isa('PPI::Token::Quote') ) { push @modules, $child->string(); } elsif ( $child->isa('PPI::Token::QuoteLike::Words') ) { push @modules, $child->literal(); } # end if } # end foreach } # end foreach return @modules; } # end _modules_loaded_by_moose_sugar() sub _create_wanted_moose_sugar { my ($sugar) = @_; # Have to return 0 for false because undef tells PPI to stop searching. return sub { my (undef, $element) = @_; # Fix this once the next PPI version is released. Want only vanilla # statements. return 0 if ref $element ne 'PPI::Statement'; my $first_child = $element->schild(0); return 0 if not $first_child; return 0 if not $first_child->isa('PPI::Token::Word'); return $first_child->content() eq $sugar; }; # end closure } # end _create_wanted_moose_sugar() 1; # Magic true value required at end of module. __END__ =encoding utf8 =for stopwords =head1 NAME Module::Used - Find modules loaded by Perl code without running it. =head1 VERSION This document describes Module::Used version 1.3.0. =head1 SYNOPSIS 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( 'use strict; require Find::Bin; no warnings;' ); # "Exporter" @modules = modules_used_in_string( 'use parent 0.221 qw< Exporter >;' ); =head1 DESCRIPTION Modules are found statically based upon C and C statements. If use of the L or L is found, both that module and the referenced ones will be returned. If L or L are found, this will look for C and C sugar will be looked for; presently, this will miss modules listed in parentheses. Dynamically loaded modules will not be found. =head1 INTERFACE Nothing is exported by default, but you can import everything using the C<:all> tag. =over =item C< modules_used_in_files( @files ) > Return a list of modules used in the specified files. Cs 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. Cs if there any of the modules weren't found in C<@INC>. =item C< modules_used_in_string( $string ) > Return a list of modules used in the code in the parameter. =item C< modules_used_in_document( $document ) > Return a list of modules used in the specified L. =back =head1 DIAGNOSTICS =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. =item "%s" is not readable. Cannot read the file. =item "%s" is a directory. The "file" was actually a directory. =item Could not parse "%s". L could not interpret the file as a Perl document. =back =head1 CONFIGURATION AND ENVIRONMENT None, currently. =head1 DEPENDENCIES L L L L =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS None reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 SEE ALSO L L L L =head1 AUTHOR Elliot Shank C<< >> =head1 LICENSE AND COPYRIGHT Copyright ©2008-2012, Elliot Shank C<< >>. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. =cut # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/t000755000766000766 012017025061 14240 5ustar00elliotelliot000000000000Module-Used-v1.3.0/t/a_use_ok.t000444000766000766 54212017025061 16330 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; use Test::More tests => 1; use_ok('Module::Used') or BAIL_OUT('No point in continuing.'); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/t/b_modules_used.t000444000766000766 672612017025061 17566 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; 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 => 22; { my $code; $code = 'say $x;'; ## no critic (RequireInterpolationOfMetachars) cmp_deeply( [ modules_used_in_string( $code ) ], [], $code, ); $code = 'use strict;'; cmp_deeply( [ modules_used_in_string( $code ) ], [ qw< strict > ], $code, ); $code = 'use 5.006;'; cmp_deeply( [ modules_used_in_string( $code ) ], [], $code, ); $code = q< use A; require B; no C; >; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< A B C > ), 'use require no', ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< base > ), $code, ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< base > ), $code, ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< A base > ), $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; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< A B C D::E base > ), $code, ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< A B C D::E parent > ), $code, ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< A base > ), $code, ); cmp_deeply( [ modules_used_in_files( __FILE__ ) ], bag( qw< utf8 strict warnings Module::Used Test::Deep Test::More > ), $code, ); $code = q; cmp_deeply( [ modules_used_in_string( $code ) ], bag( qw< > ), $code, ); } _test_moose_sugar('extends', 'Moose'); _test_moose_sugar('with', 'Moose'); _test_moose_sugar('with', 'Moose::Role'); sub _test_moose_sugar { my ($sugar, $module) = @_; my $code = qq; cmp_deeply( [ modules_used_in_string( $code ) ], bag( $module, qw< Bar Baz > ), $code, ); $code = qq; cmp_deeply( [ modules_used_in_string( $code ) ], bag( $module, qw< Bar Baz > ), $code, ); TODO: { local $TODO = q; $code = qq; cmp_deeply( [ modules_used_in_string( $code ) ], bag( $module, qw< Bar Baz > ), $code, ); } return; } # end _test_moose_sugar() # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt000755000766000766 012017025061 14430 5ustar00elliotelliot000000000000Module-Used-v1.3.0/xt/author000755000766000766 012017025061 15732 5ustar00elliotelliot000000000000Module-Used-v1.3.0/xt/author/consistent_version_numbers.t000444000766000766 261112017025061 23745 0ustar00elliotelliot000000000000#!/usr/bin/env perl # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. use 5.008003; use utf8; use strict; use warnings; use File::Find; use File::Slurp; use Test::More qw(no_plan); ## no critic (Bangs::ProhibitNoPlan) my $last_version = undef; find( {wanted => \&check_version, no_chdir => 1}, 'blib' ); if (! defined $last_version) { ## no critic (RequireInterpolationOfMetachars) fail('Failed to find any files with $VERSION'); ## use critic } # end if sub check_version { # $_ is the full path to the file return if not mxms and not m< [.] pm \z >xms; my $content = read_file($_); # only look at perl scripts, not sh scripts return if mxms and $content !~ m< \A \#![^\r\n]+?perl >xms; my @version_lines = $content =~ m< ( [^\n]* \$VERSION [^\n]* ) >xmsg; if (@version_lines == 0) { fail($_); } # end if foreach my $line (@version_lines) { if (!defined $last_version) { $last_version = shift @version_lines; pass($_); } else { is($line, $last_version, $_); } # end if } # end foreach return; } # end check_version() # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/copyright.t000444000766000766 523712017025061 20273 0ustar00elliotelliot000000000000#!/usr/bin/env perl # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. use 5.008003; use utf8; use strict; use warnings; use Const::Fast qw< const >; use File::Find; use File::Slurp; use Test::More qw(no_plan); ## no critic (Bangs::ProhibitNoPlan) const my $LOCALTIME_YEAR_FIELD_NUMBER => 5; const my $LOCALTIME_YEAR_OFFSET => 1900; my $this_year = (localtime)[$LOCALTIME_YEAR_FIELD_NUMBER] + $LOCALTIME_YEAR_OFFSET; my $copyrights_found = 0; find({wanted => \&check_file, no_chdir => 1}, 'blib'); foreach ( grep { m/^readme/xmsi } read_dir(q<.>) ) { check_file(); } # end foreach ok($copyrights_found != 0, 'found a copyright statement'); sub check_file { # $_ is the path to a filename, relative to the root of the # distribution # Only test plain files return if (! -f $_); ## no critic (ProhibitComplexRegexes) # Filter the list of filenames return if not m< ^ (?: README.* # docs | .*/scripts/[^/]+ # programs | .*/script/[^/]+ # programs | .*/bin/[^/]+ # programs | .*\.(?: pl # program ext | pm # module ext | html # doc ext | 3pm # doc ext | [13] # doc ext ) ) $ >xms; ## use critic my $content = read_file($_); # Note: man pages will fail to match if the correct form of the # copyright symbol is used because the man page translators don't # handle UTF-8. # # For some reason, Vim writes a bad utf8 version of the copyright sign # if I attempt to modify the line. So, disable the violation. *sigh* ## no critic (ProhibitEscapedMetacharacters) my @copyright_years = $content =~ m< (?: copyright | \(c\) | © ) \s* (?: \d{4} \\? - )? (\d{4}) >gixms; if (0 < grep {$_ ne $this_year} @copyright_years) { fail("$_ copyrights: @copyright_years"); } elsif (0 == @copyright_years) { pass("$_, no copyright found"); } else { pass($_); } # end if return $copyrights_found += @copyright_years; } # end check_file() # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/distribution.t000444000766000766 75412017025061 20761 0ustar00elliotelliot000000000000#!/usr/bin/env perl # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. use 5.008003; use utf8; use strict; use warnings; # No POD coverage due to complaints about builtins when using Fatal. use Test::Distribution ( distversion => 1, not => 'podcover' ); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/kwalitee.t000444000766000766 45412017025061 20044 0ustar00elliotelliot000000000000#!/usr/bin/env perl use utf8; use 5.008003; use strict; use warnings; use Test::More; use Test::Kwalitee; # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/perlcritic-code.t000444000766000766 60612017025061 21306 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; use Test::Perl::Critic ( -severity => 1, -profile => 'xt/author/perlcriticrc-code' ); all_critic_ok( qw< lib bin > ); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/perlcritic-tests.t000444000766000766 60412017025061 21534 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; use Test::Perl::Critic ( -severity => 1, -profile => 'xt/author/perlcriticrc-tests' ); all_critic_ok( qw< t xt > ); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/perlcriticrc-code000444000766000766 276312017025061 21417 0ustar00elliotelliot000000000000# Make things as strict as possible. profile-strictness = quiet severity = 1 verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n # Need to write CodeLayout::RequireUTF8 [-CodeLayout::RequireASCII] # No Emacs around here. [-Editor::RequireEmacsFileVariables] [-ErrorHandling::RequireUseOfExceptions] # Perl::Tidy wouldn't know a properly formatted conditional expression # if one stomped all over Perl::Tidy.pm. (Not to say that P::T isn't # useful.) [-CodeLayout::RequireTidyCode] [Documentation::PodSpelling] stop_words = PPI regex subclasses [-Documentation::RequirePodLinksIncludeText] [Documentation::RequirePodSections] source = module_starter_pbp_0_0_3 language = en_US [InputOutput::RequireCheckedSyscalls] functions = open close # Tags are good enough for me. [-Miscellanea::RequireRcsKeywords] # For some reason, this chokes on v-strings within a version constructor # and I don't have time to chase this down. [-Modules::PerlMinimumVersion] [RegularExpressions::ProhibitUnusualDelimiters] allow_all_brackets = 1 [RegularExpressions::RequireBracesForMultiline] allow_all_brackets = 1 [-Tics::ProhibitLongLines] # Magic numbers BAD. (It doesn't hurt that I wrote this policy.) [ValuesAndExpressions::ProhibitMagicNumbers] severity = 4 [Variables::ProhibitPackageVars] packages = File::Next # setup vim: set filetype=conf tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/perlcriticrc-tests000444000766000766 252612017025061 21644 0ustar00elliotelliot000000000000# Make things as strict as possible. profile-strictness = quiet severity = 1 verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n # Tags are good enough for me. [-Miscellanea::RequireRcsKeywords] # No Emacs around here. [-Editor::RequireEmacsFileVariables] # Need to write CodeLayout::RequireUTF8 [-CodeLayout::RequireASCII] # Perl::Tidy wouldn't know a properly formatted conditional expression # if one stomped all over Perl::Tidy.pm. (Not to say that P::T isn't # useful.) [-CodeLayout::RequireTidyCode] # Don't require POD for tests. [-Documentation::RequirePodSections] [InputOutput::RequireCheckedSyscalls] functions = open close [-Modules::RequireVersionVar] [RegularExpressions::ProhibitUnusualDelimiters] allow_all_brackets = 1 [RegularExpressions::RequireBracesForMultiline] allow_all_brackets = 1 # Magic numbers BAD. (It doesn't hurt that I wrote this policy.) [ValuesAndExpressions::ProhibitMagicNumbers] severity = 4 # For some reason, this chokes on v-strings within a version constructor # and I don't have time to chase this down. [-Modules::PerlMinimumVersion] [-ErrorHandling::RequireUseOfExceptions] [-Tics::ProhibitLongLines] # setup vim: set filetype=conf tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/pod_coverage.t000444000766000766 67512017025061 20701 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; use Test::More; use Test::Pod::Coverage; # The also_private usage is required due to using the Fatal module. all_pod_coverage_ok( { also_private => [ qw{ close read write } ] } ); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/pod_syntax.t000444000766000766 47412017025061 20431 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.008003; use utf8; use strict; use warnings; use Test::More; use Test::Pod; all_pod_files_ok(); # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : Module-Used-v1.3.0/xt/author/README000444000766000766 56012017025061 16730 0ustar00elliotelliot000000000000This directory contains tests that should only be run on a developer's machine because they aren't relevant during installation or that they are likely to fail anywhere other than the developer's machine. For example, using Test::Perl::Critic can produce errors when the locally installed version of Perl::Critic is different than the one on the developer's machine.