blib/lib/Zed/Config.pm

filter: Statementstmt 40.7% 11 / 27 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 3 totaltotal 35.0% 14 / 40 CC 2 SCAR 9.7
CC
2
Cov
38%
load
6.0
dump
2.0
_conf
2.0
CRAP 2.6
« blib/lib/Zed/Range/Set.pm ↑ Summary blib/lib/Zed/Plugin/Exe/Cmd.pm »
1 package Zed::Config;
2  
3 =head1 NAME
4  
5 Zed::Config - config base module.
6  
7 =head1 SYNOPSIS
8  
9 Foo->load;
10 Foo->config;
11 Foo->dump;
12  
13 package Foo;
14 use base Zed::Config;
15 our $NAME = "Foo";
16  
17  
18 =cut
19  
20 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use YAML::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Zed::Output;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 my %all_config;
26  
27 sub load
28 {
29 0 ▶ my ($class, $conf, $name ) = shift;
Subroutine load: not called CC=2 SCAR=17.9
Pod undocumented
30 0 $name = ${"$class\::NAME"};
31 0 debug("config name: $name");
32 0 $conf = _conf($name);
33  
34 0 debug("config file: $conf");
35 0 ▶ $conf = eval{YAML::XS::LoadFile $conf} || {};
Condition0%0/2
eval { do { YAML::XS::LoadFile($conf) } } || {}
l!l
00
MC/DC0%0/1
eval { do { YAML::XS::LoadFile($conf) } } || {}
eval { do { YAML::XS::LoadFile($conf) } }
Truth table0%0/2
A
A= eval { do { YAML::XS::LoadFile($conf) } }
Aresult
11
00
36 0 debug("config hash:", $conf);
37 0 $all_config{ $class } = $conf;
38 }
39  
40 sub dump
41 {
42 0 ▶ my ($class, $name) = shift;
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
43 0 $name = ${"$class\::NAME"};
44 0 YAML::XS::DumpFile( _conf($name), $all_config{$class} );
45 }
46 0 ▶sub _conf{ File::Spec->join( $ENV{ZED_HOME}, shift ) }
Subroutine _conf: not called CC=1 SCAR=6.9
47  
48 0 ▶sub config { $all_config{ $_[0] }; }
Subroutine config: not called CC=1 SCAR=6.9
Pod undocumented
49 1 1;
50  
« blib/lib/Zed/Range/Set.pm ↑ Summary blib/lib/Zed/Plugin/Exe/Cmd.pm »