r52351 - in /branches/upstream/libperl-metrics-simple-perl/current: ./ bin/ lib/Perl/Metrics/ lib/Perl/Metrics/Simple/ lib/Perl/Metrics/Simple/Analysis/ t/ t/more_test_files/ t/test_files/ t/test_files/Perl/Code/Analyze/Test/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Feb 8 23:25:22 UTC 2010


Author: jawnsy-guest
Date: Mon Feb  8 23:25:16 2010
New Revision: 52351

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=52351
Log:
[svn-upgrade] Integrating new upstream version, libperl-metrics-simple-perl (0.14)

Modified:
    branches/upstream/libperl-metrics-simple-perl/current/Build.PL
    branches/upstream/libperl-metrics-simple-perl/current/Changes
    branches/upstream/libperl-metrics-simple-perl/current/EXAMPLES
    branches/upstream/libperl-metrics-simple-perl/current/INSTALL
    branches/upstream/libperl-metrics-simple-perl/current/META.yml
    branches/upstream/libperl-metrics-simple-perl/current/Makefile.PL
    branches/upstream/libperl-metrics-simple-perl/current/bin/countperl
    branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple.pm
    branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis.pm
    branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis/File.pm
    branches/upstream/libperl-metrics-simple-perl/current/t/001_load.t
    branches/upstream/libperl-metrics-simple-perl/current/t/0020_find_files.t
    branches/upstream/libperl-metrics-simple-perl/current/t/0030_analyze.t
    branches/upstream/libperl-metrics-simple-perl/current/t/0901_pod.t
    branches/upstream/libperl-metrics-simple-perl/current/t/0902_pod_coverage.t
    branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/end_token.pl
    branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/main_subs_and_pod.pl
    branches/upstream/libperl-metrics-simple-perl/current/t/test_files/Perl/Code/Analyze/Test/Module.pm
    branches/upstream/libperl-metrics-simple-perl/current/t/test_files/no_packages_nor_subs
    branches/upstream/libperl-metrics-simple-perl/current/t/test_files/not_a_perl_file
    branches/upstream/libperl-metrics-simple-perl/current/t/test_files/package_no_subs.pl
    branches/upstream/libperl-metrics-simple-perl/current/t/test_files/subs_no_package.pl

