Permalink
Browse files

Added a frontend script 'bundledeps'.

Unimport 'bundle' from CPAN to remove warnings.
Actually implemented ->bundle_modules and fixed the POD.
  • Loading branch information...
1 parent 3772daf commit 84c4c7ec711962864145f9e1038bd153cdd8c4f5 @miyagawa committed Feb 6, 2010
Showing with 63 additions and 7 deletions.
  1. +2 −1 Makefile.PL
  2. +14 −6 lib/App/BundleDeps.pm
  3. +47 −0 script/bundledeps
View
@@ -6,7 +6,8 @@ all_from 'lib/App/BundleDeps.pm';
requires 'local::lib';
requires 'YAML';
+install_script 'script/bundledeps';
recommends 'YAML::XS';
test_requires 'Test::More';
-WriteAll;
+WriteAll;
View
@@ -1,7 +1,7 @@
package App::BundleDeps;
use strict;
use warnings;
-use CPAN;
+use CPAN ();
use CPAN::HandleConfig;
use ExtUtils::MakeMaker;
use File::Spec;
@@ -45,15 +45,23 @@ sub bundle_from_meta {
my $requires = $meta->{requires} || {};
my $build_requires = $meta->{build_requires} || {};
- $self->setup_deps( { %{ $requires }, %{ $build_requires } } );
+ my %deps = (%{ $requires }, %{ $build_requires });
+ $self->setup_deps(keys %deps);
$self->bundle();
}
+sub bundle_modules {
+ my($self, @modules) = @_;
+
+ $self->setup_deps(@modules);
+ $self->bundle();
+}
+
sub setup_deps {
- my ($self, $deps) = @_;
+ my ($self, @deps) = @_;
- my @deps = grep { $_ ne 'perl' } sort keys %$deps;
+ @deps = grep { $_ ne 'perl' } sort @deps;
$self->deps(\@deps);
}
@@ -103,7 +111,7 @@ App::BundleDeps - Bundle All Your Module Deps In A local::lib Dir
# or
my @modules = ( $module1, $module2, $module3, ... );
- App::BundleDeps->new()->bundle_modules( %modules );
+ App::BundleDeps->new()->bundle_modules( @modules );
=head1 DESCRIPTION
@@ -183,4 +191,4 @@ under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
-=cut
+=cut
View
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+use strict;
+use App::BundleDeps;
+use Getopt::Long;
+
+my $bundler = App::BundleDeps->new;
+
+@ARGV = map { /^(-M)(.+)/ ? ($1,$2) : $_ } @ARGV;
+
+my @modules;
+GetOptions(
+ "extlib=s", sub { $bundler->extlib($_[1]) },
+ 'M|modules=s@', sub { push @modules, $_[1] },
+);
+
+if (@modules) {
+ $bundler->bundle_modules(@modules);
+} else {
+ $bundler->bundle_from_meta('META.yml');
+}
+
+__END__
+
+=head1 NAME
+
+bundledeps - Frontend for App::BundleDeps
+
+=head1 SYNOPSIS
+
+ # build from META.yml into extlib
+ bundledeps
+
+ # Installs to local::lib path
+ bundledeps --extlib local
+
+ # Install modules
+ bundledeps -MCatalyst -MMoose
+
+=head1 AUTHOR
+
+Tatsuhiko Miyagawa
+
+=head1 SEE ALSO
+
+L<App::BundleDeps>
+
+=cut

0 comments on commit 84c4c7e

Please sign in to comment.