Param/FileWorker.pm

filter: Statementstmt 100% 57 / 57 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 7 / 7 totaltotal 90.8% 79 / 87 CC 6 SCAR 9.4
CC
6
Cov
91%
store_file
5.3
init_with_args
2.0
BEGIN
1.0
CRAP 2.6
« Param.pm ↑ Summary
1 package Config::Param::FileWorker;
2  
3 2 ▶use Config::Param;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '4.000006'; # updated by release script
8 2 $VERSION = eval $VERSION;
9  
10 sub new
11 1 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
12 1 my $class = shift;
13 1 my $self = {};
14 1 bless $self, $class;
15 1 $self->{config} = shift;
16 1 $self->{config}{nofinals} = 1;
17 1 $self->{pardef} = shift;
18 1 $self->{pars} = Config::Param->new($self->{config},$self->{pardef});
19 1 $self->{defpars} = dclone($self->{pars}{param});
20 1 return $self;
21 }
22  
23 sub init_with_args
24 1 ▶{
Subroutine init_with_args: called CC=2 SCAR=6.9
Pod documented
25 1 my $self = shift;
26 1 my $args = shift;
27 1 ▶ $args = \@ARGV unless defined $args;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args 0 1 1
28 1 $self->{pars}->parse_args($args);
29 1 $self->{pars}->use_config_files();
30 1 $self->{pars}->apply_args();
31 1 my $good = (not @{$self->{pars}{errors}});
32 1 $self->{pars}{errors} = [];
33 1 return $good;
34 }
35  
36 sub store_defaults
37 1 ▶{
Subroutine store_defaults: called CC=1 SCAR=0.0
Pod documented
38 1 my $self = shift;
39 1 $self->{defpars} = dclone($self->{pars}{param});
40 }
41  
42 sub load_defaults
43 1 ▶{
Subroutine load_defaults: called CC=1 SCAR=0.0
Pod documented
44 1 my $self = shift;
45 1 $self->{pars}{param} = dclone($self->{defpars});
46 }
47  
48 sub param
49 7 ▶{
Subroutine param: called CC=1 SCAR=0.0
Pod documented
50 7 my $self = shift;
51 # Yes, it's a direct reference.
52 7 return $self->{pars}{param};
53 }
54  
55 sub load_file
56 1 ▶{
Subroutine load_file: called CC=1 SCAR=0.0
Pod documented
57 1 my $self = shift;
58 1 my $file = shift;
59 1 $self->{pars}->parse_file($file);
60 1 my $good = (not @{$self->{pars}{errors}});
61 1 $self->{pars}{errors} = [];
62 1 return $good;
63 }
64  
65 sub store_file
66 1 ▶{
Subroutine store_file: called CC=5 SCAR=16.7
Pod documented
67 1 my $self = shift;
68 1 my $file = shift;
69 1 ▶ $file = undef if defined $file and $file eq '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $file and $file eq "" 0 1 1
Condition33%1/3
defined $file and $file eq ""
!ll&&!rl&&r
010
MC/DC0%0/2
defined $file and $file eq ""
defined $file $file eq ""
Truth table33%1/3
A and B
A= defined $fileB= $file eq ""
ABresult
0X0
100
111
70 1 my $fh = \*STDOUT;
71 1 ▶ if(defined $file)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file) 1 0 1
72 {
73 1 $fh = IO::File->new();
74 1 ▶ $fh->open($file, '>') or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$fh->open($file, ">") or return 0 1 0 1
75 }
76 1 $self->{pars}->print_file($fh);
77 1 $fh->close();
78 1 my $good = (not @{$self->{pars}{errors}});
79 1 $self->{pars}{errors} = [];
80 1 return $good;
81 }
82  
83 2 1;
84  
85 __END__
« Param.pm ↑ Summary