Iller/DocType/Gitignore.pm

filter: Statementstmt 100% 51 / 51 Branchbran 90.0% 9 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 4 totaltotal 91.5% 76 / 83 CC 11 SCAR 17.6
CC
11
Cov
97%
parse
11.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.8
« Iller/Plugin.pm ↑ Summary Iller/DocType/Weaver.pm »
1 2 ▶use 5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
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  
5 package Dist::Iller::DocType::Gitignore;
6  
7 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
8 # ABSTRACT: Turn the Dist::Iller config into a .gitignore file
9 2 our $VERSION = '0.1411';
10  
11 2 ▶use Dist::Iller::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Types::Standard qw/ArrayRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 with qw/
15 Dist::Iller::DocType
16 /;
17  
18 2 for my $setting (qw/always onexist/) {
19 has $setting => (
20 is => 'ro',
21 isa => ArrayRef[Str],
22 traits => ['Array'],
23 4 ▶ default => sub { [ ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 4 handles => {
25 "add_$setting" => 'push',
26 "all_$setting" => 'elements',
27 "get_$setting" => 'get',
28 "set_$setting" => 'set',
29 },
30 );
31 }
32  
33 4 ▶sub comment_start { '#' }
Subroutine comment_start: called CC=1 SCAR=0.0
Pod undocumented
34  
35 3 ▶sub filename { '.gitignore' }
Subroutine filename: called CC=1 SCAR=0.0
Pod undocumented
36  
37 4 ▶sub phase { 'after' }
Subroutine phase: called CC=1 SCAR=0.0
Pod undocumented
38  
39 1 ▶sub to_hash {
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
40 1 my $self = shift;
41 1 return { always => $self->always, onexist => $self->onexist };
42 }
43  
44 3 ▶sub parse {
Subroutine parse: called CC=11 SCAR=24.0
45 3 my $self = shift;
46 3 my $yaml = shift;
47  
48 3 ▶ if(exists $yaml->{'config'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $yaml->{"config"}) 1 2 3
49 # ugly hack..
50 1 $self->parse_config({ '+config' => $yaml->{'config'} });
51 }
52 3 ▶ if(exists $yaml->{'always'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $yaml->{"always"}) 3 0 3
53 3 $self->add_always($_) for @{ $yaml->{'always'} };
54 }
55 3 ▶ if(exists $yaml->{'onexist'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $yaml->{"onexist"}) 2 1 3
56 2 $self->add_onexist($_) for grep { path($_)->exists } @{ $yaml->{'onexist'} };
57 }
58  
59 3 ▶ if ($self->global && $self->global->has_distribution_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->global and $self->global->has_distribution_name) 2 1 3
Condition66%2/3
$self->global and $self->global->has_distribution_name
!ll&&!rl&&r
102
MC/DC50%1/2
$self->global and $self->global->has_distribution_name
$self->global $self->global->has_distribution_name
Truth table66%2/3
A and B
A= $self->globalB= $self->global->has_distribution_name
ABresult
0X0
100
111
60 2 for my $type (qw/always onexist/) {
61 4 my $all = "all_$type";
62 4 my $get = "get_$type";
63 4 my $set = "set_$type";
64 4 for my $index (0.. scalar $self->$all - 1) {
65 5 my $item = $self->$get($index);
66 5 ▶ $self->$set($index, '/'.$self->global->distribution_name.'-*') if $item eq '$self.distribution_name';
Branch: 1 branch
BranchTrueFalseTotal
if $item eq "\$self.distribution_name" 1 4 5
67 }
68 }
69 }
70 }
71  
72 1 ▶sub to_string {
Subroutine to_string: called CC=1 SCAR=0.0
73 1 my $self = shift;
74  
75 1 return join "\n", ($self->all_always, $self->all_onexist, '');
76 }
77  
78 2 __PACKAGE__->meta->make_immutable;
79  
80 2 1;
81  
82 __END__
« Iller/Plugin.pm ↑ Summary Iller/DocType/Weaver.pm »