Modified: branches/upstream/libperl-metrics-simple-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/Build.PL?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/Build.PL (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/Build.PL Mon Feb  8 23:25:16 2010
@@ -1,7 +1,7 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/Build.PL,v 1.15 2007/12/30 21:37:31 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/Build.PL,v 1.15 2007/12/30 21:37:31 matisse Exp $
 # $Revision: 1.15 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/Build.PL,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/Build.PL,v $
 # $Date: 2007/12/30 21:37:31 $
 ###############################################################################
 use strict;

Modified: branches/upstream/libperl-metrics-simple-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/Changes?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/Changes (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/Changes Mon Feb  8 23:25:16 2010
@@ -1,4 +1,10 @@
 Revision history for Perl module Perl::Metrics::Simple
+
+0.14
+  Allow using a ref-to-SCALAR of file contents instead of a file path.
+  https://rt.cpan.org/Ticket/Display.html?id=54293
+  Thanks to Alexandr Ciornii for requesting this and supplying patches.
+  Also changes all VERSION numbers to match: 0.14
 
 0.13 Mon May  4 08:25:51 PDT 2009
   Fixed bug in report output in countperl.

Modified: branches/upstream/libperl-metrics-simple-perl/current/EXAMPLES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/EXAMPLES?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/EXAMPLES (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/EXAMPLES Mon Feb  8 23:25:16 2010
@@ -1,4 +1,4 @@
-$Header: /usr/local/CVS/Perl-Metrics-Simple/EXAMPLES,v 1.1 2007/05/20 16:02:27 matisse Exp $
+$Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/EXAMPLES,v 1.1 2007/05/20 16:02:27 matisse Exp $
 
 Examples of using  Perl::Metrics::Simple
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/INSTALL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/INSTALL?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/INSTALL (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/INSTALL Mon Feb  8 23:25:16 2010
@@ -1,4 +1,4 @@
-$Header: /usr/local/CVS/Perl-Metrics-Simple/INSTALL,v 1.2 2008/08/10 16:31:29 matisse Exp $
+$Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/INSTALL,v 1.2 2008/08/10 16:31:29 matisse Exp $
 
 Installing  Perl::Metrics::Simple
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/META.yml?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/META.yml (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/META.yml Mon Feb  8 23:25:16 2010
@@ -1,11 +1,18 @@
 ---
 name: Perl-Metrics-Simple
-version: 0.13
+version: 0.14
 author: []
 abstract: 'Count packages, subs, lines, etc. of many files.'
 license: perl
 resources:
-  license: ~
+  license: http://dev.perl.org/licenses/
+build_requires:
+  Data::Dumper: 0
+  File::Spec: 0
+  Module::Build: 0.2612
+  Readonly: 1.03
+  Test::Pod: 1
+  Test::Pod::Coverage: 1.04
 requires:
   Carp: 0
   Data::Dumper: 0
@@ -18,26 +25,21 @@
   Statistics::Basic::Mean: 0
   Statistics::Basic::Median: 0
   Statistics::Basic::StdDev: 0
-build_requires:
-  Data::Dumper: 0
-  File::Spec: 0
-  Module::Build: 0.2612
-  Readonly: 1.03
-  Test::Pod: 1
-  Test::Pod::Coverage: 1.04
 recommends:
   Readonly::XS: 1.02
+configure_requires:
+  Module::Build: 0.35
 provides:
   Perl::Metrics::Simple:
     file: lib/Perl/Metrics/Simple.pm
-    version: 0.13
+    version: 0.14
   Perl::Metrics::Simple::Analysis:
     file: lib/Perl/Metrics/Simple/Analysis.pm
-    version: 0.11
+    version: 0.14
   Perl::Metrics::Simple::Analysis::File:
     file: lib/Perl/Metrics/Simple/Analysis/File.pm
-    version: 0.11
-generated_by: Module::Build version 0.32
+    version: 0.14
+generated_by: Module::Build version 0.35
 meta-spec:
-  url: http://module-build.sourceforge.net/META-spec-v1.2.html
-  version: 1.2
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4

Modified: branches/upstream/libperl-metrics-simple-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/Makefile.PL?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/Makefile.PL (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/Makefile.PL Mon Feb  8 23:25:16 2010
@@ -1,6 +1,6 @@
 # $Revision: 1.3 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/Makefile.PL,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/Makefile.PL,v $
 # $Date: 2007/12/30 21:37:30 $
 #
 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab :

Modified: branches/upstream/libperl-metrics-simple-perl/current/bin/countperl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/bin/countperl?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/bin/countperl (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/bin/countperl Mon Feb  8 23:25:16 2010
@@ -1,10 +1,10 @@
 #!/usr/bin/perl
 
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/bin/countperl,v 1.9 2009/04/27 15:35:37 matisse Exp $
-# $Revision: 1.9 $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/bin/countperl,v 1.10 2010/02/07 20:59:07 matisse Exp $
+# $Revision: 1.10 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/bin/countperl,v $
-# $Date: 2009/04/27 15:35:37 $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/bin/countperl,v $
+# $Date: 2010/02/07 20:59:07 $
 ###############################################################################
 
 package main;
@@ -14,7 +14,7 @@
 use Perl::Metrics::Simple qw(0.13);
 use Pod::Usage;
 
-our $VERSION = 0.13;
+our $VERSION = 0.14;
 
 if ( !@ARGV ) {
     pod2usage( -verbose => 1 );

Modified: branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple.pm?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple.pm (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple.pm Mon Feb  8 23:25:16 2010
@@ -1,11 +1,12 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple.pm,v 1.20 2009/05/02 16:20:58 matisse Exp $
-# $Revision: 1.20 $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple.pm,v 1.21 2010/02/07 20:59:07 matisse Exp $
+# $Revision: 1.21 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple.pm,v $
-# $Date: 2009/05/02 16:20:58 $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple.pm,v $
+# $Date: 2010/02/07 20:59:07 $
 ###############################################################################
 
 package Perl::Metrics::Simple;
+use 5.006;
 use strict;
 use warnings;
 
@@ -20,12 +21,12 @@
 use Perl::Metrics::Simple::Analysis::File;
 use Readonly;
 
-our $VERSION = 0.13;
-
-Readonly::Scalar our $PERL_FILE_SUFFIXES => qr{ \. (:? pl | pm | t ) }xmi;
-Readonly::Scalar our $SKIP_LIST_REGEX    => qr{ \.svn | _darcs | CVS }xmi;
-Readonly::Scalar my $PERL_SHEBANG_REGEX  => qr/ \A [#] ! .* perl /xm;
-Readonly::Scalar my $DOT_FILE_REGEX      => qr/ \A [.] /xm;
+our $VERSION = '0.14';
+
+Readonly::Scalar our $PERL_FILE_SUFFIXES => qr{ \. (:? pl | pm | t ) }sxmi;
+Readonly::Scalar our $SKIP_LIST_REGEX    => qr{ \.svn | \. git | _darcs | CVS }sxmi;
+Readonly::Scalar my $PERL_SHEBANG_REGEX  => qr/ \A [#] ! .* perl /sxm;
+Readonly::Scalar my $DOT_FILE_REGEX      => qr/ \A [.] /sxm;
 
 sub new {
     my ($class) = @_;
@@ -37,7 +38,9 @@
 sub analyze_files {
     my ( $self, @dirs_and_files ) = @_;
     my @results = ();
-    foreach my $file ( @{ $self->find_files(@dirs_and_files) } ) {
+    my @objects = grep { ref $_ } @dirs_and_files;
+    @dirs_and_files = grep { not ref $_ } @dirs_and_files;
+    foreach my $file ( (scalar(@dirs_and_files)?@{ $self->find_files(@dirs_and_files) }:()), at objects ) {
         my $file_analysis =
           Perl::Metrics::Simple::Analysis::File->new( path => $file );
         push @results, $file_analysis;
@@ -71,7 +74,8 @@
 
     File::Find::find( { wanted => $wanted, no_chdir => 1 }, @paths );
 
-    return sort @files;
+    my @sorted_list = sort @files;
+    return @sorted_list;
 }
 
 sub should_be_skipped {
@@ -122,8 +126,8 @@
 =head1 SYNOPSIS
 
   use Perl::Metrics::Simple;
-  my $analzyer = Perl::Metrics::Simple->new;
-  my $analysis = $analzyer->analyze_files(@ARGV);
+  my $analyzer = Perl::Metrics::Simple->new;
+  my $analysis = $analyzer->analyze_files(@paths, @refs_to_file_contents);
   $file_count    = $analysis->file_count;
   $package_count = $analysis->package_count;
   $sub_count     = $analysis->sub_count;
@@ -163,12 +167,16 @@
 
 =head1 OBJECT METHODS
 
-=head2 analyze_files( @files_and_or_dirs )
-
-Takes an array of files and or directory paths and returns
-a L<Perl::Metrics::Simple::Analysis> object.
-
-=head2 find_files
+=head2 analyze_files( @paths, @refs_to_file_contents )
+
+Takes an array of files and or directory paths, and/or
+SCALAR refs to file contents and returns
+an L<Perl::Metrics::Simple::Analysis> object.
+
+=head2 find_files( @directories_and_files )
+
+Uses I<list_perl_files> to find all the readable Perl files
+and returns a reference to a (possibly empty) list of paths.
 
 =head2 list_perl_files
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis.pm?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis.pm (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis.pm Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis.pm,v 1.15 2009/05/02 16:21:00 matisse Exp $
-# $Revision: 1.15 $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis.pm,v 1.16 2010/02/07 20:59:07 matisse Exp $
+# $Revision: 1.16 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis.pm,v $
-# $Date: 2009/05/02 16:21:00 $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis.pm,v $
+# $Date: 2010/02/07 20:59:07 $
 ###############################################################################
 
 package Perl::Metrics::Simple::Analysis;
@@ -16,7 +16,7 @@
 use Statistics::Basic::Mean;
 use Statistics::Basic::Median;
 
-our $VERSION = '0.11';
+our $VERSION = '0.14';
 
 my %AnalysisData = ();
 my %Files        = ();

Modified: branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis/File.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis/File.pm?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis/File.pm (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/lib/Perl/Metrics/Simple/Analysis/File.pm Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis/File.pm,v 1.19 2009/05/02 16:21:00 matisse Exp $
-# $Revision: 1.19 $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis/File.pm,v 1.20 2010/02/07 20:59:07 matisse Exp $
+# $Revision: 1.20 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis/File.pm,v $
-# $Date: 2009/05/02 16:21:00 $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/lib/Perl/Metrics/Simple/Analysis/File.pm,v $
+# $Date: 2010/02/07 20:59:07 $
 ###############################################################################
 
 package Perl::Metrics::Simple::Analysis::File;
@@ -17,10 +17,10 @@
 use PPI::Document;
 use Readonly;
 
-our $VERSION = '0.11';
+our $VERSION = '0.14';
 
 Readonly::Scalar my $ALL_NEWLINES_REGEX =>
-    qr/ ( \Q$INPUT_RECORD_SEPARATOR\E ) /xm;
+    qr/ ( \Q$INPUT_RECORD_SEPARATOR\E ) /sxm;
 Readonly::Array our @LOGIC_OPERATORS =>
     qw( ! && || ||= &&= or and xor not ? <<= >>= );
 Readonly::Hash our %LOGIC_OPERATORS => hashify(@LOGIC_OPERATORS);
@@ -28,6 +28,7 @@
 Readonly::Array our @LOGIC_KEYWORDS =>
     qw( for foreach goto if else elsif last next unless until while );
 Readonly::Hash our %LOGIC_KEYWORDS => hashify(@LOGIC_KEYWORDS);
+Readonly::Scalar my $LAST_CHARACTER => -1;
 
 # Private instance variables:
 my %Path       = ();
@@ -50,10 +51,20 @@
 
     my $path = $self->path;
 
-    if ( !-r $path ) {
-        Carp::confess "Path '$path' is missing or not readable!";
-    }
-    my $document = _make_pruned_document($path);
+    my $document;
+    if (ref $path) {
+        if (ref $path eq 'SCALAR') {
+            $document = PPI::Document->new($path);
+        } else {
+            $document = $path;
+        }
+    } else {
+        if ( !-r $path ) {
+            Carp::confess "Path '$path' is missing or not readable!";
+        }
+        $document = _create_ppi_document($path);
+    }
+    $document = _make_pruned_document($document);
 
     if ( !defined $document ) {
         cluck "Could not make a PPI document from '$path'";
@@ -75,7 +86,7 @@
     return $self;
 }
 
-sub _make_pruned_document {
+sub _create_ppi_document {
     my $path = shift;
     my $document;
     if ( -s $path ) {
@@ -91,6 +102,11 @@
         my $one_whitespace_character = q{ };
         $document = PPI::Document->new( \$one_whitespace_character );
     }
+    return $document;
+}
+
+sub _make_pruned_document {
+    my $document = shift;;
     $document = _prune_non_code_lines($document);
     $document->index_locations();
     $document->readonly(1);
@@ -137,21 +153,22 @@
 
 sub get_node_length {
     my ( $self, $node ) = @_;
-    eval { $node = _prune_non_code_lines($node); };
+    my $eval_result = eval { $node = _prune_non_code_lines($node); };
+    return 0 if not $eval_result;
     return 0 if ( !defined $node );
     my $string = $node->content;
     return 0 if ( !length $string );
 
     # Replace whitespace-newline with newline
-    $string =~ s/ \s+ \Q$INPUT_RECORD_SEPARATOR\E /$INPUT_RECORD_SEPARATOR/mxg;
-    $string =~ s/\Q$INPUT_RECORD_SEPARATOR\E /$INPUT_RECORD_SEPARATOR/mxg;
+    $string =~ s/ \s+ \Q$INPUT_RECORD_SEPARATOR\E /$INPUT_RECORD_SEPARATOR/smxg;
+    $string =~ s/\Q$INPUT_RECORD_SEPARATOR\E /$INPUT_RECORD_SEPARATOR/smxg;
     $string =~ s/ \A \s+ //msx;    # Remove leading whitespace
-    my @newlines = ( $string =~ /$ALL_NEWLINES_REGEX/mxg );
+    my @newlines = ( $string =~ /$ALL_NEWLINES_REGEX/smxg );
     my $line_count = scalar @newlines;
 
  # if the string is not empty and the last character is not a newline then add 1
     if ( length $string ) {
-        my $last_char = substr $string, -1, 1;
+        my $last_char = substr $string, $LAST_CHARACTER, 1;
         if ( $last_char ne "$INPUT_RECORD_SEPARATOR" ) {
             $line_count++;
         }
@@ -448,7 +465,8 @@
 
 =head2 path
 
-Path to the file.
+Either the path to the file, or a scalar ref if that was supplied
+instaed of a path.
 
 =head2 subs
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/001_load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/001_load.t?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/001_load.t (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/001_load.t Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 # -*- perl -*-
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/001_load.t,v 1.3 2006/10/03 03:53:08 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/001_load.t,v 1.3 2006/10/03 03:53:08 matisse Exp $
 # $Revision: 1.3 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/001_load.t,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/001_load.t,v $
 # $Date: 2006/10/03 03:53:08 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/0020_find_files.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/0020_find_files.t?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/0020_find_files.t (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/0020_find_files.t Mon Feb  8 23:25:16 2010
@@ -1,7 +1,7 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/0020_find_files.t,v 1.6 2008/07/19 17:36:27 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0020_find_files.t,v 1.6 2008/07/19 17:36:27 matisse Exp $
 # $Revision: 1.6 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/0020_find_files.t,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0020_find_files.t,v $
 # $Date: 2008/07/19 17:36:27 $
 ###############################################################################
 use strict;

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/0030_analyze.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/0030_analyze.t?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/0030_analyze.t (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/0030_analyze.t Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/0030_analyze.t,v 1.18 2008/07/19 17:36:27 matisse Exp $
-# $Revision: 1.18 $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0030_analyze.t,v 1.19 2010/02/07 20:59:07 matisse Exp $
+# $Revision: 1.19 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/0030_analyze.t,v $
-# $Date: 2008/07/19 17:36:27 $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0030_analyze.t,v $
+# $Date: 2010/02/07 20:59:07 $
 ###############################################################################
 
 use strict;
@@ -14,7 +14,7 @@
 use lib "$Bin/lib";
 use Perl::Metrics::Simple::TestData;
 use Readonly;
-use Test::More tests => 31;
+use Test::More tests => 37;
 
 Readonly::Scalar my $TEST_DIRECTORY => "$Bin/test_files";
 Readonly::Scalar my $EMPTY_STRING   => q{};
@@ -28,6 +28,7 @@
 
 test_new();
 test_analyze_one_file();
+test_analyze_text_from_scalar_ref();
 test_analyze_files();
 test_analysis();
 test_is_ref();
@@ -40,6 +41,14 @@
     my $test_data_object = Perl::Metrics::Simple::TestData->new(
         test_directory => $TEST_DIRECTORY );
     return $test_data_object;
+}
+
+sub slurp {
+    my ($path) = @_;
+    open my $fh, '<', $path;
+    my $contents = do { local $INPUT_RECORD_SEPARATOR; <$fh> };
+    close $fh;
+    return \$contents;
 }
 
 sub test_analyze_one_file {
@@ -73,6 +82,62 @@
     my $has_subs_and_package_expected_result = $test_data->{'Module.pm'};
     my $subs_and_package_analysis = Perl::Metrics::Simple::Analysis::File->new(
         path => $has_subs_and_package_expected_result->{'path'} );
+    is_deeply(
+        $subs_and_package_analysis->all_counts,
+        $has_subs_and_package_expected_result,
+        'analyze_one_file() with packages and subs.'
+    );
+}
+
+sub test_analyze_text_from_scalar_ref {
+    my $test_data_object = set_up();
+    my $test_data        = $test_data_object->get_test_data;
+    my $no_package_no_sub_expected_result
+        = $test_data->{'no_packages_nor_subs'};
+
+    my $ref_to_text = slurp( $no_package_no_sub_expected_result->{'path'} );
+
+    my $analysis
+        = Perl::Metrics::Simple::Analysis::File->new( path => $ref_to_text );
+    is_deeply( $analysis->packages, [], 'Analysis of file with no packages.' );
+    is_deeply( $analysis->subs,     [], 'Analysis of file with no subs.' );
+
+    my $has_package_no_subs_expected_result
+        = $test_data->{'package_no_subs.pl'};
+    my $has_package_no_subs_contents
+        = slurp( $has_package_no_subs_expected_result->{'path'} );
+    my $new_analysis = Perl::Metrics::Simple::Analysis::File->new(
+        path => $has_package_no_subs_contents );
+    is_deeply(
+        $new_analysis->packages,
+        $has_package_no_subs_expected_result->{packages},
+        'Analysis of file with one package.'
+    );
+    is_deeply( $new_analysis->subs, [],
+        'Analysis of file with one package and no subs.' );
+
+    my $has_subs_expected_result = $test_data->{'subs_no_package.pl'};
+    $ref_to_text = slurp( $has_subs_expected_result->{'path'} );
+
+    $has_subs_expected_result->{'subs'}[0]{'path'}    = $ref_to_text;
+    $has_subs_expected_result->{'subs'}[1]{'path'}    = $ref_to_text;
+    $has_subs_expected_result->{'path'}               = $ref_to_text;
+    $has_subs_expected_result->{'main_stats'}{'path'} = $ref_to_text;
+    my $has_subs_analysis
+        = Perl::Metrics::Simple::Analysis::File->new( path => $ref_to_text );
+    is_deeply( $has_subs_analysis->all_counts,
+        $has_subs_expected_result, 'analyze_one_file() subs_no_package.pl' );
+
+    my $has_subs_and_package_expected_result = $test_data->{'Module.pm'};
+    $ref_to_text = slurp( $has_subs_and_package_expected_result->{'path'} );
+    $has_subs_and_package_expected_result->{'path'}            = $ref_to_text;
+    $has_subs_and_package_expected_result->{'subs'}[0]{'path'} = $ref_to_text;
+    $has_subs_and_package_expected_result->{'subs'}[1]{'path'} = $ref_to_text;
+    $has_subs_and_package_expected_result->{'subs'}[2]{'path'} = $ref_to_text;
+    $has_subs_and_package_expected_result->{'main_stats'}{'path'}
+        = $ref_to_text;
+    my $subs_and_package_analysis
+        = Perl::Metrics::Simple::Analysis::File->new( path => $ref_to_text );
     is_deeply(
         $subs_and_package_analysis->all_counts,
         $has_subs_and_package_expected_result,
@@ -237,5 +302,5 @@
         undef,
         '_get_mean_median_std_dev() returns undef when passed empty array.'
     );
-    return 1;    
-}
+    return 1;
+}

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/0901_pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/0901_pod.t?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/0901_pod.t (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/0901_pod.t Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 # -*- perl -*-
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/0901_pod.t,v 1.1 2006/11/26 06:47:43 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0901_pod.t,v 1.1 2006/11/26 06:47:43 matisse Exp $
 # $Revision: 1.1 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/0901_pod.t,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0901_pod.t,v $
 # $Date: 2006/11/26 06:47:43 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/0902_pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/0902_pod_coverage.t?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/0902_pod_coverage.t (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/0902_pod_coverage.t Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 # -*- perl -*-
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/0902_pod_coverage.t,v 1.1 2006/11/26 06:47:43 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0902_pod_coverage.t,v 1.1 2006/11/26 06:47:43 matisse Exp $
 # $Revision: 1.1 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/0902_pod_coverage.t,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/0902_pod_coverage.t,v $
 # $Date: 2006/11/26 06:47:43 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/end_token.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/end_token.pl?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/end_token.pl (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/end_token.pl Mon Feb  8 23:25:16 2010
@@ -1,7 +1,7 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/more_test_files/end_token.pl,v 1.1 2008/03/15 18:07:51 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/more_test_files/end_token.pl,v 1.1 2008/03/15 18:07:51 matisse Exp $
 # $Revision: 1.1 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/more_test_files/end_token.pl,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/more_test_files/end_token.pl,v $
 # $Date: 2008/03/15 18:07:51 $
 
 package end_token; # 1

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/main_subs_and_pod.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/main_subs_and_pod.pl?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/main_subs_and_pod.pl (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/more_test_files/main_subs_and_pod.pl Mon Feb  8 23:25:16 2010
@@ -1,7 +1,7 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/more_test_files/main_subs_and_pod.pl,v 1.1 2008/03/15 18:07:51 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/more_test_files/main_subs_and_pod.pl,v 1.1 2008/03/15 18:07:51 matisse Exp $
 # $Revision: 1.1 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/more_test_files/main_subs_and_pod.pl,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/more_test_files/main_subs_and_pod.pl,v $
 # $Date: 2008/03/15 18:07:51 $
 
 package main_subs_and_pod; # 1

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/test_files/Perl/Code/Analyze/Test/Module.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/test_files/Perl/Code/Analyze/Test/Module.pm?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/test_files/Perl/Code/Analyze/Test/Module.pm (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/test_files/Perl/Code/Analyze/Test/Module.pm Mon Feb  8 23:25:16 2010
@@ -1,7 +1,7 @@
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/Perl/Code/Analyze/Test/Module.pm,v 1.7 2006/11/23 22:25:48 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/Perl/Code/Analyze/Test/Module.pm,v 1.7 2006/11/23 22:25:48 matisse Exp $
 # $Revision: 1.7 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/Perl/Code/Analyze/Test/Module.pm,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/Perl/Code/Analyze/Test/Module.pm,v $
 # $Date: 2006/11/23 22:25:48 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/test_files/no_packages_nor_subs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/test_files/no_packages_nor_subs?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/test_files/no_packages_nor_subs (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/test_files/no_packages_nor_subs Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 #!/usr/bin/perl
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/no_packages_nor_subs,v 1.2 2006/09/03 17:13:29 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/no_packages_nor_subs,v 1.2 2006/09/03 17:13:29 matisse Exp $
 # $Revision: 1.2 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/no_packages_nor_subs,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/no_packages_nor_subs,v $
 # $Date: 2006/09/03 17:13:29 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/test_files/not_a_perl_file
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/test_files/not_a_perl_file?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/test_files/not_a_perl_file (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/test_files/not_a_perl_file Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 # not a perl file
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/not_a_perl_file,v 1.2 2006/09/03 17:13:29 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/not_a_perl_file,v 1.2 2006/09/03 17:13:29 matisse Exp $
 # $Revision: 1.2 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/not_a_perl_file,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/not_a_perl_file,v $
 # $Date: 2006/09/03 17:13:29 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/test_files/package_no_subs.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/test_files/package_no_subs.pl?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/test_files/package_no_subs.pl (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/test_files/package_no_subs.pl Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 #!/usr/bin/perl
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/package_no_subs.pl,v 1.4 2006/11/23 22:25:48 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/package_no_subs.pl,v 1.4 2006/11/23 22:25:48 matisse Exp $
 # $Revision: 1.4 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/package_no_subs.pl,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/package_no_subs.pl,v $
 # $Date: 2006/11/23 22:25:48 $
 ###############################################################################
 

Modified: branches/upstream/libperl-metrics-simple-perl/current/t/test_files/subs_no_package.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libperl-metrics-simple-perl/current/t/test_files/subs_no_package.pl?rev=52351&op=diff
==============================================================================
--- branches/upstream/libperl-metrics-simple-perl/current/t/test_files/subs_no_package.pl (original)
+++ branches/upstream/libperl-metrics-simple-perl/current/t/test_files/subs_no_package.pl Mon Feb  8 23:25:16 2010
@@ -1,8 +1,8 @@
 #!/usr/bin/perl
-# $Header: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/subs_no_package.pl,v 1.4 2006/09/24 19:18:06 matisse Exp $
+# $Header: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/subs_no_package.pl,v 1.4 2006/09/24 19:18:06 matisse Exp $
 # $Revision: 1.4 $
 # $Author: matisse $
-# $Source: /usr/local/CVS/Perl-Metrics-Simple/t/test_files/subs_no_package.pl,v $
+# $Source: /Library/VersionControl/CVS/Perl-Metrics-Simple/t/test_files/subs_no_package.pl,v $
 # $Date: 2006/09/24 19:18:06 $
 ###############################################################################
 




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