Permalink
Browse files

Checking in changes prior to tagging of version 1.5016.

Changelog diff is:

diff --git a/Changes b/Changes
index c35746b..0e1484d 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 See http://github.com/miyagawa/cpanminus/ for the latest development.

+1.5016 Tue Jul 17 12:00:57 PDT 2012
+   [Improvements]
+      - Added Module/CPANfile.pm to the fatlib. This allows bootstrapping dependencies
+        with cpanm --installdeps on Heroku etc.
+
 1.5015 Sun Jun 24 15:34:57 PDT 2012
    [Improvements]
       - Improved Makefile.PL to include bugtracker info (Ben Bullock)
  • Loading branch information...
1 parent 692559d commit b0cc91a33151853a4a2eb0ed6c593359d1bda1e0 @miyagawa committed Jul 17, 2012
Showing with 198 additions and 4 deletions.
  1. +5 −0 Changes
  2. +191 −2 cpanm
  3. +1 −1 lib/App/cpanminus.pm
  4. +1 −1 lib/App/cpanminus/script.pm
View
@@ -1,5 +1,10 @@
See http://github.com/miyagawa/cpanminus/ for the latest development.
+1.5016 Tue Jul 17 12:00:57 PDT 2012
+ [Improvements]
+ - Added Module/CPANfile.pm to the fatlib. This allows bootstrapping dependencies
+ with cpanm --installdeps on Heroku etc.
+
1.5015 Sun Jun 24 15:34:57 PDT 2012
[Improvements]
- Improved Makefile.PL to include bugtracker info (Ben Bullock)
View
193 cpanm
@@ -18,7 +18,7 @@ my %fatpacked;
$fatpacked{"App/cpanminus.pm"} = <<'APP_CPANMINUS';
package App::cpanminus;
- our $VERSION = "1.5015";
+ our $VERSION = "1.5016";
=head1 NAME
@@ -326,7 +326,7 @@ $fatpacked{"App/cpanminus/script.pm"} = <<'APP_CPANMINUS_SCRIPT';
use constant WIN32 => $^O eq 'MSWin32';
use constant SUNOS => $^O eq 'solaris';
- our $VERSION = "1.5015";
+ our $VERSION = "1.5016";
my $quote = WIN32 ? q/"/ : q/'/;
@@ -8124,6 +8124,195 @@ $fatpacked{"JSON/PP/Boolean.pm"} = <<'JSON_PP_BOOLEAN';
JSON_PP_BOOLEAN
+$fatpacked{"Module/CPANfile.pm"} = <<'MODULE_CPANFILE';
+ package Module::CPANfile;
+ use strict;
+ use warnings;
+ use Cwd;
+
+ our $VERSION = '0.9007';
+
+ sub new {
+ my($class, $file) = @_;
+ bless {}, $class;
+ }
+
+ sub load {
+ my($proto, $file) = @_;
+ my $self = ref $proto ? $proto : $proto->new;
+ $self->{file} = $file || "cpanfile";
+ $self->parse;
+ $self;
+ }
+
+ sub parse {
+ my $self = shift;
+
+ my $file = Cwd::abs_path($self->{file});
+ $self->{result} = Module::CPANfile::Environment::parse($file) or die $@;
+ }
+
+ sub prereqs { shift->prereq }
+
+ sub prereq {
+ my $self = shift;
+ require CPAN::Meta::Prereqs;
+ CPAN::Meta::Prereqs->new($self->prereq_specs);
+ }
+
+ sub prereq_specs {
+ my $self = shift;
+ $self->{result}{spec};
+ }
+
+ package Module::CPANfile::Environment;
+ use strict;
+
+ my @bindings = qw(
+ on requires recommends suggests conflicts
+ osname perl
+ configure_requires build_requires test_requires author_requires
+ );
+
+ my $file_id = 1;
+
+ sub import {
+ my($class, $result_ref) = @_;
+ my $pkg = caller;
+
+ $$result_ref = Module::CPANfile::Result->new;
+ for my $binding (@bindings) {
+ no strict 'refs';
+ *{"$pkg\::$binding"} = sub { $$result_ref->$binding(@_) };
+ }
+ }
+
+ sub parse {
+ my $file = shift;
+
+ my $code = do {
+ open my $fh, "<", $file or die "$file: $!";
+ join '', <$fh>;
+ };
+
+ my($res, $err);
+
+ {
+ local $@;
+ $res = eval sprintf <<EVAL, $file_id++;
+ package Module::CPANfile::Sandbox%d;
+ no warnings;
+ my \$_result;
+ BEGIN { import Module::CPANfile::Environment \\\$_result };
+
+ $code;
+
+ \$_result;
+ EVAL
+ $err = $@;
+ }
+
+ if ($err) { die "Parsing $file failed: $err" };
+
+ return $res;
+ }
+
+ package Module::CPANfile::Result;
+ use strict;
+
+ sub new {
+ bless {
+ phase => 'runtime', # default phase
+ spec => {},
+ }, shift;
+ }
+
+ sub on {
+ my($self, $phase, $code) = @_;
+ local $self->{phase} = $phase;
+ $code->()
+ }
+
+ sub osname { die "TODO" }
+ sub perl { die "TODO" }
+
+ sub requires {
+ my($self, $module, $requirement) = @_;
+ $self->{spec}{$self->{phase}}{requires}{$module} = $requirement || 0;
+ }
+
+ sub recommends {
+ my($self, $module, $requirement) = @_;
+ $self->{spec}->{$self->{phase}}{recommends}{$module} = $requirement || 0;
+ }
+
+ sub suggests {
+ my($self, $module, $requirement) = @_;
+ $self->{spec}->{$self->{phase}}{suggests}{$module} = $requirement || 0;
+ }
+
+ sub conflicts {
+ my($self, $module, $requirement) = @_;
+ $self->{spec}->{$self->{phase}}{conflicts}{$module} = $requirement || 0;
+ }
+
+ # Module::Install compatible shortcuts
+
+ sub configure_requires {
+ my($self, @args) = @_;
+ $self->on(configure => sub { $self->requires(@args) });
+ }
+
+ sub build_requires {
+ my($self, @args) = @_;
+ $self->on(build => sub { $self->requires(@args) });
+ }
+
+ sub test_requires {
+ my($self, @args) = @_;
+ $self->on(test => sub { $self->requires(@args) });
+ }
+
+ sub author_requires {
+ my($self, @args) = @_;
+ $self->on(develop => sub { $self->requires(@args) });
+ }
+
+ package Module::CPANfile;
+
+ 1;
+
+ __END__
+
+ =head1 NAME
+
+ Module::CPANfile - Parse cpanfile
+
+ =head1 SYNOPSIS
+
+ use Module::CPANfile;
+
+ my $file = Module::CPANfile->load("cpanfile");
+ my $prereqs = $file->prereqs; # CPAN::Meta::Prereqs object
+
+ =head1 DESCRIPTION
+
+ Module::CPANfile is a tool to handle L<cpanfile> format to load application
+ specific dependencies, not just for CPAN distributions.
+
+ =head1 AUTHOR
+
+ Tatsuhiko Miyagawa
+
+ =head1 SEE ALSO
+
+ L<cpanfile>, L<CPAN::Meta>, L<CPAN::Meta::Spec>
+
+ =cut
+
+
+MODULE_CPANFILE
+
$fatpacked{"Module/Metadata.pm"} = <<'MODULE_METADATA';
# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
# vim:ts=8:sw=2:et:sta:sts=2
View
@@ -1,5 +1,5 @@
package App::cpanminus;
-our $VERSION = "1.5015";
+our $VERSION = "1.5016";
=head1 NAME
@@ -14,7 +14,7 @@ use Symbol ();
use constant WIN32 => $^O eq 'MSWin32';
use constant SUNOS => $^O eq 'solaris';
-our $VERSION = "1.5015";
+our $VERSION = "1.5016";
my $quote = WIN32 ? q/"/ : q/'/;

0 comments on commit b0cc91a

Please sign in to comment.