This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit bf362c590185e6303f7d87fc586072b7a7a732cf
Author: Tatsuhiko Miyagawa <miyag...@bulknews.net>
Date:   Thu May 30 17:22:25 2013 +0900

    remove lock state property for Carton object
---
 lib/Carton.pm      | 17 +++++++----------
 lib/Carton/CLI.pm  | 29 ++++++++++++++++-------------
 lib/Carton/Lock.pm |  8 ++++++++
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/lib/Carton.pm b/lib/Carton.pm
index e7a4afa..9cb57a4 100644
--- a/lib/Carton.pm
+++ b/lib/Carton.pm
@@ -41,8 +41,6 @@ sub local_cache {
     File::Spec->rel2abs("$_[0]->{path}/cache");
 }
 
-sub lock { $_[0]->{lock} }
-
 sub list_dependencies {
     my $self = shift;
 
@@ -59,12 +57,12 @@ sub list_dependencies {
     return map "$_~$hash->{$_}", grep { $_ ne 'perl' } keys %$hash;
 }
 
-sub download_from_cpanfile {
-    my($self, $cpanfile) = @_;
+sub bundle {
+    my($self, $cpanfile, $lock) = @_;
 
     my @modules = $self->list_dependencies;
 
-    my $index = $self->build_index($self->lock->{modules});
+    my $index = $self->build_index($lock->{modules});
     $self->build_mirror_file($index, $self->{mirror_file});
 
     my $mirror = $self->{mirror} || $DefaultMirror;
@@ -77,19 +75,18 @@ sub download_from_cpanfile {
         "--mirror-index", $self->{mirror_file},
         "--no-skip-satisfied",
         ( $mirror ne $DefaultMirror ? "--mirror-only" : () ),
-        "--scandeps",
         "--save-dists", $local_cache,
         @modules,
     );
 }
 
 sub install {
-    my($self, $file, $cascade) = @_;
+    my($self, $file, $lock, $cascade) = @_;
 
     my @modules = $self->list_dependencies;
 
-    if ($self->lock) {
-        my $index = $self->build_index($self->lock->{modules});
+    if ($lock) {
+        my $index = $self->build_index($lock->{modules});
         $self->build_mirror_file($index, $self->{mirror_file});
     }
 
@@ -106,7 +103,7 @@ sub install {
         "--mirror", "http://backpan.perl.org/";, # fallback
         "--skip-satisfied",
         ( $is_default_mirror ? () : "--mirror-only" ),
-        ( $self->lock ? ("--mirror-index", $self->{mirror_file}) : () ),
+        ( $lock ? ("--mirror-index", $self->{mirror_file}) : () ),
         ( $cascade ? "--cascade-search" : () ),
         @modules,
     ) or die "Installing modules failed\n";
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index 2112f62..1fc95f6 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -8,6 +8,7 @@ use Getopt::Long;
 use Term::ANSIColor qw(colored);
 
 use Carton;
+use Carton::Lock;
 use Carton::Util;
 use Carton::Error;
 use Try::Tiny;
@@ -135,18 +136,16 @@ sub cmd_bundle {
 
     $self->parse_options(\@args, "p|path=s" => sub { $self->carton->{path} = 
$_[1] });
 
-    my $lock = $self->find_lock;
-
     $self->carton->configure(
-        lock => $lock,
         mirror_file => $self->mirror_file,
     );
 
+    my $lock = $self->find_lock;
     my $cpanfile = $self->find_cpanfile;
 
     if ($lock) {
         $self->print("Bundling modules using $cpanfile\n");
-        $self->carton->download_from_cpanfile($cpanfile);
+        $self->carton->bundle($cpanfile, $lock);
     } else {
         $self->error("Can't locate carton.lock file. Run carton install 
first\n");
     }
@@ -164,10 +163,7 @@ sub cmd_install {
         "cached!"     => \$self->{use_local_mirror},
     );
 
-    my $lock = $self->find_lock;
-
     $self->carton->configure(
-        lock => $lock,
         mirror_file => $self->mirror_file,
     );
 
@@ -175,14 +171,15 @@ sub cmd_install {
         $self->carton->use_local_mirror;
     }
 
+    my $lock = $self->find_lock;
     my $cpanfile = $self->find_cpanfile;
 
     if ($self->{deployment}) {
         $self->print("Installing modules using $cpanfile (deployment mode)\n");
-        $self->carton->install($cpanfile);
+        $self->carton->install($cpanfile, $lock);
     } else {
         $self->print("Installing modules using $cpanfile\n");
-        $self->carton->install($cpanfile, 1);
+        $self->carton->install($cpanfile, $lock, 1);
         $self->carton->update_lock_file($self->lock_file);
     }
 
@@ -295,7 +292,13 @@ sub find_lock {
     my $self = shift;
 
     if (-e $self->lock_file) {
-        return $self->lock_data; # TODO object
+        my $data;
+        try {
+            $data = Carton::Util::load_json($self->lock_file);
+        } catch {
+            $self->error("Can't parse carton.lock: $_\n");
+        };
+        return Carton::Lock->new($data);
     }
 
     return;
@@ -304,9 +307,9 @@ sub find_lock {
 sub lock_data {
     my $self = shift;
 
-    my $lock;
+    my $data;
     try {
-        $lock = Carton::Util::load_json($self->lock_file);
+        $data = Carton::Util::load_json($self->lock_file);
     } catch {
         if (/No such file/) {
             $self->error("Can't locate carton.lock\n");
@@ -315,7 +318,7 @@ sub lock_data {
         }
     };
 
-    return $lock;
+    return $data;
 }
 
 sub lock_file {
diff --git a/lib/Carton/Lock.pm b/lib/Carton/Lock.pm
new file mode 100644
index 0000000..066d58a
--- /dev/null
+++ b/lib/Carton/Lock.pm
@@ -0,0 +1,8 @@
+package Carton::Lock;
+
+sub new {
+    my($class, $data) = @_;
+    bless $data, $class;
+}
+
+1;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/carton.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to