r34348 - in /branches/upstream/libmodule-extract-use-perl: ./ current/ current/corpus/ current/examples/ current/lib/ current/t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Wed Apr 29 21:08:53 UTC 2009
Author: jawnsy-guest
Date: Wed Apr 29 21:08:48 2009
New Revision: 34348
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34348
Log:
[svn-inject] Installing original source of libmodule-extract-use-perl
Added:
branches/upstream/libmodule-extract-use-perl/
branches/upstream/libmodule-extract-use-perl/current/
branches/upstream/libmodule-extract-use-perl/current/Changes
branches/upstream/libmodule-extract-use-perl/current/LICENSE
branches/upstream/libmodule-extract-use-perl/current/MANIFEST
branches/upstream/libmodule-extract-use-perl/current/META.yml
branches/upstream/libmodule-extract-use-perl/current/Makefile.PL
branches/upstream/libmodule-extract-use-perl/current/README
branches/upstream/libmodule-extract-use-perl/current/corpus/
branches/upstream/libmodule-extract-use-perl/current/corpus/Repeated.pm
branches/upstream/libmodule-extract-use-perl/current/examples/
branches/upstream/libmodule-extract-use-perl/current/examples/placeholder.pl
branches/upstream/libmodule-extract-use-perl/current/lib/
branches/upstream/libmodule-extract-use-perl/current/lib/Use.pm
branches/upstream/libmodule-extract-use-perl/current/t/
branches/upstream/libmodule-extract-use-perl/current/t/get_modules.t
branches/upstream/libmodule-extract-use-perl/current/t/load.t
branches/upstream/libmodule-extract-use-perl/current/t/pod.t
branches/upstream/libmodule-extract-use-perl/current/t/pod_coverage.t
branches/upstream/libmodule-extract-use-perl/current/t/test_manifest
Added: branches/upstream/libmodule-extract-use-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/Changes?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/Changes (added)
+++ branches/upstream/libmodule-extract-use-perl/current/Changes Wed Apr 29 21:08:48 2009
@@ -1,0 +1,17 @@
+# Changes for Module::Extract::Use
+
+0.13 - Wed Oct 29 14:15:51 2008
+ * Only return unique elements, so remove the duplicates
+ from the return list
+
+0.12 - Wed Oct 29 02:40:08 2008
+ * No more carping. Check the value of $object->error after a call
+ to see if anything bad happened.
+
+0.11 - Tue Oct 28 17:25:54 2008
+ * Bump to a release version
+
+0.10_01 - Fri Aug 15 16:09:15 2008
+ * First release of a module to pull out the package names
+
+
Added: branches/upstream/libmodule-extract-use-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/LICENSE?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/LICENSE (added)
+++ branches/upstream/libmodule-extract-use-perl/current/LICENSE Wed Apr 29 21:08:48 2009
@@ -1,0 +1,1 @@
+You can use Module::Extract::Use under the same terms as Perl itself.
Added: branches/upstream/libmodule-extract-use-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/MANIFEST?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/MANIFEST (added)
+++ branches/upstream/libmodule-extract-use-perl/current/MANIFEST Wed Apr 29 21:08:48 2009
@@ -1,0 +1,14 @@
+Changes
+corpus/Repeated.pm
+examples/placeholder.pl
+lib/Use.pm
+LICENSE
+Makefile.PL
+MANIFEST This list of files
+README
+t/get_modules.t
+t/load.t
+t/pod.t
+t/pod_coverage.t
+t/test_manifest
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libmodule-extract-use-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/META.yml?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/META.yml (added)
+++ branches/upstream/libmodule-extract-use-perl/current/META.yml Wed Apr 29 21:08:48 2009
@@ -1,0 +1,22 @@
+--- #YAML:1.0
+name: Module-Extract-Use
+version: 0.13
+abstract: Extract the modules that a modules uses
+author:
+ - brian d foy <bdfoy at cpan.org>
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ PPI: 0
+ Test::More: 0
+ Test::Output: 0
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.48
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Added: branches/upstream/libmodule-extract-use-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/Makefile.PL?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/Makefile.PL (added)
+++ branches/upstream/libmodule-extract-use-perl/current/Makefile.PL Wed Apr 29 21:08:48 2009
@@ -1,0 +1,31 @@
+# $Id: Makefile.PL,v 1.4 2004/07/04 17:04:17 comdog Exp $
+use ExtUtils::MakeMaker;
+
+require 5.006;
+
+eval "use Test::Manifest 1.14";
+
+WriteMakefile(
+ 'NAME' => 'Module::Extract::Use',
+ 'ABSTRACT' => 'Extract the modules that a modules uses',
+ 'VERSION_FROM' => 'lib/Use.pm',
+ 'LICENSE' => 'perl',
+ 'AUTHOR' => 'brian d foy <bdfoy at cpan.org>',
+
+ 'PREREQ_PM' => {
+ 'PPI' => '0',
+ 'Test::More' => '0',
+ 'Test::Output' => '0',
+ },
+
+ 'PM' => {
+ 'lib/Use.pm' => '$(INST_LIBDIR)/Use.pm',
+ },
+
+ 'MAN3PODS' => {
+ 'lib/Use.pm' => '$(INST_MAN3DIR)/Module::Extract::Use.3',
+ },
+
+ clean => { FILES => q|Module-Extract-Use-*| },
+
+ );
Added: branches/upstream/libmodule-extract-use-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/README?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/README (added)
+++ branches/upstream/libmodule-extract-use-perl/current/README Wed Apr 29 21:08:48 2009
@@ -1,0 +1,27 @@
+$Id: README,v 1.1 2004/09/08 00:25:41 comdog Exp $
+
+You can install this using in the usual Perl fashion
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+The documentation is in the module file. Once you install
+the file, you can read it with perldoc.
+
+ perldoc Module::Extract::Use
+
+If you want to read it before you install it, you can use
+perldoc directly on the module file.
+
+ perldoc lib/Use.pm
+
+This module is also in CVS on SourceForge
+
+ http://sourceforge.net/projects/brian-d-foy/
+
+
+Enjoy,
+
+brian d foy, bdfoy at cpan.org
Added: branches/upstream/libmodule-extract-use-perl/current/corpus/Repeated.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/corpus/Repeated.pm?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/corpus/Repeated.pm (added)
+++ branches/upstream/libmodule-extract-use-perl/current/corpus/Repeated.pm Wed Apr 29 21:08:48 2009
@@ -1,0 +1,23 @@
+package Local::Repeated;
+
+use strict;
+use warnings;
+
+no warnings;
+
+use warnings;
+use strict;
+
+use constant;
+
+package Foo;
+use warnings;
+
+{
+no strict;
+}
+
+use warnings;
+
+
+1;
Added: branches/upstream/libmodule-extract-use-perl/current/examples/placeholder.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/examples/placeholder.pl?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/examples/placeholder.pl (added)
+++ branches/upstream/libmodule-extract-use-perl/current/examples/placeholder.pl Wed Apr 29 21:08:48 2009
@@ -1,0 +1,3 @@
+#!/usr/bin/perl
+
+# See the module synopsis until I can create some interesting examples
Added: branches/upstream/libmodule-extract-use-perl/current/lib/Use.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/lib/Use.pm?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/lib/Use.pm (added)
+++ branches/upstream/libmodule-extract-use-perl/current/lib/Use.pm Wed Apr 29 21:08:48 2009
@@ -1,0 +1,150 @@
+# $Id$
+package Module::Extract::Use;
+use strict;
+
+use warnings;
+no warnings;
+
+use subs qw();
+use vars qw($VERSION);
+
+$VERSION = '0.13';
+
+=head1 NAME
+
+Module::Extract::Use - Pull out the modules a module uses
+
+=head1 SYNOPSIS
+
+ use Module::Extract::Use;
+
+ my $extor = Module::Extract::Use->new;
+
+ my @modules = $extor->get_modules( $file );
+ if( $extor->error ) { ... }
+
+
+=head1 DESCRIPTION
+
+Extract the names of the modules used in a file using a static analysis.
+Since this module does not run code, it cannot find dynamic uses of
+modules, such as C<eval "require $class">.
+
+=cut
+
+=over 4
+
+=item new
+
+Makes an object. The object doesn't do anything just yet, but you
+need it to call the methods.
+
+=cut
+
+sub new
+ {
+ my $class = shift;
+
+ my $self = bless {}, $class;
+
+ $self->init;
+
+ $self;
+ }
+
+=item init
+
+Set up the object. You shouldn't need to call this yourself.
+
+=cut
+
+sub init
+ {
+ $_[0]->_clear_error;
+ }
+
+=item get_modules( FILE )
+
+Returns a list of namespaces explicity use-d in FILE. Returns undef if the
+file does not exist or if it can't parse the file.
+
+Each used namespace is only in the list even if it is used multiple times
+in the file. The order of the list does not correspond to anything so don't
+use the order to infer anything.
+
+=cut
+
+sub get_modules {
+ my( $self, $file ) = @_;
+
+ $_[0]->_clear_error;
+
+ unless( -e $file )
+ {
+ $self->_set_error( ref( $self ) . ": File [$file] does not exist!" );
+ return;
+ }
+
+ require PPI;
+
+ my $Document = eval { PPI::Document->new( $file ) };
+ unless( $Document )
+ {
+ $self->_set_error( ref( $self ) . ": Could not parse file [$file]" );
+ return;
+ }
+
+ my $modules = $Document->find(
+ sub {
+ $_[1]->isa( 'PPI::Statement::Include' ) && $_[1]->type eq 'use'
+ }
+ );
+
+ my %Seen;
+ my @modules = grep { ! $Seen{$_}++ } eval { map { $_->module } @$modules };
+
+ @modules;
+ }
+
+=item error
+
+Return the error from the last call to C<get_modules>.
+
+=cut
+
+sub _set_error { $_[0]->{error} = $_[1]; }
+
+sub _clear_error { $_[0]->{error} = '' }
+
+sub error { $_[0]->{error} }
+
+=back
+
+=head1 TO DO
+
+* Make it recursive, so it scans the source for any module that
+it finds.
+
+=head1 SEE ALSO
+
+L<Module::ScanDeps>
+
+=head1 SOURCE AVAILABILITY
+
+The source code is in Github:
+
+ git://github.com/briandfoy/module--extract--use.git
+
+=head1 AUTHOR
+
+brian d foy, C<< <bdfoy at cpan.org> >>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2008, brian d foy, All Rights Reserved.
+
+You may redistribute this under the same terms as Perl itself.
+
+=cut
+
+1;
Added: branches/upstream/libmodule-extract-use-perl/current/t/get_modules.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/t/get_modules.t?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/t/get_modules.t (added)
+++ branches/upstream/libmodule-extract-use-perl/current/t/get_modules.t Wed Apr 29 21:08:48 2009
@@ -1,0 +1,68 @@
+#!/usr/bin/perl
+use strict;
+
+use Test::More 'no_plan';
+use File::Basename;
+use File::Spec::Functions qw(catfile);
+
+my $class = "Module::Extract::Use";
+
+use_ok( $class );
+
+my $extor = $class->new;
+isa_ok( $extor, $class );
+can_ok( $extor, 'get_modules' );
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Try it with a file that doesn't exist, should fail
+{
+my $not_there = 'not_there';
+ok( ! -e $not_there, "Missing file is actually missing" );
+
+$extor->get_modules( $not_there );
+like( $extor->error, qr/does not exist/, "Missing file give right error" );
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Try it with a file PPI can't parse, should fail
+{
+open my($fh), ">", "empty";
+close $fh;
+END{ unlink 'empty' }
+
+my $unparseable = 'empty';
+ok( -e $unparseable, "Unparseable file is there" );
+
+$extor->get_modules( $unparseable );
+like( $extor->error, qr/not parse/, "Unparseable file gives right error" );
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Try it with this file
+{
+my $test = $0;
+ok( -e $test, "Test file is there" );
+
+my %modules = map { $_, 1 } $extor->get_modules( $test );
+
+foreach my $module ( qw(Test::More File::Basename) )
+ {
+ ok( exists $modules{$module}, "Found $module" );
+ ok( ! $extor->error, "No error for parseable file [$module]")
+ }
+
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Try it with a file that has repeated use lines
+# I should only get unique names
+{
+my $file = catfile( qw(corpus Repeated.pm) );
+ok( -e $file, "Test file [$file] is there" );
+
+my @modules = sort { $a cmp $b } $extor->get_modules( $file );
+is( scalar @modules, 3 );
+
+is_deeply( \@modules, [qw(constant strict warnings)] );
+
+}
Added: branches/upstream/libmodule-extract-use-perl/current/t/load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/t/load.t?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/t/load.t (added)
+++ branches/upstream/libmodule-extract-use-perl/current/t/load.t Wed Apr 29 21:08:48 2009
@@ -1,0 +1,11 @@
+# $Id: load.t,v 1.2 2004/09/08 00:25:42 comdog Exp $
+BEGIN {
+ @classes = qw(Module::Extract::Use);
+ }
+
+use Test::More tests => scalar @classes;
+
+foreach my $class ( @classes )
+ {
+ print "Bail out! $class did not compile\n" unless use_ok( $class );
+ }
Added: branches/upstream/libmodule-extract-use-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/t/pod.t?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/t/pod.t (added)
+++ branches/upstream/libmodule-extract-use-perl/current/t/pod.t Wed Apr 29 21:08:48 2009
@@ -1,0 +1,5 @@
+# $Id$
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
Added: branches/upstream/libmodule-extract-use-perl/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/t/pod_coverage.t?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/t/pod_coverage.t (added)
+++ branches/upstream/libmodule-extract-use-perl/current/t/pod_coverage.t Wed Apr 29 21:08:48 2009
@@ -1,0 +1,6 @@
+# $Id$
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
+
Added: branches/upstream/libmodule-extract-use-perl/current/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-extract-use-perl/current/t/test_manifest?rev=34348&op=file
==============================================================================
--- branches/upstream/libmodule-extract-use-perl/current/t/test_manifest (added)
+++ branches/upstream/libmodule-extract-use-perl/current/t/test_manifest Wed Apr 29 21:08:48 2009
@@ -1,0 +1,5 @@
+# $Id$
+load.t
+pod.t
+pod_coverage.t
+get_modules.t
More information about the Pkg-perl-cvs-commits
mailing list