r71932 - in /trunk/libmodule-extract-use-perl: Changes META.yml README debian/changelog debian/control debian/copyright debian/source/ debian/source/format lib/Use.pm t/get_modules.t t/test_manifest

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Thu Mar 24 00:40:45 UTC 2011


Author: jawnsy-guest
Date: Thu Mar 24 00:39:53 2011
New Revision: 71932

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=71932
Log:
looks good, dch -r

Added:
    trunk/libmodule-extract-use-perl/debian/source/
    trunk/libmodule-extract-use-perl/debian/source/format
Modified:
    trunk/libmodule-extract-use-perl/Changes
    trunk/libmodule-extract-use-perl/META.yml
    trunk/libmodule-extract-use-perl/README
    trunk/libmodule-extract-use-perl/debian/changelog
    trunk/libmodule-extract-use-perl/debian/control
    trunk/libmodule-extract-use-perl/debian/copyright
    trunk/libmodule-extract-use-perl/lib/Use.pm
    trunk/libmodule-extract-use-perl/t/get_modules.t
    trunk/libmodule-extract-use-perl/t/test_manifest

Modified: trunk/libmodule-extract-use-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/Changes?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/Changes (original)
+++ trunk/libmodule-extract-use-perl/Changes Thu Mar 24 00:39:53 2011
@@ -1,8 +1,8 @@
 # Changes for Module::Extract::Use
 
