Iller.pm

filter: Statementstmt 97.3% 74 / 76 Branchbran 88.8% 16 / 18 Conditioncond 55.5% 5 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 2 totaltotal 88.2% 113 / 128 CC 17 SCAR 17.8
CC
17
Cov
92%
parse
12.1
generate_files
6.6
__ANON__
2.0
CRAP 5.9
« Iller/DocType/Dist.pm ↑ Summary Iller/Plugin.pm »
1 4 ▶use 5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Dist::Iller;
6  
7 # ABSTRACT: A Dist::Zilla & Pod::Weaver preprocessor
8 4 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 4 our $VERSION = '0.1411';
10  
11 4 ▶use Dist::Iller::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Types::Standard qw/Map Str ConsumerOf/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Types::Path::Tiny qw/Path/;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 4 ▶use String::CamelCase qw/camelize/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Module::Load qw/load/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Safe::Isa qw/$_does/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use YAML::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use Dist::Iller::Prereq;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 has docs => (
23 is => 'ro',
24 isa => Map[Str, ConsumerOf['Dist::Iller::DocType'] ],
25 2 ▶ default => sub { +{ } },
Subroutine __ANON__: called CC=1 SCAR=0.0
26 4 traits => ['Hash'],
27 handles => {
28 set_doc => 'set',
29 get_doc => 'get',
30 doc_keys => 'keys',
31 doc_kv => 'kv',
32 },
33 );
34 4 has filepath => (
35 is => 'ro',
36 isa => Path,
37 default => 'iller.yaml',
38 coerce => 1,
39 );
40  
41 5 ▶sub parse {
Subroutine parse: called CC=12 SCAR=25.0
Pod undocumented
42 5 my $self = shift;
43 5 my $phase = shift;
44  
45 5 my $yaml = YAML::Tiny->read($self->filepath->stringify);
46  
47 DOCTYPE:
48 5 for my $document (sort { $a->{'doctype'} cmp $b->{'doctype'} } @{ $yaml }) {
49 19 my $doctype_class = sprintf 'Dist::Iller::DocType::%s', camelize($document->{'doctype'});
50 19 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
51 19 load $doctype_class;
52 }
53 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 0 croak "Can't load $doctype_class: $_";
55 19 };
56 19 ▶ next DOCTYPE if $doctype_class->phase ne $phase;
Branch: 1 branch
BranchTrueFalseTotal
if $doctype_class->phase ne $phase 12 7 19
57 7 $self->set_doc($document->{'doctype'}, $doctype_class->new(global => $self->get_doc('global'))->parse($document));
58 }
59 5 ▶ if($self->get_doc('dist')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_doc("dist")) 4 1 5
60 4 $self->get_doc('dist')->add_prereq(Dist::Iller::Prereq->new(
61 module => __PACKAGE__,
62 version => __PACKAGE__->VERSION,
63 phase => 'develop',
64 relation => 'suggests',
65 ));
66  
67 DOC:
68 4 for my $doc ($self->doc_kv) {
69 12 ▶ if($doc->[1]->$_does('Dist::Iller::Role::HasPlugins')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->[1]->$Dist::Iller::_does("Dist::Iller::Role::HasPlugins")) 8 4 12
70 8 $self->get_doc('dist')->add_plugins_as_prereqs($doc->[1]->packages_for_plugin, $doc->[1]->all_plugins);
71 }
72  
73 12 for my $included_config ($doc->[1]->all_included_configs) {
74 5 $self->get_doc('dist')->add_prereq(Dist::Iller::Prereq->new(
75 module => $included_config->[0],
76 version => $included_config->[1],
77 phase => 'develop',
78 relation => 'suggests',
79 ));
80 }
81  
82 12 ▶ next DOC if $doc->[0] eq 'dist';
Branch: 1 branch
BranchTrueFalseTotal
if $doc->[0] eq "dist" 4 8 12
83 8 ▶ next DOC if $doc->[0] eq 'cpanfile';
Branch: 1 branch
BranchTrueFalseTotal
if $doc->[0] eq "cpanfile" 1 7 8
84 7 ▶ if($doc->[1]->$_does('Dist::Iller::Role::HasPrereqs')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->[1]->$Dist::Iller::_does("Dist::Iller::Role::HasPrereqs")) 0 7 7
85 0 $self->get_doc('dist')->merge_prereqs($doc->[1]->all_prereqs);
86 }
87 }
88 }
89 5 ▶ if($self->get_doc('cpanfile') && $self->get_doc('dist')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_doc("cpanfile") and $self->get_doc("dist")) 1 4 5
Condition66%2/3
$self->get_doc("cpanfile") and $self->get_doc("dist")
!ll&&!rl&&r
401
MC/DC50%1/2
$self->get_doc("cpanfile") and $self->get_doc("dist")
$self->get_doc("cpanfile") $self->get_doc("dist")
Truth table66%2/3
A and B
A= $self->get_doc("cpanfile")B= $self->get_doc("dist")
ABresult
0X0
100
111
90 1 $self->get_doc('cpanfile')->merge_prereqs($self->get_doc('dist')->all_prereqs);
91 }
92 }
93  
94 4 ▶sub generate_files {
Subroutine generate_files: called CC=6 SCAR=18.8
Pod undocumented
95 4 my $self = shift;
96 4 my $phase = shift;
97  
98 4 ▶ croak q{'phase' must be either 'before' or 'after'} if !defined $phase || $phase ne 'before' && $phase ne 'after';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $phase or $phase ne "before" and $phase ne "after" 0 4 4
Condition50%3/6
not defined $phase or $phase ne "before" and $phase ne "after"
l!l&&r!l&&!r
004
$phase ne "before" and $phase ne "after"
!ll&&!rl&&r
220
MC/DC0%0/3
not defined $phase or $phase ne "before" and $phase ne "after"
not defined $phase $phase ne "before" $phase ne "after"
Truth table50%2/4
not(A) or B and C
A= not defined $phaseB= $phase ne "before"C= $phase ne "after"
ABCresult
1XX1
0111
00X0
0100
99  
100 4 for my $doc ($self->doc_kv) {
101 12 ▶ next if $doc->[1]->phase ne $phase;
Branch: 1 branch
BranchTrueFalseTotal
if $doc->[1]->phase ne $phase 6 6 12
102 6 $doc->[1]->generate_file;
103 }
104 }
105  
106 4 __PACKAGE__->meta->make_immutable;
107  
108 4 1;
109  
110 __END__
« Iller/DocType/Dist.pm ↑ Summary Iller/Plugin.pm »