Patch/Command/Sources.pm

filter: Statementstmt 42.2% 30 / 71 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 7 / 14 Podpod n/a totaltotal 33.3% 37 / 111 CC 13 SCAR 31.5
CC
13
Cov
32%
run
65.4
__ANON__
12.0
__ANON__
6.0
CRAP 23.3
« Patch/Import.pm ↑ Summary Patch/Command/Import.pm »
1 package Git::CPAN::Patch::Command::Sources;
2 1 our $AUTHORITY = 'cpan:YANICK';
3 #ABSTRACT: lists sources for the module
4 1 $Git::CPAN::Patch::Command::Sources::VERSION = '2.3.2';
5 1 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Method::Signatures::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use List::Pairwise qw/ mapp /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use MooseX::App::Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 with 'Git::CPAN::Patch::Role::Git';
15  
16 0 ▶option repository => (
Subroutine __ANON__: not called CC=2 SCAR=17.9
17 0 ▶ is => 'rw',
Branch: 1 branch
BranchTrueFalseTotal
unless $self->repository 0 0 0
18 0 isa => 'Bool',
19 0 default => 1,
20 trigger => method {
21 1 return unless $self->repository;
22 $self->set_cpan(0);
23 $self->set_backpan(0);
24 0 ▶ },
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 ▶ documentation => 'show repository information',
Branch: 1 branch
BranchTrueFalseTotal
unless $self->cpan 0 0 0
26 0 );
27 0  
28 option cpan => (
29 1 is => 'rw',
30 isa => 'Bool',
31 default => 1,
32 0 ▶ trigger => method {
Subroutine __ANON__: not called CC=2 SCAR=17.9
33 0 ▶ return unless $self->cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->backpan 0 0 0
34 0 $self->set_repository(0);
35 0 $self->set_backpan(0);
36 },
37 1 documentation => 'show cpan information',
38 );
39  
40 1 option backpan => (
41 is => 'rw',
42 isa => 'Bool',
43 default => 0,
44 trigger => method {
45 0 ▶ return unless $self->backpan;
Subroutine __ANON__: not called CC=3 SCAR=24.8
46 0 $self->set_repository(0);
47 0 $self->set_cpan(0);
48 },
49 0 documentation => 'show backpan information',
50 );
51  
52 parameter thingy => (
53 0 is => 'rw',
54 0 ▶ isa => 'Str',
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $mcpan->release("distribution", $mcpan->module($thingy)->{"distribution"}) } } or eval { do { $mcpan->release("distribution", $thingy) } } or die "could not find release for '${thingy}' on metacpan\n" 0 0 0
Condition0%0/3
eval { or eval {
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $mcpan->release("distribution", $mcpan->module($thingy)->{"distribution"}) } } or eval { do { $mcpan->release("distribution", $thingy) } }
eval { do { $mcpan->release("distribution", $mcpan->module($thingy)->{"distribution"}) } } eval { do { $mcpan->release("distribution", $thingy) } }
Truth table0%0/3
A or B
A= eval { do { $mcpan->release("distribution", $mcpan->module($thingy)->{"distribution"}) } }B= eval { do { $mcpan->release("distribution", $thingy) } }
ABresult
1X1
011
000
55 );
56  
57 1 has release_meta => (
58 is => 'ro',
59 lazy => 1,
60 default => method {
61 require MetaCPAN::API;
62 my $mcpan = MetaCPAN::API->new;
63 0 ▶ 
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 0 my $thingy = $self->thingy;
65  
66 1 eval { $mcpan->release(
67 distribution => $mcpan->module($thingy)->{distribution}
68 1 ▶ ) }
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine run: not called CC=8 SCAR=41.8
69 0 ▶ || eval { $mcpan->release( distribution => $thingy ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->repository and $self->release_meta->{"resources"}{"repository"}) 0 0 0
Condition0%0/3
$self->repository and $self->release_meta->{"resources"}{"repository"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->repository and $self->release_meta->{"resources"}{"repository"}
$self->repository $self->release_meta->{"resources"}{"repository"}
Truth table0%0/3
A and B
A= $self->repositoryB= $self->release_meta->{"resources"}{"repository"}
ABresult
0X0
100
111
70 0 || die "could not find release for '$thingy' on metacpan\n";
71 0 ▶ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
72 );
73  
74 0 ▶has backpan_index => (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cpan) 0 0 0
75 0 is => 'ro',
76 0 lazy => 1,
77 0 default => sub {
78 require BackPAN::Index;
79 return BackPAN::Index->new;
80 },
81 0 );
82 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($self->backpan) 0 0 0
83 0 method run {
84 0 ▶ if ( $self->repository and $self->release_meta->{resources}{repository} ) {
Branch: 1 branch
BranchTrueFalseTotal
my $dist = $self->backpan_index->dist($self->thingy) or die "could not find distribution on BackPAN\n" 0 0 0
85 say "vcs:";
86 mapp { say " $a: $b" } %{ $self->release_meta->{resources}{repository} };
87 }
88 0  
89 if ( $self->cpan ) {
90 1 say "cpan:";
91 for ( qw/ download_url / ) {
92 say " $_: ", $self->release_meta->{$_};
93 1 }
94 }
95 1  
96 my $BackPAN_URL = "http://backpan.perl.org/";
97 if ( $self->backpan ) {
98 say "backpan:";
99 my $dist = $self->backpan_index->dist($self->thingy)
100 or die "could not find distribution on BackPAN\n";
101  
102 say " - ", $BackPAN_URL . "/" . $_->prefix
103 for $dist->releases->search( undef, { order_by => "date" } )->all;
104 }
105 }
106  
107  
108 __PACKAGE__->meta->make_immutable;
109  
110 1;
111  
112 =pod
113  
114 =encoding UTF-8
115  
116 =head1 NAME
117  
118 Git::CPAN::Patch::Command::Sources - lists sources for the module
119  
120 =head1 VERSION
121  
122 version 2.3.2
123  
124 =head1 SYNOPSIS
125  
126 % git-cpan sources Foo::Bar
127  
128 =head1 AUTHOR
129  
130 Yanick Champoux <yanick@cpan.org>
131  
132 =head1 COPYRIGHT AND LICENSE
133  
134 This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009 by Yanick Champoux.
135  
136 This is free software; you can redistribute it and/or modify it under
137 the same terms as the Perl 5 programming language system itself.
138  
139 =cut
140  
141 __END__
142  
143  
144 use Moose;
145 use DateTime::Format::W3CDTF;
146  
147 extends 'MooseX::App::Cmd::Command';
148  
149 has '+app' => (
150 handles => [ qw/ set_target distribution_meta / ],
151 );
152  
153 sub execute {
154 my ( $self, $opts, $args ) = @_;
155  
156 die "usage: git-cpan sources <distribution>\n" unless $args->[0];
157  
158 $self->set_target( $args->[0] );
159 my $meta = $self->distribution_meta;
160  
161 if ( my $repo = $meta->{resources}{repository} ) {
162 say "Repository";
163 for ( qw/ type url web / ) {
164 say "\t$_: ", $repo->{$_} if $repo->{$_};
165 }
166 say "\n";
167 };
168  
169 say "CPAN";
170 my $date = DateTime::Format::W3CDTF->new->parse_datetime( $meta->{date} );
171 say "\tlatest release: ", $meta->{version}, " (", $date->ymd, ")";
172 say "\turl: ", $meta->{download_url};
173  
174  
175 }
176  
177  
178 1;
179  
« Patch/Import.pm ↑ Summary Patch/Command/Import.pm »