lib/Perl/ToPerl6/TransformerParameter/Behavior/StringList.pm

filter: Statementstmt 75.0% 33 / 44 Branchbran 60.0% 6 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 69.5% 48 / 69 CC 7 SCAR 19.5
CC
7
Cov
68%
generate_parameter_description
20.0
__ANON__
3.0
initialize_parameter
2.0
CRAP 7.0
« lib/Perl/ToPerl6/Statistics.pm ↑ Summary lib/Perl/ToPerl6/TransformerFactory.pm »
1 package Perl::ToPerl6::TransformerParameter::Behavior::StringList;
2  
3 23 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 23 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 23 ▶use Perl::ToPerl6::Utils qw{ :characters &words_from_string &hashify };
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 23 ▶use base qw{ Perl::ToPerl6::TransformerParameter::Behavior };
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #-----------------------------------------------------------------------------
12  
13 3 ▶sub initialize_parameter {
Subroutine initialize_parameter: called CC=2 SCAR=6.9
Pod documented
14 3 my ($self, $parameter, $specification) = @_;
15  
16 # Unfortunately, this has to be kept as a reference, rather than a regular
17 # array, due to a problem in Devel::Cycle
18 # (http://rt.cpan.org/Ticket/Display.html?id=25360) which causes
19 # t/92_memory_leaks.t to fall over.
20 3 my $always_present_values = $specification->{list_always_present_values};
21 $parameter->_get_behavior_values()->{always_present_values} =
22 3 $always_present_values;
23  
24 3 ▶ if ( not $always_present_values ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($always_present_values) 2 1 3
25 2 $always_present_values = [];
26 }
27  
28 $parameter->_set_parser(
29 9 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
30 # Normally bad thing, obscuring a variable in a outer scope
31 # with a variable with the same name is being done here in
32 # order to remain consistent with the parser function interface.
33 9 my ($transformer, $parameter, $config_string) = @_;
34  
35 9 my @values = @{$always_present_values};
36 9 my $value_string = $parameter->get_default_string();
37  
38 9 ▶ if (defined $config_string) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $config_string) 6 3 9
39 6 $value_string = $config_string;
40 }
41  
42 9 ▶ if ( defined $value_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value_string) 8 1 9
43 8 push @values, words_from_string($value_string);
44 }
45  
46 9 my %values = hashify(@values);
47  
48 9 $transformer->__set_parameter_value($parameter, \%values);
49  
50 9 return;
51 }
52 3 );
53  
54 3 return;
55 }
56  
57 #-----------------------------------------------------------------------------
58  
59 0 ▶sub generate_parameter_description {
Subroutine generate_parameter_description: not called CC=4 SCAR=30.0
Pod documented
60 0 my ($self, $parameter) = @_;
61  
62 my $always_present_values =
63 0 $parameter->_get_behavior_values()->{always_present_values};
64  
65 0 my $description = $parameter->_get_description_with_trailing_period();
66 0 ▶ if ( $description and $always_present_values ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($description and $always_present_values) 0 0 0
Condition0%0/3
$description and $always_present_values
!ll&&!rl&&r
000
MC/DC0%0/2
$description and $always_present_values
$description $always_present_values
Truth table0%0/3
A and B
A= $descriptionB= $always_present_values
ABresult
0X0
100
111
67 0 $description .= qq{\n};
68 }
69  
70 0 ▶ if ( $always_present_values ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($always_present_values) 0 0 0
71 0 $description .= 'Values that are always included: ';
72 0 $description .= join ', ', sort @{ $always_present_values };
73 0 $description .= $PERIOD;
74 }
75  
76 0 return $description;
77 }
78  
79 23 1;
80  
81 __END__
« lib/Perl/ToPerl6/Statistics.pm ↑ Summary lib/Perl/ToPerl6/TransformerFactory.pm »