Merging svn trunk into master
Nick Gerakines [Tue, 23 Dec 2008 18:18:52 +0000 (10:18 -0800)]
Build.PL
Changes
MANIFEST
META.yml
Makefile.PL [new file with mode: 0644]
lib/Test/NoTabs.pm
tools/chimps-client.pl [new file with mode: 0644]

index 287e733..ac35adb 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -13,6 +13,7 @@ my $builder = Module::Build->new(
         'File::Spec' => 0,
         'FindBin' => 0,
         'File::Find' => 0,
+        'Test::Group' => 0,
     },
     add_to_cleanup      => [ 'Test-NoTabs-*' ],
 );
diff --git a/Changes b/Changes
index 079420d..bc07902 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,3 +2,10 @@ Revision history for Test-NoTabs
 
 0.1  2006-08-24
      - Module created and released on an unsuspecting world.
+
+0.2  2006-08-25
+     - Minor code changes and pod updates
+     - Added Makefile.PL for compatibility
+
+0.3  2006-08-26
+     - Added missing dependancy (Test::Group)
index d349091..507b365 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,8 @@
 Build.PL
+<<<<<<< HEAD:MANIFEST
+=======
+Makefile.PL
+>>>>>>> trunk:MANIFEST
 Changes
 MANIFEST
 META.yml
index ba3a7ee..cb1d67c 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name: Test-NoTabs
-version: 0.1
+version: 0.3
 author:
   - Nick Gerakines <nick@socklabs.com>
 abstract: Check the presence of tabs in your project
diff --git a/Makefile.PL b/Makefile.PL
new file mode 100644 (file)
index 0000000..7424476
--- /dev/null
@@ -0,0 +1,3 @@
+use Module::Build::Compat;
+Module::Build::Compat->run_build_pl(args => \@ARGV);
+Module::Build::Compat->write_makefile();
\ No newline at end of file
index 1a76df7..e8274ec 100644 (file)
@@ -10,7 +10,7 @@ use File::Find;
 
 use vars qw( $VERSION $PERL $UNTAINT_PATTERN $PERL_PATTERN);
 
-$VERSION = '0.1';
+$VERSION = '0.3.1';
 
 $PERL    = $^X || 'perl';
 $UNTAINT_PATTERN  = qr|^([-+@\w./:\\]+)$|;
@@ -64,17 +64,17 @@ sub _all_files {
 
 sub notabs_ok {
     my $file = shift;
-    my $test_txt = shift || "Found tabs in '$file' on line ";
+    my $test_txt = shift || "Found tabs in '$file'";
     $file = _module_to_path($file);
-    open my($fh), $file or do { $Test->ok(0, $test_txt); $Test->diag("Could not open $file: $!"); return; };
+    open my $fh, $file or do { $Test->ok(0, $test_txt); $Test->diag("Could not open $file: $!"); return; };
     my $line = 0;
     while (<$fh>) {
         $line++;
-        next if (/^\s*#/); # Skip comments
-        next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/); # Skip pod
-        last if (/^\s*(__END__|__DATA__)/); # End of code
+        next if (/^\s*#/);
+        next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/);
+        last if (/^\s*(__END__|__DATA__)/);
         if ( /\t/ ) {
-          $Test->ok(0, $test_txt . $line);
+          $Test->ok(0, $test_txt . " on line $line");
           return 0;
         }
     }
@@ -98,7 +98,7 @@ sub _is_perl_script {
     my $file = shift;
     return 1 if $file =~ /\.pl$/i;
     return 1 if $file =~ /\.t$/;
-    open my($fh), $file or return;
+    open my $fh, $file or return;
     my $first = <$fh>;
     return 1 if defined $first && ($first =~ $PERL_PATTERN);
     return;
@@ -157,7 +157,7 @@ or
 
 =head1 DESCRIPTION
 
-This module scans your project/distrobution for any perl files (scripts,
+This module scans your project/distribution for any perl files (scripts,
 modules, etc) for the presence of tabs.
 
 =head1 EXPORT
@@ -232,7 +232,9 @@ L<http://search.cpan.org/dist/Test-NoTabs>
 Inspired by some code written by Paul Lindner.
 
 L<Test::Strict> was used as an example when creating this module and
-distrobution.
+distribution.
+
+Rick Myers and Emanuele Zeppieri also provided valuable feedback.
 
 =head1 SEE ALSO
 
diff --git a/tools/chimps-client.pl b/tools/chimps-client.pl
new file mode 100644 (file)
index 0000000..7d49c92
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+use Config;
+use File::Spec;
+use Test::Chimps::Client;
+use Test::TAP::Model::Visual;
+
+chdir "$FindBin::Bin/..";
+
+my @tests = map glob, qw(t/*.t);
+my $start = time;
+my $model = Test::TAP::Model::Visual->new_with_tests(@tests);
+
+my $client = Test::Chimps::Client->new(
+    server => 'http://dev.socklabs.com/cgi-bin/chimps-server.pl',
+    model  => $model,
+    report_variables => {
+        archname  => $Config{archname},
+        committer => $ENV{USER} || $ENV{USERNAME},
+        osname    => $Config{osname},
+        osvers    => $Config{osvers},
+        project   => 'Test-NoTabs',
+        duration  => time - $start,
+        revision  => get_revision(),
+    },
+);
+
+my ($status, $msg) = $client->send;
+if (! $status) {
+    print "Error: $msg\n";
+    exit(1);
+}
+
+sub get_revision {
+    return
+        # extract_revision('svk', 'svk info', qr/Mirrored From: .*Rev\. (\d+)/) ||
+        extract_revision('svn', 'svn info', qr/Revision: (\d+)/) ||
+        extract_svn_revision('.svn/entries') ||
+       'unknown';
+}
+
+sub extract_revision {
+    my($cmd, $command, $re) = @_;
+
+    return unless has_command($cmd);
+
+    my $out = qx($command) or return;
+    $out =~ /$re/;
+    return $1;
+}
+
+sub has_command {
+    my $cmd = shift;
+    grep { -e File::Spec->catfile($_, $cmd) } split /:/, $ENV{PATH};
+}
+
+sub extract_svn_revision {
+    my $file = shift;
+    open my($fh), $file or return;
+    while (<$fh>) {
+        /revision="(\d+)"/ and return $1;
+    }
+    return;
+}