-0.17 - Sat Aug  8 04:18:30 2009
-	* Removed failing test checking for empty files. PPI now 
-	handles those. :(
+0.18 - Mon Mar 21 22:15:34 2011
+	Implemented get_modules_with_details to extract the 
+	version and import lists for a use().
 
 0.16 - Wed Jun 10 00:21:12 2009
 	* Small distro cleanups and new META_MERGE hotness. No need

Modified: trunk/libmodule-extract-use-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/META.yml?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/META.yml (original)
+++ trunk/libmodule-extract-use-perl/META.yml Thu Mar 24 00:39:53 2011
@@ -1,12 +1,14 @@
 --- #YAML:1.0
 name:               Module-Extract-Use
-version:            0.17
+version:            0.18
 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
+build_requires:
     ExtUtils::MakeMaker:  0
 requires:
     perl:          5.006
@@ -19,7 +21,7 @@
     directory:
         - t
         - inc
-generated_by:       ExtUtils::MakeMaker version 6.48
+generated_by:       ExtUtils::MakeMaker version 6.55_02
 meta-spec:
     url:      http://module-build.sourceforge.net/META-spec-v1.4.html
     version:  1.4

Modified: trunk/libmodule-extract-use-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/README?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/README (original)
+++ trunk/libmodule-extract-use-perl/README Thu Mar 24 00:39:53 2011
@@ -17,7 +17,7 @@
 	
 This module is Github
 
-	http://github.com/briandfoy/module--extract--use/tree/master
+	http://github.com/briandfoy/module-extract-use/tree/master
 
 Enjoy, 
 

Modified: trunk/libmodule-extract-use-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/debian/changelog?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/debian/changelog (original)
+++ trunk/libmodule-extract-use-perl/debian/changelog Thu Mar 24 00:39:53 2011
@@ -1,9 +1,17 @@
-libmodule-extract-use-perl (0.17-2) UNRELEASED; urgency=low
+libmodule-extract-use-perl (0.18-1) unstable; urgency=low
 
-  * Update jawnsy's email address
-  * Update ryan52's email address
+  [ Jonathan Yu ]
+  * New upstream release
+  * Use new 3.0 (quilt) source format
+  * Bump to debhelper compat 8
+  * Standards-Version 3.9.1 (no changes)
+  * Drop unnecessary versioned dependencies
 
- -- Ryan Niebur <ryan at debian.org>  Fri, 25 Sep 2009 00:25:31 -0700
+  [ Ryan Niebur ]
+  * Email change: Jonathan Yu -> jawnsy at cpan.org
+  * Email change: Ryan Niebur -> ryan at debian.org
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Wed, 23 Mar 2011 20:58:25 -0400
 
 libmodule-extract-use-perl (0.17-1) unstable; urgency=low
 

Modified: trunk/libmodule-extract-use-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/debian/control?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/debian/control (original)
+++ trunk/libmodule-extract-use-perl/debian/control Thu Mar 24 00:39:53 2011
@@ -1,21 +1,25 @@
 Source: libmodule-extract-use-perl
 Section: perl
 Priority: optional
-Build-Depends: debhelper (>= 7)
-Build-Depends-Indep: libppi-perl (>= 1.203), libtest-output-perl (>= 0.12),
- libtest-pod-perl (>= 1.26), libtest-pod-coverage-perl (>= 1.08),
- libtest-manifest-perl (>= 1.21), perl
+Build-Depends: debhelper (>= 8)
+Build-Depends-Indep: perl,
+ libppi-perl (>= 1.203),
+ libtest-output-perl,
+ libtest-pod-perl (>= 1.26),
+ libtest-pod-coverage-perl,
+ libtest-manifest-perl (>= 1.21)
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
 Uploaders: Jonathan Yu <jawnsy at cpan.org>, Ryan Niebur <ryan at debian.org>,
  gregor herrmann <gregoa at debian.org>
-Standards-Version: 3.8.3
+Standards-Version: 3.9.1
 Homepage: http://search.cpan.org/dist/Module-Extract-Use/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libmodule-extract-use-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libmodule-extract-use-perl/
 
 Package: libmodule-extract-use-perl
 Architecture: all
-Depends: ${misc:Depends}, ${perl:Depends}, libppi-perl (>= 1.203)
+Depends: ${misc:Depends}, ${perl:Depends},
+ libppi-perl (>= 1.203)
 Description: Perl module to extract which modules some code uses
  Module::Extract::Use extracts the names of the modules used in a file using a
  static analysis. It uses PPI (Perl Parsing Interface) to tokenize and extract

Modified: trunk/libmodule-extract-use-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/debian/copyright?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/debian/copyright (original)
+++ trunk/libmodule-extract-use-perl/debian/copyright Thu Mar 24 00:39:53 2011
@@ -1,32 +1,34 @@
-Format-Specification:
-    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: brian d foy <bdfoy at cpan.org>
-Upstream-Source: http://search.cpan.org/dist/Module-Extract-Use/
-Upstream-Name: Module-Extract-Use
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Maintainer: brian d foy <bdfoy at cpan.org>
+Source: http://search.cpan.org/dist/Module-Extract-Use/
+Name: Module-Extract-Use
 
 Files: *
-Copyright: 2008-2009, brian d foy <bdfoy at cpan.org>
-License-Alias: Perl
-License: Artistic | GPL-1+
-
-Files: debian/*
-Copyright: 2009, Jonathan Yu <jawnsy at cpan.org>
-License: Artistic | GPL-1+
+Copyright: 2008-2011, brian d foy <bdfoy at cpan.org>
+License: Artistic or GPL-1+
 
 Files: examples/extract_modules
 Copyright: 2009, Jonathan Yu <jawnsy at cpan.org>
-License: Artistic | GPL-1+
+License: Artistic or GPL-1+
+
+Files: debian/*
+Copyright: 2009-2011, Jonathan Yu <jawnsy at cpan.org>
+ 2009, Ryan Niebur <ryanryan52 at gmail.com>
+ 2009, gregor herrmann <gregoa at debian.org>
+License: Artistic or GPL-1+
 
 License: Artistic
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the Artistic License, which comes with Perl.
-    On Debian GNU/Linux systems, the complete text of the Artistic License
-    can be found in `/usr/share/common-licenses/Artistic'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian systems, the complete text of the Artistic License can be
+ found in `/usr/share/common-licenses/Artistic'.
 
 License: GPL-1+
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-    On Debian GNU/Linux systems, the complete text of the GNU General
-    Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian systems, the complete text of version 1 of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL-1'.

Added: trunk/libmodule-extract-use-perl/debian/source/format
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/debian/source/format?rev=71932&op=file
==============================================================================
--- trunk/libmodule-extract-use-perl/debian/source/format (added)
+++ trunk/libmodule-extract-use-perl/debian/source/format Thu Mar 24 00:39:53 2011
@@ -1,0 +1,1 @@
+3.0 (quilt)

Modified: trunk/libmodule-extract-use-perl/lib/Use.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/lib/Use.pm?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/lib/Use.pm (original)
+++ trunk/libmodule-extract-use-perl/lib/Use.pm Thu Mar 24 00:39:53 2011
@@ -7,7 +7,7 @@
 use subs qw();
 use vars qw($VERSION);
 
-$VERSION = '0.17';
+$VERSION = '0.18';
 
 =head1 NAME
 
@@ -18,16 +18,22 @@
 	use Module::Extract::Use;
 
 	my $extor = Module::Extract::Use->new;
-	
+
 	my @modules = $extor->get_modules( $file );
 	if( $extor->error ) { ... }
-	
-	
+
+	my @details = $extor->get_modules_with_details( $file );
+	foreach my $detail ( @details ) {
+		printf "%s %s imports %s\n",
+			$detail->module, $detail->version,
+			join ' ', @{ $detail->imports }
+		}
+
 =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">.
+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
 
@@ -35,19 +41,18 @@
 
 =item new
 
-Makes an object. The object doesn't do anything just yet, but you
-need it to call the methods.
-
-=cut
-
-sub 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;
 	}
 
@@ -57,8 +62,7 @@
 
 =cut
 
-sub init 
-	{ 
+sub init {
 	$_[0]->_clear_error;
 	}
 
@@ -76,10 +80,46 @@
 sub get_modules {
 	my( $self, $file ) = @_;
 
-	$_[0]->_clear_error;
-
-	unless( -e $file )
-		{
+	$self->_clear_error;
+
+	my $details = $self->get_modules_with_details( $file );
+	return unless defined $details;
+
+	my @modules =
+		map { $_->{module} }
+		@$details;
+	}
+
+=item get_modules_with_details( FILE )
+
+Returns a list of hash references, one reference for each namespace
+explicitly use-d in FILE. Each reference has keys for:
+
+	namespace - the namespace, always defined
+	version   - defined if a module version was specified
+	imports   - an array reference to the import list
+
+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_with_details {
+	my( $self, $file ) = @_;
+
+	$self->_clear_error;
+
+	my $modules = $self->_get_ppi_for_file( $file );
+	return unless defined $modules;
+
+	$modules;
+	}
+
+sub _get_ppi_for_file {
+	my( $self, $file ) = @_;
+
+	unless( -e $file ) {
 		$self->_set_error( ref( $self ) . ": File [$file] does not exist!" );
 		return;
 		}
@@ -87,23 +127,52 @@
 	require PPI;
 
 	my $Document = eval { PPI::Document->new( $file ) };
-	unless( $Document )
-		{
+	unless( $Document ) {
 		$self->_set_error( ref( $self ) . ": Could not parse file [$file]" );
 		return;
 		}
-		
-	my $modules = $Document->find( 
+
+	my $modules = $Document->find(
 		sub {
-			$_[1]->isa( 'PPI::Statement::Include' )  && 
+			$_[1]->isa( 'PPI::Statement::Include' )  &&
 				( $_[1]->type eq 'use' || $_[1]->type eq 'require' )
 			}
 		);
-	
+
 	my %Seen;
-	my @modules = grep { ! $Seen{$_}++ } eval { map { $_->module } @$modules };
-
-	@modules;
+	my @modules =
+		grep { ! $Seen{ $_->{module} }++ && $_->{module} }
+		map  {
+			my $hash = {
+				pragma  => $_->pragma,
+				module  => $_->module,
+				imports => [ $self->_list_contents( $_->arguments ) ],
+				version => eval{ $_->module_version->literal || ( undef ) },
+				};
+			} @$modules;
+
+	return \@modules;
+	}
+
+sub _list_contents {
+	my( $self, $node ) = @_;
+
+	eval {
+		if( ! defined $node ) {
+			return;
+			}
+		elsif( $node->isa( 'PPI::Token::QuoteLike::Words' ) ) {
+			( $node->literal )
+			}
+		elsif( $node->isa( 'PPI::Structure::List' ) ) {
+			my $nodes = $node->find( sub{ $_[1]->isa( 'PPI::Token::Quote' ) } );
+			map { $_->string } @$nodes;
+			}
+		elsif( $node->isa( 'PPI::Token::Quote' ) ) {
+			( $node->string );
+			}
+	};
+
 	}
 
 =item error
@@ -113,7 +182,7 @@
 =cut
 
 sub _set_error   { $_[0]->{error} = $_[1]; }
-	
+
 sub _clear_error { $_[0]->{error} = '' }
 
 sub error        { $_[0]->{error} }
@@ -122,8 +191,11 @@
 
 =head1 TO DO
 
-* Make it recursive, so it scans the source for any module that
-it finds.
+=over 4
+
+=item * Make it recursive, so it scans the source for any module that it finds.
+
+=back
 
 =head1 SEE ALSO
 
@@ -131,9 +203,7 @@
 
 =head1 SOURCE AVAILABILITY
 
-The source code is in Github:
-
-	git://github.com/briandfoy/module--extract--use.git
+The source code is in Github: git://github.com/briandfoy/module-extract-use.git
 
 =head1 AUTHOR
 
@@ -141,7 +211,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (c) 2008-2009, brian d foy, All Rights Reserved.
+Copyright (c) 2008-2011, brian d foy, All Rights Reserved.
 
 You may redistribute this under the same terms as Perl itself.
 

Modified: trunk/libmodule-extract-use-perl/t/get_modules.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/t/get_modules.t?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/t/get_modules.t (original)
+++ trunk/libmodule-extract-use-perl/t/get_modules.t Thu Mar 24 00:39:53 2011
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use strict;
 
-use Test::More tests => 13;
+use Test::More tests => 16;
 use File::Basename;
 use File::Spec::Functions qw(catfile);
 
@@ -30,11 +30,14 @@
 ok( -e $test, "Test file is there" );
 
 my %modules = map { $_, 1 } $extor->get_modules( $test );
+ok( ! $extor->error, "No error for parseable file [$test]");
 
-foreach my $module ( qw(Test::More File::Basename) )
-	{
+foreach my $module ( qw(Test::More File::Basename File::Spec::Functions strict) ) {
 	ok( exists $modules{$module}, "Found $module" );
-	ok( ! $extor->error, "No error for parseable file [$module]")
+	}
+
+foreach my $module ( qw(Foo Bar::Baz) ) {
+	ok( ! exists $modules{$module}, "Didn't find $module" );
 	}
 
 }

Modified: trunk/libmodule-extract-use-perl/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-extract-use-perl/t/test_manifest?rev=71932&op=diff
==============================================================================
--- trunk/libmodule-extract-use-perl/t/test_manifest (original)
+++ trunk/libmodule-extract-use-perl/t/test_manifest Thu Mar 24 00:39:53 2011
@@ -2,3 +2,5 @@
 pod.t
 pod_coverage.t
 get_modules.t
+imports.t
+versions.t




More information about the Pkg-perl-cvs-commits mailing list