Subject: | PATCH: Add Module::Build support |
The attached patch adds support for Module::Build. I tested it out on
one of my projects and it worked well. It's version-finding code may not
be 100% correct for all possible cases, but I think it's decent. It'd be
better to run the Build.PL, then use the Module::Build API to get the
version (via the dist_version method), but I'm not sure you wanted to do
that.
Subject: | shipit.patch |
diff -ru ShipIt-0.51/lib/ShipIt/ProjectType/Perl/ModuleBuild.pm ShipIt-0.51.new/lib/ShipIt/ProjectType/Perl/ModuleBuild.pm
--- ShipIt-0.51/lib/ShipIt/ProjectType/Perl/ModuleBuild.pm 2007-05-07 15:52:46.000000000 -0500
+++ ShipIt-0.51.new/lib/ShipIt/ProjectType/Perl/ModuleBuild.pm 2008-02-10 10:56:15.000000000 -0600
@@ -20,5 +20,21 @@
!system("perl", "Build", $cmd);
}
+sub makedist {
+ my $self = shift;
+ $self->prepare_build;
+
+ require Module::Build;
+ my $build = Module::Build->current;
+
+ my $file = $build->dist_dir;
+ $file .= ".tar.gz";
+ die "Distfile $file already exists.\n" if -e $file;
+
+ $self->run_build("dist") or die "make dist failed";
+ die "Distfile $file doesn't exists, but should.\n" unless -e $file;
+ return $file;
+}
+
1;
Only in ShipIt-0.51.new/lib/ShipIt/ProjectType/Perl: ModuleBuild.pm~
diff -ru ShipIt-0.51/lib/ShipIt/ProjectType/Perl.pm ShipIt-0.51.new/lib/ShipIt/ProjectType/Perl.pm
--- ShipIt-0.51/lib/ShipIt/ProjectType/Perl.pm 2007-04-25 18:11:53.000000000 -0500
+++ ShipIt-0.51.new/lib/ShipIt/ProjectType/Perl.pm 2008-02-10 10:45:18.000000000 -0600
@@ -1,6 +1,7 @@
package ShipIt::ProjectType::Perl;
use strict;
use base 'ShipIt::ProjectType';
+use File::Spec;
use ShipIt::Util qw(slurp write_file);
use ShipIt::ProjectType::Perl::MakeMaker;
use ShipIt::ProjectType::Perl::ModuleBuild;
@@ -26,10 +27,10 @@
my $self = shift;
return $self->{version} if defined $self->{version};
- if (-e "Makefile.PL") {
- return $self->{version} = $self->current_version_from_makefilepl;
+ if (-e "Build.PL") {
+ return $self->{version} = $self->current_version_from_buildpl;
} else {
- die "TODO: don't yet support Module::Build, etc...\n";
+ return $self->{version} = $self->current_version_from_makefilepl;
}
}
@@ -55,6 +56,37 @@
return $self->version_from_file;
}
+sub current_version_from_buildpl {
+ my $self = shift;
+ open (my $fh, "Build.PL") or die "Can't open Build.PL: $!\n";
+ while (<$fh>) {
+ if (/\bdist_version_from\b.+([\'\"])(.+?)\1/) {
+ $self->{ver_from} = $2;
+ last;
+ }
+ if (/\bmodule_name\b.+([\'\"])(.+?)\1/) {
+ $self->{ver_from} = $self->_module_to_file($2);
+ # no last since we prefer dist_version_from
+ }
+ if (/\bdist_version\b.+([\'\"])(.+?)\1/) {
+ return $2;
+ }
+ }
+ close($fh);
+ return $self->version_from_file;
+}
+
+sub _module_to_file {
+ my ($self, $mod) = @_;
+
+ my @parts = split /::/, $mod;
+ $parts[-1] .= q{.pm};
+
+ unshift @parts, 'lib' if -d 'lib';
+
+ return File::Spec->catfile(@parts);
+}
+
# returns $VERSION from a file, assuming $self->{ver_from} is already set
sub version_from_file {
my $self = shift;
Only in ShipIt-0.51.new/lib/ShipIt/ProjectType: Perl.pm~
Only in ShipIt-0.51.new/lib/ShipIt: Util.pm~
diff -ru ShipIt-0.51/Makefile.PL ShipIt-0.51.new/Makefile.PL
--- ShipIt-0.51/Makefile.PL 2007-02-03 16:26:07.000000000 -0600
+++ ShipIt-0.51.new/Makefile.PL 2008-02-10 10:44:08.000000000 -0600
@@ -18,6 +18,7 @@
AUTHOR => 'Brad Fitzpatrick <brad@danga.com>',
ABSTRACT_FROM => 'lib/ShipIt.pm',
PREREQ_PM => {
+ 'File::Spec' => 0,
'Term::ReadLine' => 0,
},
);