lib/Perl/ToPerl6/OptionsProcessor.pm

filter: Statementstmt 100% 105 / 105 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 32 / 32 Podpod 100% 21 / 21 totaltotal 97.6% 163 / 167 CC 5 SCAR 2.9
CC
5
Cov
98%
_init
3.0
_check_for_extra_options
3.0
BEGIN
1.0
CRAP 1.3
« lib/Perl/ToPerl6/Exception/Configuration/Option.pm ↑ Summary lib/Perl/ToPerl6/Exception/Configuration/Option/Global/ExtraParameter.pm »
1 package Perl::ToPerl6::OptionsProcessor;
2  
3 17 ▶use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 17 ▶use Perl::ToPerl6::Exception::AggregateConfiguration;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 ▶use Perl::ToPerl6::Exception::Configuration::Option::Global::ExtraParameter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 17 ▶use Perl::ToPerl6::Utils qw<
Subroutine BEGIN: called CC=1 SCAR=0.0
12 :booleans :characters :severities :data_conversion $DEFAULT_VERBOSITY
13 17 >;
14 17 ▶use Perl::ToPerl6::Utils::Constants qw<
Subroutine BEGIN: called CC=1 SCAR=0.0
15 $PROFILE_STRICTNESS_DEFAULT
16 :color_necessity
17 17 >;
18 17 ▶use Perl::ToPerl6::Utils::DataConversion qw< dor >;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 #-----------------------------------------------------------------------------
21  
22 134 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
23 134 my ($class, %args) = @_;
24 134 my $self = bless {}, $class;
25 134 $self->_init( %args );
26 133 return $self;
27 }
28  
29 #-----------------------------------------------------------------------------
30  
31 134 ▶sub _init {
Subroutine _init: called CC=3 SCAR=11.0
32 134 my ( $self, %args ) = @_;
33  
34 # Multi-value defaults
35 134 my $exclude = dor(delete $args{exclude}, $EMPTY);
36 134 $self->{_exclude} = [ words_from_string( $exclude ) ];
37  
38 134 my $include = dor(delete $args{include}, $EMPTY);
39 134 $self->{_include} = [ words_from_string( $include ) ];
40  
41 134 my $program_extensions = dor(delete $args{'program-extensions'}, $EMPTY);
42 134 $self->{_program_extensions} = [ words_from_string( $program_extensions) ];
43  
44 # Single-value defaults
45 134 $self->{_force} = dor(delete $args{force}, $FALSE);
46 134 $self->{_in_place} = dor(delete $args{'in-place'}, $FALSE);
47 134 $self->{_only} = dor(delete $args{only}, $FALSE);
48 $self->{_profile_strictness} =
49 134 dor(delete $args{'profile-strictness'}, $PROFILE_STRICTNESS_DEFAULT);
50 134 $self->{_single_transformer} = dor(delete $args{'single-transformer'}, $EMPTY);
51 134 $self->{_necessity} = dor(delete $args{necessity}, $NECESSITY_HIGHEST);
52 134 $self->{_detail} = dor(delete $args{detail}, $NECESSITY_LOWEST + 1);
53 134 $self->{_theme} = dor(delete $args{theme}, $EMPTY);
54 134 $self->{_top} = dor(delete $args{top}, $FALSE);
55 134 $self->{_verbose} = dor(delete $args{verbose}, $DEFAULT_VERBOSITY);
56 134 $self->{_pager} = dor(delete $args{pager}, $EMPTY);
57  
58 $self->{_color_necessity_highest} = dor(
59 delete $args{'color-necessity-highest'},
60 delete $args{'colour-necessity-highest'},
61 delete $args{'color-necessity-5'},
62 134 delete $args{'colour-necessity-5'},
63 $PROFILE_COLOR_NECESSITY_HIGHEST_DEFAULT,
64 );
65 $self->{_color_necessity_high} = dor(
66 delete $args{'color-necessity-high'},
67 delete $args{'colour-necessity-high'},
68 delete $args{'color-necessity-4'},
69 134 delete $args{'colour-necessity-4'},
70 $PROFILE_COLOR_NECESSITY_HIGH_DEFAULT,
71 );
72 $self->{_color_necessity_medium} = dor(
73 delete $args{'color-necessity-medium'},
74 delete $args{'colour-necessity-medium'},
75 delete $args{'color-necessity-3'},
76 134 delete $args{'colour-necessity-3'},
77 $PROFILE_COLOR_NECESSITY_MEDIUM_DEFAULT,
78 );
79 $self->{_color_necessity_low} = dor(
80 delete $args{'color-necessity-low'},
81 delete $args{'colour-necessity-low'},
82 delete $args{'color-necessity-2'},
83 134 delete $args{'colour-necessity-2'},
84 $PROFILE_COLOR_NECESSITY_LOW_DEFAULT,
85 );
86 $self->{_color_necessity_lowest} = dor(
87 delete $args{'color-necessity-lowest'},
88 delete $args{'colour-necessity-lowest'},
89 delete $args{'color-necessity-1'},
90 134 delete $args{'colour-necessity-1'},
91 $PROFILE_COLOR_NECESSITY_LOWEST_DEFAULT,
92 );
93  
94 # If we're using a pager or not outputing to a tty don't use colors.
95 # Can't use IO::Interactive here because we /don't/ want to check STDIN.
96 134 ▶ my $default_color = ($self->pager() or not -t *STDOUT) ? $FALSE : $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$self->pager || !(-t *STDOUT) ? : 134 0 134
Condition66%2/3
$self->pager or not -t *STDOUT
l!l&&r!l&&!r
21320
MC/DC0%0/2
$self->pager or not -t *STDOUT
$self->pager not -t *STDOUT
Truth table66%2/3
A or not(B)
A= $self->pagerB= not -t *STDOUT
ABresult
1X1
011
000
97 134 $self->{_color} = dor(delete $args{color}, delete $args{colour}, $default_color);
98  
99 # If there's anything left, complain.
100 134 _check_for_extra_options(%args);
101  
102 133 return $self;
103 }
104  
105 #-----------------------------------------------------------------------------
106  
107 134 ▶sub _check_for_extra_options {
Subroutine _check_for_extra_options: called CC=3 SCAR=11.0
108 134 my %args = @_;
109  
110 134 ▶ if ( my @remaining = sort keys %args ){
Branch: 1 branch
BranchTrueFalseTotal
if (my(@remaining) = sort(keys %args)) 1 133 134
111 1 my $errors = Perl::ToPerl6::Exception::AggregateConfiguration->new();
112  
113 1 foreach my $option_name (@remaining) {
114 2 $errors->add_exception(
115 Perl::ToPerl6::Exception::Configuration::Option::Global::ExtraParameter->new(
116 option_name => $option_name,
117 )
118 )
119 }
120  
121 1 $errors->rethrow();
122 }
123  
124 133 return;
125 }
126  
127 #-----------------------------------------------------------------------------
128 # Public ACCESSOR methods
129  
130 56 ▶sub necessity {
Subroutine necessity: called CC=1 SCAR=0.0
Pod documented
131 56 my ($self) = @_;
132 56 return $self->{_necessity};
133 }
134  
135 #-----------------------------------------------------------------------------
136  
137 69 ▶sub theme {
Subroutine theme: called CC=1 SCAR=0.0
Pod documented
138 69 my ($self) = @_;
139 69 return $self->{_theme};
140 }
141  
142 #-----------------------------------------------------------------------------
143  
144 73 ▶sub exclude {
Subroutine exclude: called CC=1 SCAR=0.0
Pod documented
145 73 my ($self) = @_;
146 73 return $self->{_exclude};
147 }
148  
149 #-----------------------------------------------------------------------------
150  
151 73 ▶sub include {
Subroutine include: called CC=1 SCAR=0.0
Pod documented
152 73 my ($self) = @_;
153 73 return $self->{_include};
154 }
155  
156 #-----------------------------------------------------------------------------
157  
158 73 ▶sub in_place {
Subroutine in_place: called CC=1 SCAR=0.0
Pod documented
159 73 my ($self) = @_;
160 73 return $self->{_in_place};
161 }
162  
163 #-----------------------------------------------------------------------------
164  
165 73 ▶sub only {
Subroutine only: called CC=1 SCAR=0.0
Pod documented
166 73 my ($self) = @_;
167 73 return $self->{_only};
168 }
169  
170 #-----------------------------------------------------------------------------
171  
172 71 ▶sub profile_strictness {
Subroutine profile_strictness: called CC=1 SCAR=0.0
Pod documented
173 71 my ($self) = @_;
174 71 return $self->{_profile_strictness};
175 }
176  
177 #-----------------------------------------------------------------------------
178  
179 71 ▶sub single_transformer {
Subroutine single_transformer: called CC=1 SCAR=0.0
Pod documented
180 71 my ($self) = @_;
181 71 return $self->{_single_transformer};
182 }
183  
184 #-----------------------------------------------------------------------------
185  
186 73 ▶sub verbose {
Subroutine verbose: called CC=1 SCAR=0.0
Pod documented
187 73 my ($self) = @_;
188 73 return $self->{_verbose};
189 }
190  
191 #-----------------------------------------------------------------------------
192  
193 76 ▶sub color {
Subroutine color: called CC=1 SCAR=0.0
Pod documented
194 76 my ($self) = @_;
195 76 return $self->{_color};
196 }
197  
198 #-----------------------------------------------------------------------------
199  
200 207 ▶sub pager {
Subroutine pager: called CC=1 SCAR=0.0
Pod documented
201 207 my ($self) = @_;
202 207 return $self->{_pager};
203 }
204  
205 #-----------------------------------------------------------------------------
206  
207 73 ▶sub detail {
Subroutine detail: called CC=1 SCAR=0.0
Pod documented
208 73 my ($self) = @_;
209 73 return $self->{_detail};
210 }
211  
212 #-----------------------------------------------------------------------------
213  
214 73 ▶sub force {
Subroutine force: called CC=1 SCAR=0.0
Pod documented
215 73 my ($self) = @_;
216 73 return $self->{_force};
217 }
218  
219 #-----------------------------------------------------------------------------
220  
221 71 ▶sub top {
Subroutine top: called CC=1 SCAR=0.0
Pod documented
222 71 my ($self) = @_;
223 71 return $self->{_top};
224 }
225  
226 #-----------------------------------------------------------------------------
227  
228 76 ▶sub color_necessity_highest {
Subroutine color_necessity_highest: called CC=1 SCAR=0.0
Pod documented
229 76 my ($self) = @_;
230 76 return $self->{_color_necessity_highest};
231 }
232  
233 #-----------------------------------------------------------------------------
234  
235 76 ▶sub color_necessity_high {
Subroutine color_necessity_high: called CC=1 SCAR=0.0
Pod documented
236 76 my ($self) = @_;
237 76 return $self->{_color_necessity_high};
238 }
239  
240 #-----------------------------------------------------------------------------
241  
242 76 ▶sub color_necessity_medium {
Subroutine color_necessity_medium: called CC=1 SCAR=0.0
Pod documented
243 76 my ($self) = @_;
244 76 return $self->{_color_necessity_medium};
245 }
246  
247 #-----------------------------------------------------------------------------
248  
249 76 ▶sub color_necessity_low {
Subroutine color_necessity_low: called CC=1 SCAR=0.0
Pod documented
250 76 my ($self) = @_;
251 76 return $self->{_color_necessity_low};
252 }
253  
254 #-----------------------------------------------------------------------------
255  
256 76 ▶sub color_necessity_lowest {
Subroutine color_necessity_lowest: called CC=1 SCAR=0.0
Pod documented
257 76 my ($self) = @_;
258 76 return $self->{_color_necessity_lowest};
259 }
260  
261 #-----------------------------------------------------------------------------
262  
263 73 ▶sub program_extensions {
Subroutine program_extensions: called CC=1 SCAR=0.0
Pod documented
264 73 my ($self) = @_;
265 73 return $self->{_program_extensions};
266 }
267  
268 #-----------------------------------------------------------------------------
269  
270 17 1;
271  
272 __END__
« lib/Perl/ToPerl6/Exception/Configuration/Option.pm ↑ Summary lib/Perl/ToPerl6/Exception/Configuration/Option/Global/ExtraParameter.pm »