[Bps-public-commit] Shipwright branch, master, updated. 65c21d505e3eb3cdf953154c1364a4718c1593ed
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sun Jul 19 03:59:31 EDT 2009
The branch, master has been updated
via 65c21d505e3eb3cdf953154c1364a4718c1593ed (commit)
from e7260a470a2aa4ef4c99f316ea72fd82f9a10744 (commit)
Summary of changes:
lib/Shipwright/Source/Base.pm | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit 65c21d505e3eb3cdf953154c1364a4718c1593ed
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jul 19 15:39:54 2009 +0800
add support for requires_from and test_requires_from methods of Module::Install
diff --git a/lib/Shipwright/Source/Base.pm b/lib/Shipwright/Source/Base.pm
index e82bc49..7264616 100644
--- a/lib/Shipwright/Source/Base.pm
+++ b/lib/Shipwright/Source/Base.pm
@@ -181,6 +181,10 @@ sub _follow {
$makefile =~ s/^\s*recommends(?!\w)/shipwright_recommends/mg;
$makefile =~ s/^\s*features(?!\w)/shipwright_features/mg;
$makefile =~ s/^\s*feature(?!\w)/shipwright_feature/mg;
+ $makefile =~
+ s/^\s*requires_from(?!\w)/shipwright_requires_from/mg;
+ $makefile =~
+ s/^\s*test_requires_from(?!\w)/shipwright_test_requires_from/mg;
my $shipwright_makefile = <<'EOF';
my $shipwright_req = {};
@@ -207,6 +211,32 @@ sub shipwright_test_requires {
goto &test_requires;
}
+sub _shipwright_requires_from {
+ my $type = shift;
+ my $file = shift;
+
+ open my $fh, '<', $file or return;
+ my $content = do { local $/; <$fh> };
+# the following lines in this sub are mostly stolen from Module::Install::Metadata
+ my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+
+ while ( @requires ) {
+ my $module = shift @requires;
+ my $version = shift @requires;
+ _shipwright_requires( $type, $module, $version || 0 );
+ }
+}
+
+sub shipwright_test_requires_from {
+ _shipwright_requires_from( 'build_requires', @_ );
+ goto &test_requires_from;
+}
+
+sub shipwright_requires_from {
+ _shipwright_requires_from( 'requires', @_ );
+ goto &requires_from;
+}
+
sub shipwright_recommends {
_shipwright_requires( 'recommends', @_ == 1 ? ( @_, 0 ) : @_ );
goto &recommends;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list