Author: particle
Date: Thu Jan 25 09:34:46 2007
New Revision: 16791

Modified:
   trunk/lib/Parrot/Distribution.pm
   trunk/t/codingstd/perlcritic.t
   trunk/t/perl/Parrot_Distribution.t

Log:
[lib]: refactoring Parrot::Distribution.pm -- part 2
~ clean up get_perl_language_files()
~ added some tests
~ modify usage in perlcritic tests

Modified: trunk/lib/Parrot/Distribution.pm
==============================================================================
--- trunk/lib/Parrot/Distribution.pm    (original)
+++ trunk/lib/Parrot/Distribution.pm    Thu Jan 25 09:34:46 2007
@@ -194,7 +194,7 @@
                 ],
             },
             yacc => { file_exts => ['y'] },
-#            perl => { file_exts => ['pl', 'pm', 'in', 't'] },
+            perl => { file_exts => ['pl', 'pm', 'in', 't'] },
         },
         header => {
             c    => { file_exts => ['h'] },
@@ -378,16 +378,18 @@
 
 sub get_perl_language_files {
     my $self = shift;
-    my @files;
-    my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
 
-    foreach my $file ( keys(%$manifest) ) {
+    my @files = (
+        $self->perl_source_files,
+    );
+
+    my @perl_language_files = ();
+    foreach my $file ( @files ) {
         next if $self->is_perl_exemption($file);
-        next unless $self->is_perl($file);
-        push @files, $file;
+        push @perl_language_files, $file;
     }
 
-    return @files;
+    return @perl_language_files;
 }
 
 
@@ -412,7 +414,7 @@
         } unless @exemptions;
 
         $file->path =~ /\Q$_\E$/ && return 1
-            for @exemptions;
+            for <@exemptions>;
         return;
     }
 }

Modified: trunk/t/codingstd/perlcritic.t
==============================================================================
--- trunk/t/codingstd/perlcritic.t      (original)
+++ trunk/t/codingstd/perlcritic.t      Thu Jan 25 09:34:46 2007
@@ -89,7 +89,7 @@
 # get the files to check
 my $DIST = Parrot::Distribution->new();
 if ( [EMAIL PROTECTED] ) {
-    @files = $DIST->get_perl_language_files();
+    @files = map { $_->path } $DIST->get_perl_language_files();
 }
 else {
 

Modified: trunk/t/perl/Parrot_Distribution.t
==============================================================================
--- trunk/t/perl/Parrot_Distribution.t  (original)
+++ trunk/t/perl/Parrot_Distribution.t  Thu Jan 25 09:34:46 2007
@@ -5,7 +5,7 @@
 use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );
-use Test::More tests => 26;
+use Test::More tests => 30;
 use File::Spec;
 
 =head1 NAME
@@ -64,6 +64,17 @@
         "Directory from hardcoded list $dir found through MANIFEST" );
 }
 
+
+## perl files
+{
+    my @perl_files;
+    ok( ( @perl_files = $d->get_perl_language_files ), 'Got perl files' );
+    ok( $d->perl_source_file_with_name('ops2c.pl'), 'Perl source file (.pl)' );
+    ok( $d->perl_source_file_with_name('Distribution.pm'), 'Perl source file 
(.pm)' );
+    ok( $d->perl_source_file_with_name('perlcritic.t'), 'Perl source file 
(.t)' );
+}
+
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4

Reply via email to