Configure.pm

filter: Statementstmt 51.3% 112 / 218 Branchbran 38.0% 38 / 100 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 86.9% 20 / 23 Podpod 100% 8 / 8 totaltotal 50.1% 178 / 355 CC 66 SCAR 39.8
CC
66
Cov
47%
process_interactive
182.0
validate_type
110.0
show_help
56.0
CRAP 53.7
↑ Summary Base/Devel.pm »
1 package Package::Configure;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use SelfLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Text::ParseWords;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Text::Wrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #can't use it here b/c it may not be installed when Package-Tools is
13 #installed, so we require it later.
14 #use Config::IniFiles;
15  
16 1 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use constant CACHE => 'pkg_config.cache';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant TEMPLATE => 'pkg_config.in';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 =head1 SYNOPSIS
22  
23 my $config = Package::Configure->new();
24 my $value1 = $config->setting1(); #get
25 $config->setting1('a new value for setting 1'); #set
26  
27 =head1 DESCRIPTION
28  
29 Package::Configure - Access package configuration values
30 from command-line options (Getopt::Long style), previously specified
31 cached settings, or default values. This package is a kindred spirit to
32 the GNU automake and autoconf tools.
33  
34 When a Package::Configure object is instantiated, the following
35 happens:
36  
37 1. A. If F<pkg_config.cache> exists, load it into L</ini()> accessor as a
38 Config::IniFiles object.
39 B. Otherwise, if F<pkg_config.in> exists, load that.
40 C. Otherwise, load nothing.
41  
42 2. If a configuration file was loaded, process commandline arguments
43 Using Getopt::Long, overriding configuration setings with those provided
44 from Getopt::Long.
45  
46 3. A. If C<--help> was given as a Makefile.PL argument, render the configuration
47 as a usage document to STDOUT and exit(0).
48  
49 -otherwise-
50  
51 B. If a configuration file was loaded, and C<--interactive> was given as a
52 Makefile.PL argument, query the user on STDOUT/STDIN for new configuration
53 values.
54  
55 4. Variable values may also be accessed using C<$config-E<gt>my_setting_name()>
56 to get the current value, or C<$config-E<gt>my_setting_name('a new value')> to
57 update the value of the variable.
58  
59 5. When the object is destroyed (by falling out of scope, being undefined, etc),
60 the current state of the object is written to F<pkg_config.cache>.
61  
62 =head1 CONFIGURATION FILES pkg_config.in AND pkg_config.cache
63  
64 The configuration files are in INI format, and are parsed using Config::IniFiles.
65 You should be familiar with the INI format and L<Config::IniFiles>.
66  
67 =head2 RESERVED VARIABLES
68  
69 These variables have a built-in function and are reserved for use by
70 Package::Configure.
71  
72 * help
73 * interactive
74  
75 Run C<Makefile.PL --help> for a display of what parameters are available, and
76 C<Makefile.PL --interactive> for an interactive query for values of said
77 parameters.
78  
79 =head2 DECLARING CONFIGURATION VARIABLES
80  
81 Package::Configure recognizes variables in the following INI sections:
82  
83 for single value parameters:
84  
85 * [option integer]
86 * [option float]
87 * [option string]
88 * [option dir]
89 * [option file]
90  
91 for multi value parameters:
92  
93 * [option integers]
94 * [option floats]
95 * [option strings]
96 * [option dirs]
97 * [option files]
98  
99 Comments on sections/parameters are recognized and displayed when F<Makefile.PL> is
100 run with the C<--help> option.
101  
102 Typechecking is performed on the integer, float, dir, and file sections, see
103 L</validate_type()>.
104  
105 for scripts:
106  
107 * [PL_FILES]
108 * [EXE_FILES]
109  
110 thes sections are special -- they are passed to ExtUtils::MakeMaker to
111 determine which scripts are processed at make-time (PL_FILES), and which are installed
112 (EXE_FILES). See L<ExtUtils::MakeMaker> for details on how that system works.
113  
114 =head2 SETTING VARIABLE VALUES
115  
116 See L<Config::IniFiles>
117  
118 Default values can be set in F<pkg_config.in>, as well as collected from the
119 command-line using Getopt::Long-style options, or with interactive question/answer.
120  
121 The Getopt::Long parameters available are created dynamically from the variable names
122 in F<pkg_config.in> or F<pkg_config.cache> (preferred if present).
123  
124 =head3 EDITING CONFIGURATION FILE
125  
126 See L<Config::IniFiles> for a description of the configuration file format.
127  
128 =head3 COMMAND-LINE OPTIONS
129  
130 For a script called F<script.pl>, valid executions of the script might be:
131  
132 C<script.pl --color red --number 9>
133  
134 C<script.pl>
135  
136 Argument names are identical to those in F<pkg_config.in> or F<pkg_config.cache>.
137  
138 =head3 INTERACTIVE QUERY
139  
140 A few runs of C<script.pl --interactive> might look like the following:
141  
142 [14:38]aday@asti:~/cvsroot/Package-Tools> /usr/bin/perl ./script.pl --interactive
143 color - what is your favorite color? (currently: "blue")? red
144 number - what is your favorite number? (currently: "2")? 9
145  
146 [14:38]aday@asti:~/cvsroot/Package-Tools> /usr/bin/perl ./script.pl --interactive
147 color - what is your favorite color? (currently: "red")? yellow
148 number - what is your favorite number? (currently: "9")? 8
149  
150 [14:38]aday@asti:~/cvsroot/Package-Tools> /usr/bin/perl ./script.pl --interactive --color 6 --number orange
151 Value "orange" invalid for option number (number expected)
152 color - what is your favorite color? (currently: "6")? orange
153 number - what is your favorite number? (currently: "8")? 6
154  
155 =head1 AUTHOR
156  
157 Allen Day, E<lt>allenday@ucla.eduE<gt>
158  
159 =cut
160  
161 =head1 METHODS
162  
163 =cut
164  
165 =head2 AUTOLOAD()
166  
167 FIXME internal method, undocumented
168  
169 =cut
170  
171 3 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=5 SCAR=16.4
172 3 my $self = shift;
173 3 my $val = shift;
174  
175 #return undef unless $self && $self->ini();
176  
177 3 my $symbol = $AUTOLOAD;
178 3 my $sub = $symbol;
179 3 $sub =~ s/^.+::([\w]+?)$/$1/;
180  
181 3 my $sect = undef;
182 3 my $i = 0;
183 3 foreach my $section ($self->ini()->Sections){
184 33 ▶ if(grep {$_ eq $sub} $self->ini()->Parameters($section)){
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $sub;} $self->ini->Parameters($section)) 3 30 33
185 3 $sect = $section;
186 3 $i++;
187 }
188  
189 }
190  
191 3 ▶ if($i == 0){
Branch: 2 branches
BranchTrueFalseTotal
if ($i == 0) { } 0 3 3
elsif ($i == 1) { } 3 0 3
192 0 die "no such parameter or method '$sub'";
193 } elsif($i == 1){
194 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
195  
196 7 ▶ *$symbol = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
197 7 my($self,@val) = @_;
198 7 ▶ if(@val){
Branch: 1 branch
BranchTrueFalseTotal
if (@val) { } 2 5 7
199 2 return $self->ini()->setval($sect,$sub,@val);
200 } else {
201 5 return $self->ini()->val($sect,$sub);
202 }
203 3 };
204  
205 3 return $self->$sub(@_);
206 } else {
207 0 warn "parameters in multiple ($i) sections named $sub, use
208 \$install->config->ini()->val('section',$sub)
209 \$install->config->ini()->setval('section,$sub,\@newvals)
210 for access";
211 0 return undef;
212 }
213  
214 0 return undef;
215 }
216  
217 =head2 new()
218  
219 Usage : $config = Package::Configure->new();
220 Function: constructs a new object, reads variables and their default/cached
221 values from state files F<pkg_config.in> and F<pkg_config.cache>.
222 Also handles command-line arguments by delegating to Getopt::Long.
223 Returns : a Package::Configure object
224 Args : none.
225  
226 =cut
227  
228 1 ▶sub new {
Subroutine new: called CC=7 SCAR=22.0
Pod documented
229 1 my($class,%arg) = @_;
230  
231 1 my $self = bless {}, $class;
232  
233 1 my $ini;
234  
235 1 ▶ if(!$arg{bootstrap}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($arg{"bootstrap"}) 1 0 1
236 1 require Config::IniFiles;
237 1 ▶ if (-f CACHE) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f 'pkg_config.cache') { } 0 1 1
elsif (-f 'pkg_config.in') { } 1 0 1
238 0 $ini = Config::IniFiles->new( -file => CACHE );
239 0 print STDERR colored("\rusing cached configuration values from ".CACHE,'cyan')."\n";
240 } elsif (-f TEMPLATE) {
241 1 $ini = Config::IniFiles->new( -file => TEMPLATE );
242 1 print STDERR colored("\rusing default configuration values from ".TEMPLATE,'cyan')."\n";
243 } else {
244 #no config file
245 0 $ini = Config::IniFiles->new();
246 }
247  
248 1 ▶ if(!$ini){
Branch: 1 branch
BranchTrueFalseTotal
unless ($ini) 0 1 1
249 0 print STDERR colored('config parse failed: '.join(' ',@Config::IniFiles::errors),'red')."\n";
250 0 exit(1);
251 }
252  
253 1 $self->ini($ini);
254  
255 #override defaults and cache with command-line args
256 1 $self->process_options();
257  
258 #query user interactively
259 1 ▶ $self->process_interactive() if $self->interactive();
Branch: 1 branch
BranchTrueFalseTotal
if $self->interactive 0 1 1
260  
261 #validate parameters
262 1 $self->validate_configuration();
263 }
264  
265 1 ▶ $self->ini()->WriteConfig(CACHE) if $self->ini();
Branch: 1 branch
BranchTrueFalseTotal
if $self->ini 1 0 1
266  
267 1 return $self;
268 }
269  
270 =head2 validate_type()
271  
272 Usage : $obj->validate_type('type','thing_to_check');
273 Function: attempts to validate a value as a particular type
274 valid values for argument 1 are: integer, float, string, dir, file.
275 Returns : 1 on success
276 Args : anonymous list:
277 argument 1: type to validate against
278 argument 2: value to validate
279  
280 =cut
281  
282 0 ▶sub validate_type {
Subroutine validate_type: not called CC=10 SCAR=47.0
Pod documented
283 0 my ($self,$type,$val) = @_;
284  
285 0 ▶ if($type eq 'integer') { return 1 if $val =~ /^-?\d+$/ }
Branch: 6 branches
BranchTrueFalseTotal
if ($type eq 'integer') { } 0 0 0
elsif ($type eq 'float') { } 0 0 0
elsif ($type eq 'string') { } 0 0 0
elsif ($type eq 'dir') { } 0 0 0
elsif ($type eq 'file') { } 0 0 0
if $val =~ /^-?\d+$/ 0 0 0
286 0 ▶ elsif($type eq 'float') { return 1 if $val =~ /^-?\d*\.?\d*$/ }
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^-?\d*\.?\d*$/ 0 0 0
287 0 elsif($type eq 'string') { return 1 }
288 0 ▶ elsif($type eq 'dir') { return 1 if -d $val }
Branch: 1 branch
BranchTrueFalseTotal
if -d $val 0 0 0
289 0 ▶ elsif($type eq 'file') { return 1 if -f $val }
Branch: 1 branch
BranchTrueFalseTotal
if -f $val 0 0 0
290  
291 0 return 0;
292 }
293  
294  
295 =head2 validate_configuration()
296  
297 Usage : $obj->validate_configuration();
298 Function: internal method. attempts to validate values
299 from the configuration file by calling L</validate_type()>
300 on each.
301 Returns : n/a
302 Args : none
303  
304 =cut
305  
306 1 ▶sub validate_configuration {
Subroutine validate_configuration: called CC=8 SCAR=38.6
Pod documented
307 1 my ($self) = @_;
308  
309 1 my $cfg = $self->ini;
310  
311 1 foreach my $section ( $cfg->GroupMembers('option') ) {
312 10 foreach my $param ($cfg->Parameters("option $section")){
313 0 my $die = 0;
314  
315 #single
316 0 ▶ if($section !~ /s$/){
Branch: 1 branch
BranchTrueFalseTotal
if (not $section =~ /s$/) { } 0 0 0
317 0 my $val = val("option $section",$param);
318 0 my $type = $section;
319 0 $type =~ s/option //;
320 0 ▶ $die++ unless $self->validate_type($type,$val);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->validate_type($type, $val) 0 0 0
321 }
322  
323 #plural
324 else {
325 0 my @val = val("option $section",$param);
326 0 foreach my $val (@val){
327 0 my $type = $section;
328 0 $type =~ s/option //;
329 0 $type =~ s/s$//;
330 0 ▶ $die++ unless $self->validate_type($type,$val);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->validate_type($type, $val) 0 0 0
331 }
332 }
333  
334 #did the param(s) validate?
335 0 ▶ if($die){
Branch: 1 branch
BranchTrueFalseTotal
if ($die) 0 0 0
336 0 $section =~ s/option //;
337 0 die "[option $section] $param: value is not a valid '$section'";
338 }
339 }
340 }
341 }
342  
343 =head2 process_interactive()
344  
345 Usage : $obj->process_interactive();
346 Function: iterates over [option *] and [EXE_FILES] sections from
347 configuration file and prompts user for new values. values
348 are validated using L</validate_type()> before being
349 accepted. lists of values are accepted and split using
350 L<Text::ParseWords::shellwords>
351 Returns : n/a
352 Args : none
353  
354 =cut
355  
356 0 ▶sub process_interactive {
Subroutine process_interactive: not called CC=13 SCAR=52.0
Pod documented
357 0 my ($self) = @_;
358  
359 0 my $ask = qq(\r%s [%s] - %s (currently: "%s")? );
360  
361 0 foreach my $section ( $self->ini()->Sections ){
362 0 ▶ next unless $section =~ /^option/;
Branch: 1 branch
BranchTrueFalseTotal
unless $section =~ /^option/ 0 0 0
363 0 foreach my $param ( $self->ini()->Parameters($section) ){
364 0 my $type = $section;
365 0 $type =~ s/^option //;
366  
367 0 my $comment = join('', map{s/^#//;$_} $self->ini()->GetParameterComment($section,$param));
368  
369 0 print sprintf($ask,
370 $param,
371 $type,
372 $comment,
373 $self->ini()->val($section,$param)
374 );
375 0 my $response = <>;
376 0 chomp $response;
377  
378 0 ▶ if($response eq ''){
Branch: 1 branch
BranchTrueFalseTotal
if ($response eq "") 0 0 0
379 0 print colored("\ryou didn't respond, skipping. this may break the build",'red')."\n";
380 0 next;
381 }
382  
383 0 my $valid = 1;
384 #single
385 0 ▶ if($type !~ /s$/){
Branch: 1 branch
BranchTrueFalseTotal
if (not $type =~ /s$/) { } 0 0 0
386 0 ▶ if(!$self->validate_type($type,$response)){
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->validate_type($type, $response)) { } 0 0 0
387 0 $valid = 0;
388 } else {
389 #commit it
390 0 $self->ini()->setval($section,$param,$response);
391 }
392 }
393 #plural
394 else {
395 0 $type =~ s/s$//;
396 0 my @response = shellwords($response);
397 0 foreach my $response (@response) {
398 0 ▶ if(!$self->validate_type($type,$response)){
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->validate_type($type, $response)) { } 0 0 0
399 0 $valid = 0;
400 0 last;
401 } else {
402 0 $self->ini()->setval($section,$param,@response);
403 }
404 }
405 0 ▶ if($valid == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($valid == 1) 0 0 0
406 #commit it
407 0 $self->ini()->setval($section,$param,@response);
408 }
409 }
410 0 ▶ if(!$valid){
Branch: 1 branch
BranchTrueFalseTotal
unless ($valid) 0 0 0
411 0 print colored("\rinvalid value(s), try again",'red')."\n";
412 0 redo;
413 }
414 }
415 }
416  
417 0 $ask = qq(\rinstall %s - %s [Y/n]? );
418  
419 0 foreach my $exe ( $self->ini()->Parameters('EXE_FILES') ){
420 0 my $target = $exe;
421  
422 0 $target =~ s/\.PLS?$//;
423  
424 0 my $comment = join('', map{s/^#//;$_} $self->ini()->GetParameterComment('EXE_FILES',$exe));
425  
426 0 print sprintf($ask,
427 $target,
428 $comment,
429 $self->ini()->val('EXE_FILES',$exe)
430 );
431 0 my $response = <>;
432 0 chomp $response;
433  
434 0 ▶ if($response !~ /^n/i){
Branch: 1 branch
BranchTrueFalseTotal
if (not $response =~ /^n/i) { } 0 0 0
435 0 $self->ini()->setval('EXE_FILES',$exe,'yes')
436 } else {
437 0 $self->ini()->setval('EXE_FILES',$exe,'no')
438 }
439 }
440 }
441  
442  
443 =head2 process_options()
444  
445 Usage : $config->process_options();
446 Function: Internal method that processes command-line options.
447  
448 =cut
449  
450 1 ▶sub process_options {
Subroutine process_options: called CC=18 SCAR=30.3
Pod documented
451 1 my $self = shift;
452  
453 1 my $cfg = $self->ini();
454  
455 1 my %slot = ();
456 1 my %sect = ();
457 1 my @protos = ();
458  
459 #hardcode in --help
460 1 $slot{help} = undef;
461 1 push @protos, 'help!';
462 1 $slot{interactive} = undef;
463 1 push @protos, 'interactive!';
464  
465 1 foreach my $section ($cfg->GroupMembers('option')) {
466 10 foreach my $param ($cfg->Parameters($section)) {
467 11 $sect{$param} = $section;
468 11 $slot{$param} = undef;
469  
470 #single
471 11 ▶ if($section eq 'option integer') { push @protos, "$param=i" }
Branch: 10 branches
BranchTrueFalseTotal
if ($section eq 'option integer') { } 2 9 11
elsif ($section eq 'option float') { } 1 8 9
elsif ($section eq 'option file') { } 1 7 8
elsif ($section eq 'option dir') { } 1 6 7
elsif ($section eq 'option string') { } 1 5 6
elsif ($section eq 'option integers') { } 1 4 5
elsif ($section eq 'option floats') { } 1 3 4
elsif ($section eq 'option files') { } 1 2 3
elsif ($section eq 'option dirs') { } 1 1 2
elsif ($section eq 'option strings') { } 1 0 1
472 1 elsif($section eq 'option float') { push @protos, "$param=f" }
473 1 elsif($section eq 'option file') { push @protos, "$param=s" }
474 1 elsif($section eq 'option dir') { push @protos, "$param=s" }
475 1 elsif($section eq 'option string') { push @protos, "$param=s" }
476  
477 #plural
478 1 elsif($section eq 'option integers'){ push @protos, "$param=i@" }
479 1 elsif($section eq 'option floats') { push @protos, "$param=f@" }
480 1 elsif($section eq 'option files') { push @protos, "$param=s@" }
481 1 elsif($section eq 'option dirs') { push @protos, "$param=s@" }
482 1 elsif($section eq 'option strings') { push @protos, "$param=s@" }
483 }
484 }
485  
486 1 GetOptions(\%slot,@protos);
487  
488 #if help requested, give it and bail out
489 1 ▶ if($slot{help}){
Branch: 1 branch
BranchTrueFalseTotal
if ($slot{"help"}) 0 1 1
490 0 $self->show_help();
491 0 exit 0;
492 }
493  
494 #if interactive requested, set a flag to do a query later
495 1 ▶ if($slot{interactive}){
Branch: 1 branch
BranchTrueFalseTotal
if ($slot{"interactive"}) 0 1 1
496 0 $self->interactive(1);
497 }
498  
499 #handle setteds
500 1 foreach my $k (keys %slot){
501 13 ▶ next unless defined($slot{$k});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $slot{$k} 13 0 13
502 0 ▶ if(ref($slot{$k}) eq 'ARRAY'){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $slot{$k} eq 'ARRAY') { } 0 0 0
503 0 $cfg->setval($sect{$k},$k,@{ $slot{$k} });
504 } else {
505 0 $cfg->setval($sect{$k},$k,$slot{$k});
506 }
507 }
508 }
509  
510 =head2 show_help()
511  
512 Usage : $obj->show_help();
513 Function: render configuration file sections/parameters with
514 descriptions to STDOUT. program exits and call does
515 not return.
516 Returns : exit code on program termination
517 Args : exits 0 (success)
518  
519 =cut
520  
521 0 ▶sub show_help {
Subroutine show_help: not called CC=7 SCAR=40.3
Pod documented
522 0 my ($self) = @_;
523  
524 0 my $i = 4;
525  
526 0 print "Usage: $0 [options]\n";
527 0 print "Available options, organized by section:\n\n";
528  
529 0 foreach my $section ($self->ini->Sections()){
530 0 ▶ next unless $section =~ /^option/;
Branch: 1 branch
BranchTrueFalseTotal
unless $section =~ /^option/ 0 0 0
531 0 ▶ next unless $self->ini->Parameters($section);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->ini->Parameters($section) 0 0 0
532  
533 0 my $comment = join(' ', map {s/^#+//; $_} $self->ini->GetSectionComment($section));
534 0 ▶ $comment ||= 'no description for this section';
Condition0%0/2
$comment ||= "no description for this section"
l!l
00
MC/DC0%0/1
$comment ||= "no description for this section"
$comment
Truth table0%0/2
A
A= $comment
Aresult
11
00
535 0 print( (' ' x $i)."[$section] $comment\n" );
536  
537 0 $i += 4;
538  
539 0 foreach my $param ($self->ini->Parameters($section)){
540 0 my $comment = join(' ', map {s/^#+//; $_} $self->ini->GetParameterComment($section,$param));
541 0 ▶ $comment ||= 'no description for this parameter';
Condition0%0/2
$comment ||= "no description for this parameter"
l!l
00
MC/DC0%0/1
$comment ||= "no description for this parameter"
$comment
Truth table0%0/2
A
A= $comment
Aresult
11
00
542 0 print( (' ' x $i).'--'.$param." : $comment\n" );
543 }
544  
545 0 $i -= 4;
546  
547 0 print "\n";
548 }
549 }
550  
551 =head2 ini()
552  
553 Usage : $obj->ini($newval)
554 Function: holds a Config::IniFiles instance
555 Returns : value of ini (a scalar)
556 Args : on set, new value (a scalar or undef, optional)
557  
558  
559 =cut
560  
561 50 ▶sub ini {
Subroutine ini: called CC=2 SCAR=6.9
Pod documented
562 50 my($self,$val) = @_;
563 50 ▶ $self->{'ini'} = $val if defined($val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 1 49 50
564 50 return $self->{'ini'};
565 }
566  
567 =head2 interactive()
568  
569 Usage : $obj->interactive($newval)
570 Function: flag for whether or not the user should be interactively
571 queried for configuration values.
572 Returns : value of interactive (a scalar)
573 Args : on set, new value (a scalar or undef, optional)
574  
575  
576 =cut
577  
578 1 ▶sub interactive {
Subroutine interactive: called CC=2 SCAR=7.1
Pod documented
579 1 my($self,$val) = @_;
580 1 ▶ $self->{'interactive'} = $val if defined($val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 1 1
581 1 return $self->{'interactive'};
582 }
583  
584 =head2 DESTROY()
585  
586 called when the object is destroyed. writes object's variables' states
587 to F<pkg_config.cache> to be read at next instantiation.
588  
589 =cut
590  
591 1 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.2
592 1 my $self = shift;
593 1 ▶ $self->ini->WriteConfig(CACHE) if $self->ini();
Branch: 1 branch
BranchTrueFalseTotal
if $self->ini 1 0 1
594 }
595  
596 1 1;
↑ Summary Base/Devel.pm »