convert to Distar, fixup author
[p5sagit/strictures.git] / lib / strictures.pm
index f149054..3c3c005 100644 (file)
@@ -3,31 +3,53 @@ package strictures;
 use strict;
 use warnings FATAL => 'all';
 
-our $VERSION = '1.000000'; # 1.0.0
+our $VERSION = '1.002000'; # 1.2.0
 
 sub VERSION {
   for ($_[1]) {
     last unless defined && !ref && int != 1;
     die "Major version specified as $_ - this is strictures version 1";
   }
+  # disable this since Foo->VERSION(undef) correctly returns the version
+  # and that can happen either if our caller passes undef explicitly or
+  # because the for above autovivified $_[1] - I could make it stop but
+  # it's pointless since we don't want to blow up if the caller does
+  # something valid either.
+  no warnings 'uninitialized';
   shift->SUPER::VERSION(@_);
 }
 
 sub import {
   strict->import;
   warnings->import(FATAL => 'all');
-  my $do_indirect = do {
+  my $extra_tests = do {
     if (exists $ENV{PERL_STRICTURES_EXTRA}) {
       $ENV{PERL_STRICTURES_EXTRA}
     } else {
-      !!($0 =~ /^x?t\/.*(?:load|compile|coverage).*\.t$/)
+      !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
+         and (-e '.git' or -e '.svn'))
     }
   };
-  if ($do_indirect) {
-    if (eval { require indirect; 1 }) {
-      indirect->unimport('FATAL');
+  if ($extra_tests) {
+    if (eval {
+          require indirect;
+          require multidimensional;
+          require bareword::filehandles;
+          1
+        }) {
+      indirect->unimport(':fatal');
+      multidimensional->unimport;
+      bareword::filehandles->unimport;
     } else {
-      die "strictures.pm extra testing active but couldn't load indirect.pm: $@";
+      die "strictures.pm extra testing active but couldn't load modules.
+Extra testing is auto-enabled in checkouts only, so if you're the author
+of a strictures using module you need to run:
+
+  cpan indirect multidimensional bareword::filehandles
+
+but these modules are not required by your users.
+
+Error loading modules was: $@";
     }
   }
 }
@@ -50,10 +72,11 @@ is equivalent to
 
 except when called from a file where $0 matches:
 
-  /^x?t\/.*(?:load|compile|coverage).*\.t$/
+  /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
 
-or when the PERL_STRICTURES_EXTRA environment variable is set, in which
-case
+and when either '.git' or '.svn' is present in the current directory (with
+the intention of only forcing extra tests on the author side) - or when the
+PERL_STRICTURES_EXTRA environment variable is set, in which case
 
   use strictures 1;
 
@@ -62,11 +85,16 @@ is equivalent to
   use strict;
   use warnings FATAL => 'all';
   no indirect 'fatal';
+  no multidimensional;
+  no bareword::filehandles;
 
 Note that _EXTRA may at some point add even more tests, with only a minor
 version increase, but any changes to the effect of 'use strictures' in
 normal mode will involve a major version bump.
 
+Be aware: THIS MEANS THE EXTRA TEST MODULES ARE REQUIRED FOR AUTHORS OF
+STRICTURES USING CODE - but not by end users thereof.
+
 =head1 DESCRIPTION
 
 I've been writing the equivalent of this module at the top of my code for
@@ -105,3 +133,48 @@ when its version is tested to ensure that
 
 will continue to only introduce the current set of strictures even if 2.0 is
 installed.
+
+=head1 METHODS
+
+=head2 import
+
+This method does the setup work described above in L</DESCRIPTION>
+
+=head2 VERSION
+
+This method traps the strictures->VERSION(1) call produced by a use line
+with a version number on it and does the version check.
+
+=head1 COMMUNITY AND SUPPORT
+
+=head2 IRC channel
+
+irc.perl.org #toolchain
+
+(or bug 'mst' in query on there or freenode)
+
+=head2 Git repository
+
+Gitweb is on http://git.shadowcat.co.uk/ and the clone URL is:
+
+  git clone git://git.shadowcat.co.uk/p5sagit/strictures.git
+
+=head1 AUTHOR
+
+mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
+
+=head1 CONTRIBUTORS
+
+None required yet. Maybe this module is perfect (hahahahaha ...).
+
+=head1 COPYRIGHT
+
+Copyright (c) 2010 the strictures L</AUTHOR> and L</CONTRIBUTORS>
+as listed above.
+
+=head1 LICENSE
+
+This library is free software and may be distributed under the same terms
+as perl itself.
+
+=cut