lib/Module/Provision/TraitFor/UpdatingContent.pm

filter: Statementstmt 37.2% 19 / 51 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 41.6% 5 / 12 Podpod 100% 5 / 5 totaltotal 31.5% 29 / 92 CC 12 SCAR 27.5
CC
12
Cov
27%
update_copyright_year
30.0
update_version
30.0
update_version_pre_hook
12.0
CRAP 15.6
« lib/Module/Provision/TraitFor/VCS.pm ↑ Summary lib/Module/Provision/Base.pm »
1 package Module::Provision::TraitFor::UpdatingContent;
2  
3 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Class::Usul::Constants qw( EXCEPTION_CLASS OK );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Class::Usul::Functions qw( throw );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Unexpected::Functions qw( Unspecified );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 requires qw( appldir loc manifest_paths next_argv output );
11  
12 # Private methods
13 0 ▶my $_get_ignore_rev_regex = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
14 0 my $self = shift;
15  
16 0 my $ignore_rev = $self->appldir->catfile( '.gitignore-rev' )->chomp;
17  
18 0 ▶ return $ignore_rev->exists ? join '|', $ignore_rev->getlines : undef;
Branch: 1 branch
BranchTrueFalseTotal
$ignore_rev->exists ? : 0 0 0
19 1 };
20  
21 0 ▶my $_get_update_args = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 return ($_[ 0 ]->next_argv, $_[ 0 ]->next_argv);
23 1 };
24  
25 # Public methods
26 0 ▶sub substitute_version {
Subroutine substitute_version: not called CC=1 SCAR=6.9
Pod documented
27 0 my ($self, $path, $from, $to) = @_;
28  
29 0 $path->substitute( "\Q\'${from}.%d\',\E", "\'${to}.%d\'," );
30 0 $path->substitute( "\Q v${from}.\$Rev\E", " v${to}.\$Rev" );
31 0 return;
32 }
33  
34 0 ▶sub update_copyright_year : method {
Subroutine update_copyright_year: not called CC=5 SCAR=34.0
Pod documented
35 0 my $self = shift; my ($from, $to) = $self->$_get_update_args;
36  
37 0 my $prefix = $self->loc( 'Copyright (c)' );
38  
39 0 ▶ $from or throw Unspecified, [ 'from' ];
Branch: 1 branch
BranchTrueFalseTotal
$from or &throw(Unspecified(), ["from"]) 0 0 0
40 0 ▶ $to or throw Unspecified, [ 'to' ];
Branch: 1 branch
BranchTrueFalseTotal
$to or &throw(Unspecified(), ["to"]) 0 0 0
41 0 ▶ $self->quiet or $self->output( 'Updating copyright year' );
Branch: 1 branch
BranchTrueFalseTotal
$self->quiet or $self->output("Updating copyright year") 0 0 0
42  
43 0 for my $path (@{ $self->manifest_paths }) {
44 0 $path->substitute( "\Q${prefix} ${from}\E", "${prefix} ${to}" );
45 }
46  
47 0 return OK;
48 }
49  
50 0 ▶sub update_version : method {
Subroutine update_version: not called CC=5 SCAR=34.0
Pod documented
51 0 my $self = shift; my ($from, $to) = $self->$_get_update_args;
52  
53 0 my $ignore = $self->$_get_ignore_rev_regex;
54  
55 0 ▶ $self->quiet or $self->output( 'Updating version numbers' );
Branch: 1 branch
BranchTrueFalseTotal
$self->quiet or $self->output("Updating version numbers") 0 0 0
56  
57 0 ($from, $to) = $self->update_version_pre_hook( $from, $to );
58  
59 0 for my $path (@{ $self->manifest_paths }) {
60 0 ▶ $ignore and $path =~ m{ (?: $ignore ) }mx and next;
Branch: 1 branch
BranchTrueFalseTotal
$ignore and $path =~ / (?: $ignore ) /mx and next 0 0 0
Condition0%0/3
$ignore and $path =~ / (?: $ignore ) /mx
!ll&&!rl&&r
000
MC/DC0%0/2
$ignore and $path =~ / (?: $ignore ) /mx
$ignore $path =~ / (?: $ignore ) /mx
Truth table0%0/3
A and B
A= $ignoreB= $path =~ / (?: $ignore ) /mx
ABresult
0X0
100
111
61 0 $self->substitute_version( $path, $from, $to );
62 }
63  
64 0 $self->update_version_post_hook( $from, $to );
65 0 return OK;
66 }
67  
68 0 ▶sub update_version_post_hook { # Can be modified by applied traits
Subroutine update_version_post_hook: not called CC=1 SCAR=0.0
Pod documented
69 }
70  
71 0 ▶sub update_version_pre_hook { # Can be modified by applied traits
Subroutine update_version_pre_hook: not called CC=3 SCAR=24.8
Pod documented
72 0 my ($self, @args) = @_;
73  
74 0 ▶ ($args[ 0 ] and $args[ 1 ]) or throw 'Insufficient arguments';
Branch: 1 branch
BranchTrueFalseTotal
$args[0] and $args[1] or &throw("Insufficient arguments") 0 0 0
Condition0%0/3
$args[0] and $args[1]
!ll&&!rl&&r
000
MC/DC0%0/2
$args[0] and $args[1]
$args[0] $args[1]
Truth table0%0/3
A and B
A= $args[0]B= $args[1]
ABresult
0X0
100
111
75  
76 0 return @args;
77 }
78  
79 1 1;
80  
81 __END__
« lib/Module/Provision/TraitFor/VCS.pm ↑ Summary lib/Module/Provision/Base.pm »