[carton] 214/472: move JSON parser to Lock
Lucas Kanashiro
kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
kanashiro-guest pushed a commit to branch master
in repository carton.
commit 334707133ddf374f876dcb72505ed2f2702d3932
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date: Thu May 30 22:10:46 2013 +0900
move JSON parser to Lock
---
lib/Carton/CLI.pm | 24 ++++--------------------
lib/Carton/Lock.pm | 8 ++++++++
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index 3a5c609..07261c3 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -287,35 +287,19 @@ sub find_lock {
my $self = shift;
if (-e $self->lock_file) {
- my $data;
+ my $lock;
try {
- $data = Carton::Util::load_json($self->lock_file);
+ $lock = Carton::Lock->from_file($self->lock_file);
} catch {
$self->error("Can't parse carton.lock: $_\n");
};
- return Carton::Lock->new($data);
+
+ return $lock;
}
return;
}
-sub lock_data {
- my $self = shift;
-
- my $data;
- try {
- $data = Carton::Util::load_json($self->lock_file);
- } catch {
- if (/No such file/) {
- $self->error("Can't locate carton.lock\n");
- } else {
- $self->error("Can't parse carton.lock: $_\n");
- }
- };
-
- return $data;
-}
-
sub lock_file {
my $self = shift;
return 'carton.lock';
diff --git a/lib/Carton/Lock.pm b/lib/Carton/Lock.pm
index 318ad88..c3c0af1 100644
--- a/lib/Carton/Lock.pm
+++ b/lib/Carton/Lock.pm
@@ -2,6 +2,14 @@ package Carton::Lock;
use strict;
use Carton::Package;
use Carton::Index;
+use Carton::Util;
+
+sub from_file {
+ my($class, $file) = @_;
+
+ my $data = Carton::Util::load_json($file);
+ return $class->new($data);
+}
sub new {
my($class, $data) = @_;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/carton.git
More information about the Pkg-perl-cvs-commits
mailing list