Maker.pm

filter: Statementstmt 80.5% 83 / 103 Branchbran 45.2% 19 / 42 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 20 / 26 Podpod 0.0% 0 / 8 totaltotal 66.8% 123 / 184 CC 24 SCAR 16.3
CC
24
Cov
70%
BEGIN
12.2
exe
8.8
unquote_double
7.2
CRAP 5.1
« Maker/Metaconfig.pm ↑ Summary Maker/Encode.pm »
1 package Config::Maker;
2  
3 9 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use 5.006_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 9 ▶use Config::Maker::Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 9 require overload;
12  
13 # DEBUG
14 sub LOG;
15 sub DBG;
16 sub DUMP;
17  
18 9 ▶BEGIN {
Subroutine BEGIN: called CC=6 SCAR=25.0
19 9 ▶ if($::QUIET) {
Branch: 2 branches
BranchTrueFalseTotal
if ($main::QUIET) { } 9 0 9
elsif (not $main::VERBOSE) { } 0 0 0
20 9 ▶ *LOG = sub {};
Subroutine __ANON__: called CC=1 SCAR=0.0
21 9 ▶ *DBG = sub {};
Subroutine __ANON__: called CC=1 SCAR=0.0
22 } elsif(!$::VERBOSE) {
23 0 ▶ *LOG = sub { print STDERR @_, "\n"; };
Subroutine __ANON__: not called CC=1 SCAR=6.9
24 0 ▶ *DBG = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 } else { # VERBOSE
26 0 *LOG = \&Carp::carp;
27 0 *DBG = \&Carp::carp;
28 }
29  
30 9 ▶ if($::DEBUG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::DEBUG) { } 0 9 9
31 0 require Data::Dumper;
32 0 ▶ *DUMP = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 0 print STDERR '>' x 40, ' ', shift, "\n",
34 Data::Dumper::Dumper(@_),
35 '<' x 40, "\n";
36 }
37 0 } else {
38 9 ▶ *DUMP = sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
39 }
40  
41 9 ▶ LOG($::ENCODING_LOG) if $::ENCODING_LOG;
Branch: 1 branch
BranchTrueFalseTotal
if $main::ENCODING_LOG 0 9 9
42 9 ▶ if($::ENCODING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::ENCODING) { } 9 0 9
43 9 LOG("Selected $::ENCODING as system encoding");
44 } else {
45 0 LOG("Charset conversion not available!");
46 }
47 }
48 # /DEBUG
49  
50 9 ▶use Config::Maker::Value; # overloading...
Subroutine BEGIN: called CC=1 SCAR=0.0
51 9 ▶use Config::Maker::Grammar; # Build the parser...
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 9 our $parser = Config::Maker::Grammar->new();
54  
55 9 our $VERSION = '0.007';
56  
57 9 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 9 our @ISA = qw(Exporter);
59 9 our @EXPORT = qw(LOG DBG DUMP);
60  
61 # This must be after "constants"
62  
63 9 require Config::Maker::Config;
64 9 require Config::Maker::Driver;
65 9 require Config::Maker::Schema;
66 9 require Config::Maker::Metaconfig;
67 9 require Config::Maker::Eval;
68  
69 9 our $fenc = qr/(?:(?:(?:file)?en)coding|fenc)[:=]\s*/;
70  
71 0 ▶sub unbackslash {
Subroutine unbackslash: not called CC=1 SCAR=6.9
Pod undocumented
72 0 eval qq{"\\$_[0]"}
73 }
74  
75 0 ▶sub environment {
Subroutine environment: not called CC=2 SCAR=17.9
Pod undocumented
76 0 ▶ if(defined $ENV{$_[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{$_[0]}) { } 0 0 0
77 0 return $ENV{$_[0]};
78 } else {
79 0 warn "Undefined environment variable $_[0] used";
80 0 return '';
81 }
82 }
83  
84 239 ▶sub unquote_single {
Subroutine unquote_single: called CC=1 SCAR=0.0
Pod undocumented
85 239 local $_ = $_[0];
86 239 s/\A'//;
87 239 s/'\Z//;
88 239 s/\\'/'/g;
89 239 return $_;
90 }
91  
92 5 ▶sub unquote_double {
Subroutine unquote_double: called CC=4 SCAR=19.7
Pod undocumented
93 5 local $_ = $_[0];
94 5 s/\A"//;
95 5 s/"\Z//;
96 5 s/\\( # Backslashed stuff:
97 ["\$\\] # Things to escape
98 | [tnrfbae] # Simple escape codes
99 | x[[:xdigit:]]{2} # Hex-code
100 | x\{[[:xdigit:]]{1,8}\} # Wide hex-code
101 | [0-7]{1,3} # Octal-code
102 | c[@-_] # Control-char
103 | N\{\w*\} # Named char
104 ) |
105 \$ (\w+) | # Undelimited substitution
106 \$ \{ (\w+) \} # Delimited substitution
107 0 ▶ / $1 ? unbackslash($1) :
Branch: 3 branches
BranchTrueFalseTotal
$1 ? : 0 0 0
$2 ? : 0 0 0
$3 ? : 0 0 0
108 $2 ? environment($2) :
109 $3 ? environment($3) : die "This match does not work"/xe;
110 5 return $_;
111 }
112  
113 338 ▶sub truecmp {
Subroutine truecmp: called CC=2 SCAR=6.9
Pod undocumented
114 338 ▶ $_[2] ? overload::StrVal($_[1]) cmp overload::StrVal($_[0])
Branch: 1 branch
BranchTrueFalseTotal
$_[2] ? : 337 1 338
115 : overload::StrVal($_[0]) cmp overload::StrVal($_[1]);
116 }
117  
118 53 ▶sub limit {
Subroutine limit: called CC=4 SCAR=15.6
Pod undocumented
119 53 my ($num, $min, $max) = @_;
120 53 ▶ return undef if $num < $min;
Branch: 1 branch
BranchTrueFalseTotal
if $num < $min 0 53 53
121 53 ▶ return undef if $max && $num > $max;
Branch: 1 branch
BranchTrueFalseTotal
if $max and $num > $max 0 53 53
Condition33%1/3
$max and $num > $max
!ll&&!rl&&r
0530
MC/DC0%0/2
$max and $num > $max
$max $num > $max
Truth table33%1/3
A and B
A= $maxB= $num > $max
ABresult
0X0
100
111
122 53 return $num;
123 }
124  
125 # A non-catching eval...
126 32 ▶sub exe {
Subroutine exe: called CC=8 SCAR=21.8
Pod undocumented
127 9 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 9 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
129 32 ▶ DBG "Evaluating qq{$_[0]} in " . (wantarray ? "list" : (defined wantarray ? "scalar" : "void")) . " context";
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 18 14 32
defined wantarray ? : 14 0 14
130 32 ▶ if(wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 18 14 32
elsif (defined wantarray) { } 14 0 14
131 18 my @r = eval qq/package Config::Maker::Eval; $_[0]/;
132 18 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 2 16 18
133 16 return @r;
134 } elsif(defined wantarray) {
135 14 my $r = eval qq/package Config::Maker::Eval; $_[0]/;
136 14 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 14 14
137 14 return $r;
138 } else {
139 0 eval qq/package Config::Maker::Eval; $_[0]/;
140 0 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
141 }
142 }
143  
144 9 our @path = ('.');
145  
146 144 ▶sub locate {
Subroutine locate: called CC=4 SCAR=15.9
Pod undocumented
147 144 my ($file) = @_;
148 144 ▶ if(File::Spec->file_name_is_absolute($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($file)) { } 0 144 144
149 0 return $file;
150 } else {
151 144 for(@path) {
152 144 my $f = File::Spec->rel2abs($file, $_);
153 144 DBG "Trying: $f";
154 144 ▶ return $f if -r $f;
Branch: 1 branch
BranchTrueFalseTotal
if -r $f 144 0 144
155 }
156 0 local $" = ', ';
157 0 croak "Can't find $file in @path";
158 }
159 }
160  
161  
162 9 $::RD_HINT = 1;
163  
164 9 1;
165  
166 __END__
« Maker/Metaconfig.pm ↑ Summary Maker/Encode.pm »