Maker/Config.pm

filter: Statementstmt 96.5% 56 / 58 Branchbran 62.5% 5 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 92.8% 13 / 14 Podpod 0.0% 0 / 4 totaltotal 86.5% 77 / 89 CC 6 SCAR 8.0
CC
6
Cov
91%
read
5.0
new
2.0
meta
2.0
CRAP 2.2
« Maker/Path/Meta.pm ↑ Summary Maker/Schema.pm »
1 package Config::Maker::Config;
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  
7 9 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶use Parse::RecDescent;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 ▶use Config::Maker;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 ▶use Config::Maker::Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 9 ▶use Config::Maker::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 ▶use Config::Maker::Option::Meta;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 9 ▶use Config::Maker::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 9 our $parser = $Config::Maker::parser;
17  
18 # Now to the parser itself...
19  
20 94 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
21 94 my ($class, $root) = @_;
22  
23 94 ▶ unless(UNIVERSAL::isa($root, 'Config::Maker::Option')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($root, "Config::Maker::Option")) 94 0 94
24 # We didn't get a Config::Maker::Option, so let's assume we've got
25 # a filename
26 94 my $type = Config::Maker::Type->root;
27  
28 94 my $children = $class->read($root, $type);
29  
30 94 $root = $type->instantiate({ -children => $children });
31 }
32  
33 bless {
34 94 root => $root,
35 meta => Config::Maker::Option::Meta->new(
36 -type => Config::Maker::Type->meta()
37 ),
38 }, $class;
39 }
40  
41 98 ▶sub read {
Subroutine read: called CC=5 SCAR=16.2
Pod undocumented
42 98 my ($class, $file, $type) = @_;
43 98 my ($fh, $text);
44 98 my $enc = 'system';
45  
46 98 $file = Config::Maker::locate($file);
47  
48 98 ▶ open($fh, '<', $file)
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", $file or croak("Failed to open ${file}: $!") 98 0 98
49 or croak "Failed to open $file: $!";
50 {
51 98 local $/;
52 98 $text = <$fh>;
53 }
54 98 close $fh;
55  
56 98 ▶ if((substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m) ||
Branch: 1 branch
BranchTrueFalseTotal
if (substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m or substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m) 2 96 98
Condition66%2/3
substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m or substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m
l!l&&r!l&&!r
2096
MC/DC50%1/2
substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m or substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m
substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m
Truth table66%2/3
A or B
A= substr($text, 0, 250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/mB= substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m
ABresult
1X1
011
000
57 (substr($text, -250) =~ /^\s*#.*$Config::Maker::fenc([[:alnum:]_-]+)/m)) {
58 2 $enc = $1;
59 }
60 98 $text = decode($enc, $text);
61  
62 98 LOG("Loading configuration from $file using encoding $enc");
63 98 my $options = $parser->configuration($text, undef, $type);
64 98 ▶ croak "Configuration file $file contained errors"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options 0 98 98
65 unless defined $options;
66  
67 98 return $options;
68 }
69  
70 0 ▶sub meta {
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($self, $name) = @_;
72 0 $self->{meta}->get($name);
73 }
74  
75 135 ▶sub set_meta {
Subroutine set_meta: called CC=1 SCAR=0.0
Pod undocumented
76 135 my ($self, $name, $value) = @_;
77 135 $self->{meta}->set_child($name, $value);
78 }
79  
80 9 1;
81  
82 __END__
« Maker/Path/Meta.pm ↑ Summary Maker/Schema.pm »