Daiku.pm

filter: Statementstmt 60.9% 39 / 64 Branchbran 37.5% 6 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 64.2% 9 / 14 Podpod 85.7% 6 / 7 totaltotal 58.4% 62 / 106 CC 10 SCAR 17.6
CC
10
Cov
57%
file
20.0
rule
6.0
task
5.1
CRAP 5.8
« Daiku/Role.pm ↑ Summary Daiku/Daikufile.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings FATAL => 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Daiku;
5 4 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 our $VERSION = '1.004';
7 4 ▶use Daiku::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use IPC::System::Simple ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our @EXPORT = our @EXPORT_OK =
12 qw(desc task file rule sh namespace engine build);
13  
14 4 my %engine_for = ();
15  
16 9 ▶sub _engine {
Subroutine _engine: called CC=2 SCAR=7.1
17 9 my ($caller_package) = @_;
18 9 ▶ return ($engine_for{$caller_package} ||= Daiku::Registry->new());
Condition66%2/3
$engine_for{$caller_package} ||= "Daiku::Registry"->new
l!l&&r!l&&!r
720
MC/DC0%0/2
$engine_for{$caller_package} ||= "Daiku::Registry"->new
$engine_for{$caller_package} "Daiku::Registry"->new
Truth table66%2/3
A ||= B
A= $engine_for{$caller_package}B= "Daiku::Registry"->new
ABresult
1X1
011
000
19 }
20  
21 0 ▶sub engine {
Subroutine engine: not called CC=1 SCAR=6.9
Pod undocumented
22 0 return _engine(caller(0));
23 }
24  
25 0 ▶sub desc($) {
Subroutine desc: not called CC=1 SCAR=6.9
Pod documented
26 0 my $desc = shift;
27  
28 0 _engine(caller(0))->temporary_desc($desc);
29 }
30  
31 # task 'all' => ['a', 'b'];
32 # task 'all' => ['a', 'b'] => sub { ... };
33 7 ▶sub task($$;&) {
Subroutine task: called CC=5 SCAR=16.2
Pod documented
34 7 my %args;
35 7 $args{dst} = shift @_;
36 7 ▶ if (ref($_[-1]) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[-1] eq "CODE") 6 1 7
37 6 $args{code} = pop @_;
38 }
39 7 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 5 7
40 2 $args{deps} = shift @_;
41 2 ▶ $args{deps} = [$args{deps}] if !ref $args{deps};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"deps"} 0 2 2
42 }
43 7 my $engine = _engine(caller(0));
44 7 my $desc = $engine->clear_temporary_desc;
45 7 ▶ if (defined $desc) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $desc) 0 7 7
46 0 $args{desc} = $desc;
47 }
48 7 $args{dst} = join ':', @{ $engine->namespaces }, $args{dst};
49  
50 7 my $task = Daiku::Task->new( %args );
51 7 $engine->register($task);
52 }
53  
54 # file 'all' => ['a', 'b'];
55 # file 'all' => 'a';
56 # file 'all' => ['a', 'b'] => sub { ... };
57 0 ▶sub file($$;&) {
Subroutine file: not called CC=4 SCAR=30.0
Pod documented
58 0 my %args;
59 0 $args{dst} = shift @_;
60 0 ▶ if (ref($_[-1]) eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[-1] eq "CODE") 0 0 0
61 0 $args{code} = pop @_;
62 }
63 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
64 0 $args{deps} = shift @_;
65 0 ▶ $args{deps} = [$args{deps}] if !ref $args{deps};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args{"deps"} 0 0 0
66 }
67 0 my $file = Daiku::File->new( %args );
68 0 _engine(caller(0))->register($file);
69 }
70  
71 # rule '.c' => '.o' => sub { ... };
72 0 ▶sub rule($$;&) {
Subroutine rule: not called CC=2 SCAR=17.9
Pod documented
73 0 my %args;
74 0 @args{qw/dst src code/} = @_;
75 0 ▶ delete $args{code} unless defined $args{code};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"code"} 0 0 0
76 0 my $rule = Daiku::SuffixRule->new( %args );
77 0 _engine(caller(0))->register($rule);
78 }
79  
80 0 ▶sub namespace($$) {
Subroutine namespace: not called CC=1 SCAR=6.9
Pod documented
81 0 my ($namespace, $code) = @_;
82  
83 0 my $engine = _engine(caller(0));
84 0 push @{ $engine->namespaces }, $namespace;
85 0 $code->();
86 0 pop @{ $engine->namespaces };
87 }
88  
89 2 ▶sub build {
Subroutine build: called CC=1 SCAR=0.0
Pod documented
90 2 _engine(caller(0))->build(@_);
91 }
92  
93 4 *sh = *IPC::System::Simple::run;
94  
95  
96 4 1;
97 __END__
« Daiku/Role.pm ↑ Summary Daiku/Daikufile.pm »