Patch/Command/Sources.pm

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