fix quoting of Makefile snippet for README
[p5sagit/Distar.git] / lib / Distar.pm
index 42ae6fe..fa64aed 100644 (file)
@@ -12,8 +12,10 @@ use File::Spec;
 our $VERSION = '0.001000';
 $VERSION = eval $VERSION;
 
+my $MM_VER = eval $ExtUtils::MakeMaker::VERSION;
+
 our @EXPORT = qw(
-  author manifest_include run_preflight
+  author manifest_include readme_generator run_preflight
 );
 
 sub import {
@@ -22,12 +24,17 @@ sub import {
   shift->export_to_level(1,@_);
 }
 
-sub author { our $Author = shift }
+sub author {
+  our $Author = shift;
+  $Author = [ $Author ]
+    if !ref $Author;
+}
 
 our $Ran_Preflight;
 
 our @Manifest = (
   'lib' => '.pm',
+  'lib' => '.pod',
   't' => '.t',
   't/lib' => '.pm',
   'xt' => '.t',
@@ -41,6 +48,14 @@ sub manifest_include {
   push @Manifest, @_;
 }
 
+my $readme_generator = <<'README';
+       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
+       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
+README
+sub readme_generator {
+    $readme_generator = shift;
+}
+
 sub write_manifest_skip {
   my @files = @Manifest;
   my @parts;
@@ -95,7 +110,7 @@ sub run_preflight {
     length && die "Outstanding changes";
   }
   my $ymd = sprintf(
-    "%i-%02i-%02i", (localtime)[5]+1900, (localtime)[4]+1, (localtime)[3]
+    "%i-%02i-%02i", (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3]
   );
   my $changes_line = "$version - $ymd\n";
   my @cached = grep /^\+/, `git diff --cached -U0`;
@@ -116,9 +131,10 @@ sub run_preflight {
   sub new {
     my ($class, $args) = @_;
     return $class->SUPER::new({
-      LICENSE => 'perl',
+      LICENSE => 'perl_5',
+      MIN_PERL_VERSION => '5.006',
+      AUTHOR => ($MM_VER >= 6.5702 ? $Distar::Author : $Distar::Author->[0]),
       %$args,
-      AUTHOR => $Distar::Author,
       ABSTRACT_FROM => $args->{VERSION_FROM},
       test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t xt/*/*.t' },
     });
@@ -126,7 +142,7 @@ sub run_preflight {
 
   sub dist_test {
     my $self = shift;
-    my $dist_test = $self->SUPER::dist_test(@_) . <<'END';
+    my $dist_test = $self->SUPER::dist_test(@_) . <<'END'
 
 # --- Distar section:
 preflight:
@@ -141,8 +157,8 @@ release: preflight
        git push origin v$(VERSION) HEAD
 distdir: readmefile
 readmefile: create_distdir
-       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
-       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
+END
+    . $readme_generator . <<'END';
 disttest: distmanicheck
 distmanicheck: create_distdir
        cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"