Patch/Command/Sources.pm

filter: Statementstmt 43.3% 26 / 60 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 6 / 12 Podpod 0.0% 0 / 2 totaltotal 31.3% 32 / 102 CC 13 SCAR 33.1
CC
13
Cov
31%
run
72.0
release_meta
12.0
__ANON__
6.0
CRAP 27.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.5.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 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/
Subroutine BEGIN: called CC=1 SCAR=0.0
16 signatures
17 postderef
18 1 /;
19  
20 option repository => (
21 is => 'rw',
22 isa => 'Bool',
23 default => 1,
24 0 ▶ trigger => sub ($self) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 => (
33 is => 'rw',
34 isa => 'Bool',
35 default => 1,
36 0 ▶ trigger => sub ($self) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 => (
45 is => 'rw',
46 isa => 'Bool',
47 default => 0,
48 0 ▶ trigger => sub ($self) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 0 ▶sub release_meta ($self, $thingy) {
Subroutine release_meta: not called CC=3 SCAR=24.8
Pod undocumented
62 0 require MetaCPAN::Client;
63 0 my $mcpan = MetaCPAN::Client->new;
64  
65 0 eval { $mcpan->release( $mcpan->module($thingy)->distribution ) }
66 0 ▶ || eval { $mcpan->release( $thingy ) }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $mcpan->release($mcpan->module($thingy)->distribution) } } or eval { do { $mcpan->release($thingy) } } or die "could not find release for '${thingy}' on metacpan\n" 0 0 0
Condition0%0/3
eval { do { $mcpan->release($mcpan->module($thingy)->distribution) } } or eval { do { $mcpan->release($thingy) } }
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $mcpan->release($mcpan->module($thingy)->distribution) } } or eval { do { $mcpan->release($thingy) } }
eval { do { $mcpan->release($mcpan->module($thingy)->distribution) } } eval { do { $mcpan->release($thingy) } }
Truth table0%0/3
A or B
A= eval { do { $mcpan->release($mcpan->module($thingy)->distribution) } }B= eval { do { $mcpan->release($thingy) } }
ABresult
1X1
011
000
67 || die "could not find release for '$thingy' on metacpan\n";
68 }
69  
70 0 ▶sub run ($self) {
Subroutine run: not called CC=8 SCAR=42.8
Pod undocumented
71 0 ▶ if ( $self->backpan ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->backpan) 0 0 0
72 0 say "backpan:";
73  
74 0 require MetaCPAN::Client;
75 0 my $mcpan = MetaCPAN::Client->new;
76  
77 0 my $releases = $mcpan->release(
78 { distribution => $self->thingy },
79 { sort => [{ date => { order => 'asc' } }] },
80 );
81  
82 0 ▶ if (!$releases->total) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($releases->total) 0 0 0
83 0 die "could not find releases for '$self->thingy' on metacpan\n";
84 }
85  
86 0 ▶ while (my $release = $releases->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $release = $releases->next) 0 0 0
87 0 say " - ", $release->download_url;
88 }
89  
90 0 return;
91 }
92  
93 0 my $meta = $self->release_meta($self->thingy);
94  
95 0 ▶ if ( $self->repository and $meta->resources->{repository} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->repository and $meta->resources->{"repository"}) 0 0 0
Condition0%0/3
$self->repository and $meta->resources->{"repository"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->repository and $meta->resources->{"repository"}
$self->repository $meta->resources->{"repository"}
Truth table0%0/3
A and B
A= $self->repositoryB= $meta->resources->{"repository"}
ABresult
0X0
100
111
96 0 say "vcs:";
97 0 ▶ mapp { say " $a: $b" } %{ $meta->resources->{repository} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 }
99 0 ▶ if ( $self->cpan ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cpan) 0 0 0
100 0 say "cpan:";
101 0 for ( qw/ download_url / ) {
102 0 say " $_: ", $meta->$_;
103 }
104 }
105  
106 }
107  
108  
109 1 __PACKAGE__->meta->make_immutable;
110  
111 1 1;
112  
113 =pod
114  
115 =encoding UTF-8
116  
117 =head1 NAME
118  
119 Git::CPAN::Patch::Command::Sources - lists sources for the module
120  
121 =head1 VERSION
122  
123 version 2.5.2
124  
125 =head1 SYNOPSIS
126  
127 % git-cpan sources Foo::Bar
128  
129 =head1 AUTHOR
130  
131 Yanick Champoux <yanick@cpan.org>
132  
133 =head1 COPYRIGHT AND LICENSE
134  
135 This software is copyright (c) 2026, 2014, 2010, 2009 by Yanick Champoux.
136  
137 This is free software; you can redistribute it and/or modify it under
138 the same terms as the Perl 5 programming language system itself.
139  
140 =cut
141  
142 __END__
« Patch/Import.pm ↑ Summary Patch/Command/Import.pm »