Minilla/Release/UploadToCPAN.pm

filter: Statementstmt 78.7% 37 / 47 Branchbran 50.0% 12 / 24 Conditioncond 54.5% 6 / 11 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 66.3% 65 / 98 CC 17 SCAR 33.8
CC
17
Cov
67%
run
40.9
BEGIN
1.0
BEGIN
1.0
CRAP 29.2
« Minilla/Release/BumpVersion.pm ↑ Summary Minilla/CLI/New.pm »
1 package Minilla::Release::UploadToCPAN;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use ExtUtils::MakeMaker qw(prompt);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Minilla::Util qw(require_optional is_interactive);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Minilla::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
11 1 require_optional('CPAN/Uploader.pm',
12 'Release engineering');
13 }
14  
15 5 ▶sub run {
Subroutine run: called CC=17 SCAR=37.1
Pod undocumented
16 5 my ($self, $project, $opts) = @_;
17  
18 5 my $work_dir = $project->work_dir();
19 5 my $tar = $work_dir->dist;
20  
21 5 ▶ if ($opts->{dry_run} || $ENV{FAKE_RELEASE}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->{'dry_run'} or $ENV{'FAKE_RELEASE'}) { } 2 3 5
elsif ($project->config->{'release'}{'do_not_upload_to_cpan'}) { } 1 2 3
Condition100%3/3
$opts->{"dry_run"} or $ENV{"FAKE_RELEASE"}
l!l&&r!l&&!r
113
MC/DC100%2/2
$opts->{"dry_run"} or $ENV{"FAKE_RELEASE"}
$opts->{"dry_run"} $ENV{"FAKE_RELEASE"}
Truth table100%3/3
A or B
A= $opts->{"dry_run"}B= $ENV{"FAKE_RELEASE"}
ABresult
1X1
011
000
22 2 infof("Dry run. You don't need the module upload to CPAN\n");
23 } elsif ($project->config->{release}->{do_not_upload_to_cpan}) {
24 1 infof("You disabled CPAN uploading feature in minil.toml.\n");
25 } else {
26 2 ▶ unless (is_interactive()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (is_interactive()) 1 1 2
27 1 errorf("CPAN upload requires confirmation from a terminal. Use a terminal to release, or '--dry-run' to check the release without uploading.\n");
28 }
29 1 infof("Upload to CPAN\n");
30  
31 my $pause_config = ($opts->{pause_config}) ? $opts->{pause_config}
32 : ($project->config->{release}->{pause_config}) ? $project->config->{release}->{pause_config}
33 1 ▶ : undef;
Branch: 2 branches
BranchTrueFalseTotal
$opts->{'pause_config'} ? : 0 1 1
$project->config->{'release'}{'pause_config'} ? : 0 1 1
34 1 my $config = CPAN::Uploader->read_config_file($pause_config);
35 1 ▶ if (!$config || !$config->{user} || !$config->{password}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($config and $config->{"user"} and $config->{"password"}) 0 1 1
Condition33%2/6
$config and $config->{"user"} and $config->{"password"}
!ll&&!rl&&r
001
$config and $config->{"user"}
!ll&&!rl&&r
001
MC/DC0%0/3
$config and $config->{"user"} and $config->{"password"}
$config $config->{"user"} $config->{"password"}
Truth table25%1/4
A and B and C
A= $configB= $config->{"user"}C= $config->{"password"}
ABCresult
0XX0
10X0
1100
1111
36 0 die <<EOF
37  
38 Missing ~/.pause file or your ~/.pause file is wrong.
39 You should put ~/.pause file in following format.
40  
41 user {{YOUR_PAUSE_ID}}
42 password {{YOUR_PAUSE_PASSWORD}}
43  
44  
45 EOF
46 }
47  
48 1 PROMPT: while (1) {
49 1 ▶ my $answer = prompt("Release to " . ($config->{upload_uri} || 'CPAN') . ' ? [y/n] ');
Condition50%1/2
$config->{'upload_uri'} || 'CPAN'
l!l
01
MC/DC0%0/1
$config->{'upload_uri'} || 'CPAN'
$config->{'upload_uri'}
Truth table50%1/2
A
A= $config->{'upload_uri'}
Aresult
11
00
50 1 ▶ if ($answer =~ /y/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($answer =~ /y/i) { } 0 1 1
elsif ($answer =~ /n/i) { } 1 0 1
51 0 last PROMPT;
52 } elsif ($answer =~ /n/i) {
53 1 errorf("Giving up!\n");
54 } else {
55 0 redo PROMPT;
56 }
57 }
58  
59 0 ▶ if ($opts->{trial}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"trial"}) 0 0 0
60 0 my $orig_file = $tar;
61 0 ▶ $tar =~ s/\.(tar\.gz|tgz|tar.bz2|tbz|zip)$/-TRIAL.$1/
Branch: 1 branch
BranchTrueFalseTotal
$tar =~ s/\.(tar\.gz|tgz|tar.bz2|tbz|zip)$/-TRIAL.$1/ or die "Distfile doesn't match supported archive format: $orig_file" 0 0 0
62 or die "Distfile doesn't match supported archive format: $orig_file";
63 0 infof("renaming $orig_file -> $tar for TRIAL release\n");
64 0 ▶ rename $orig_file, $tar or errorf("Renaming $orig_file -> $tar failed: $!\n");
Branch: 1 branch
BranchTrueFalseTotal
rename $orig_file, $tar or errorf("Renaming $orig_file -> $tar failed: $!\n") 0 0 0
65 }
66  
67 0 my $uploader = CPAN::Uploader->new(+{
68 tar => $tar,
69 %$config
70 });
71 0 $uploader->upload_file($tar);
72 }
73  
74 3 ▶ unlink($tar) unless Minilla->debug;
Branch: 1 branch
BranchTrueFalseTotal
unless "Minilla"->debug 3 0 3
75 }
76  
77 2 1;
78  
« Minilla/Release/BumpVersion.pm ↑ Summary Minilla/CLI/New.pm »