FindApp/Object/State/Group/Class.pm

filter: Statementstmt 95.2% 60 / 63 Branchbran 66.6% 4 / 6 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 94.7% 18 / 19 Podpod 100% 5 / 5 totaltotal 85.4% 88 / 103 CC 7 SCAR 6.3
CC
7
Cov
87%
class
6.0
copy
3.0
new
2.0
CRAP 1.9
« FindApp/Git.pm ↑ Summary FindApp/Utils/Foreign.pm »
1 package FindApp::Object::State::Group::Class;
2  
3 6 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use mro "c3";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 6 ▶use FindApp::Vars qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use FindApp::Utils qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 sibuse "State::Dirs";
12  
13 #################################################################
14  
15 sub dir_field ( _ ) ;
16 sub dir_fields ( ) ;
17 sub dir_types ( ) ;
18 sub field_map ( & @ ) ;
19 sub type_map ( & @ ) ;
20  
21 #################################################################
22  
23 92 ▶sub dir_types() {
Subroutine dir_types: called CC=1 SCAR=0.0
24 92 return qw(allowed wanted found);
25 }
26  
27 168 ▶sub dir_field(_) {
Subroutine dir_field: called CC=1 SCAR=0.0
28 168 my($type) = @_;
29 6 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
30 168 return sibpackage("State::\U$type")->();
31 }
32  
33 56 ▶sub type_map(&@) {
Subroutine type_map: called CC=1 SCAR=0.0
34 56 my $code = shift;
35 56 return map { &$code } +dir_types, @_;
36 }
37  
38 56 ▶sub dir_fields() {
Subroutine dir_fields: called CC=1 SCAR=0.0
39 56 my $fields = [ type_map{dir_field} ];
40 56 return @$fields;
41 }
42  
43 56 ▶sub field_map(&@) {
Subroutine field_map: called CC=1 SCAR=0.0
44 56 my $code = shift;
45 56 return map { &$code } +dir_fields, @_;
46 }
47  
48 6 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 0 ▶sub class { &ENTER_TRACE_2;
Subroutine class: not called CC=2 SCAR=17.9
Pod documented
51 0 my($self) = @_;
52 0 ▶ return blessed($self) || $self;
Condition0%0/3
&blessed($self) || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
&blessed($self) || $self
&blessed($self) $self
Truth table0%0/3
A || B
A= &blessed($self)B= $self
ABresult
1X1
011
000
53 }
54  
55 14 ▶sub object { &ENTER_TRACE_2;
Subroutine object: called CC=2 SCAR=7.0
Pod documented
56 14 my($self) = @_;
57 14 ▶ croak "not an object" unless blessed $self;
Branch: 1 branch
BranchTrueFalseTotal
unless &blessed($self) 0 14 14
58 14 return $self;
59 }
60  
61 56 ▶sub new { &ENTER_TRACE_2;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
62 56 good_args(@_ >= 2);
63 56 my($invocant, $name) = (shift, shift);
64 56 ▶ my $class = blessed($invocant) || $invocant;
Condition33%1/3
&blessed($invocant) || $invocant
l!l&&r!l&&!r
0560
MC/DC0%0/2
&blessed($invocant) || $invocant
&blessed($invocant) $invocant
Truth table33%1/3
A || B
A= &blessed($invocant)B= $invocant
ABresult
1X1
011
000
65 56 ▶ my %dirlists = field_map { $_ => sibpackage("State::Dirs")->new };
Subroutine __ANON__: called CC=1 SCAR=0.0
66 56 return bless(\%dirlists, $class)->params(
67 name => [$name],
68 unexported => [1],
69 @_,
70 );
71 }
72  
73 36 ▶sub copy { &ENTER_TRACE_2;
Subroutine copy: called CC=3 SCAR=11.0
Pod documented
74 36 good_args(@_ == 2);
75 36 my($new, $old) = @_;
76 36 my $name = $old->name;
77 36 ▶ $new->name eq $old->name || panic "name mismatch";
Branch: 1 branch
BranchTrueFalseTotal
$new->name eq $old->name or panic("name mismatch") 36 0 36
78 36 $new->exported($old->exported);
79 36 for my $field (dir_types()) {
80 108 $new->$field->copy($old->$field->object);
81 }
82 }
83  
84 56 ▶sub params { &ENTER_TRACE_2;
Subroutine params: called CC=2 SCAR=6.9
Pod documented
85 56 my($self, %inits) = @_;
86 56 ▶ while (my($method, $aref) = each %inits) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %inits) 112 56 168
87 112 $self->$method(@$aref);
88 }
89 56 return $self;
90 }
91  
92 6 1;
93  
94 =encoding utf8
95  
96 =head1 NAME
97  
98 FindApp::Object::State::Group::Object::Class - FIXME
99  
100 =head1 SYNOPSIS
101  
102 use FindApp::Object::State::Group::Object::Class;
103  
104 =head1 DESCRIPTION
105  
106 =head2 Public Methods
107  
108 =over
109  
110 =item class
111  
112 =item copy
113  
114 =item new
115  
116 =item object
117  
118 =item params
119  
120 =back
121  
122 =head2 Exports
123  
124 =over
125  
126 =item FIXME
127  
128 =back
129  
130 =head1 EXAMPLES
131  
132 =head1 ENVIRONMENT
133  
134 =head1 SEE ALSO
135  
136 =over
137  
138 =item L<FindApp>
139  
140 =back
141  
142 =head1 CAVEATS AND PROVISOS
143  
144 =head1 BUGS AND LIMITATIONS
145  
146 =head1 HISTORY
147  
148 =head1 AUTHOR
149  
150 Tom Christiansen << <tchrist@perl.com> >>
151  
152 =head1 LICENCE AND COPYRIGHT
153  
154 Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>.
155 All Rights Reserved.
156  
157 This module is free software; you can redistribute it and/or
158 modify it under the same terms as Perl itself. See L<perlartistic>.
159  
160 =cut
161  
« FindApp/Git.pm ↑ Summary FindApp/Utils/Foreign.pm »