[carton] 263/472: Add carton list --distfile

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Fri Jul 24 00:38:53 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 9b3be8951a1a3e024461dd52979fdc1d7dc88c59
Author: Tatsuhiko Miyagawa <miyagawa at bulknews.net>
Date:   Mon Jun 3 17:30:12 2013 +0900

    Add carton list --distfile
---
 lib/Carton/CLI.pm        |  9 ++++++++-
 lib/Carton/Dependency.pm | 12 +++++++++---
 lib/Carton/Doc/List.pod  | 10 ++++++++++
 lib/Carton/Lock.pm       |  3 +--
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/lib/Carton/CLI.pm b/lib/Carton/CLI.pm
index db88586..2e7f852 100644
--- a/lib/Carton/CLI.pm
+++ b/lib/Carton/CLI.pm
@@ -237,11 +237,18 @@ sub cmd_show {
 sub cmd_list {
     my($self, @args) = @_;
 
+    my $format = 'dist';
+
+    $self->parse_options(
+        \@args,
+        "distfile" => sub { $format = 'distfile' },
+    );
+
     my $lock = $self->find_lock
         or $self->error("Can't find carton.lock: Run `carton install` to rebuild the lock file.\n");
 
     for my $dependency ($lock->dependencies) {
-        $self->print($dependency->distname . "\n");
+        $self->print($dependency->$format . "\n");
     }
 }
 
diff --git a/lib/Carton/Dependency.pm b/lib/Carton/Dependency.pm
index 65d0347..14511eb 100644
--- a/lib/Carton/Dependency.pm
+++ b/lib/Carton/Dependency.pm
@@ -3,11 +3,17 @@ use strict;
 use CPAN::Meta;
 use Moo;
 
-has meta => (is => 'ro', coerce => sub { CPAN::Meta->new($_[0], { lazy_validation => 1 }) });
+has name     => (is => 'ro');
+has pathname => (is => 'ro');
+has provides => (is => 'ro');
+has version  => (is => 'ro');
+has target   => (is => 'ro');
+has dist     => (is => 'ro');
+has mymeta   => (is => 'ro', coerce => sub { CPAN::Meta->new($_[0], { lazy_validation => 1 }) });
 
-sub distname {
+sub distfile {
     my $self = shift;
-    sprintf '%s-%s', $self->meta->name, $self->meta->version;
+    $self->pathname;
 }
 
 1;
diff --git a/lib/Carton/Doc/List.pod b/lib/Carton/Doc/List.pod
index 8c0f36e..262a863 100644
--- a/lib/Carton/Doc/List.pod
+++ b/lib/Carton/Doc/List.pod
@@ -11,3 +11,13 @@ Carton::Doc::List - List dependencies tracked in the carton.lock file
 List the dependencies and version information tracked in the
 I<carton.lock> file. This command by default displays the name of the
 distribution (e.g. I<Foo-Bar-0.01>) in a flat list.
+
+=head1 OPTIONS
+
+=over 4
+
+=item --distfile
+
+Displays the list of distributions in a distfile format (i.e. C<AUTHOR/Dist-1.23.tar.gz>)
+
+=back
diff --git a/lib/Carton/Lock.pm b/lib/Carton/Lock.pm
index c9ce2b9..192800d 100644
--- a/lib/Carton/Lock.pm
+++ b/lib/Carton/Lock.pm
@@ -27,8 +27,7 @@ sub write {
 }
 
 sub dependencies {
-    map Carton::Dependency->new(meta => $_->{mymeta}),
-      values %{$_[0]->modules}
+    map Carton::Dependency->new($_), values %{$_[0]->modules}
 }
 
 sub find {

-- 
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