| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 42 | 9 | ▶ | if($::ENCODING) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 121 | 53 | ▶ | return undef if $max && $num > $max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$max and $num > $max
MC/DC0%0/2
$max and $num > $max
$max
$num > $max
Truth table33%1/3
A and B
A= $maxB= $num > $max
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 130 | 32 | ▶ | if(wantarray) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 131 | 18 | my @r = eval qq/package Config::Maker::Eval; $_[0]/; | |||||||||||||||||||||||||||
| 132 | 18 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 137 | 14 | return $r; | |||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||
| 139 | 0 | eval qq/package Config::Maker::Eval; $_[0]/; | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||