Pad/Config/Format/Yaml.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 51 / 51 CC 2 SCAR 1.8
CC
2
Cov
100%
parse
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Pad/Error.pm ↑ Summary Pad/Type/Dir.pm »
1 5 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 5 ▶use Getopt::Pad::Config::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 class Getopt::Pad::Config::Format::Yaml :isa(Getopt::Pad::Config::Format) :strict(params) {
7 5 ▶ use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶ use Feature::Compat::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶ use Getopt::Pad::Util qw(specError);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '0.06';
12  
13 5 ▶ use constant NAMES => ['yaml', 'yml'];
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # A missing YAML::XS is an installation problem for the programmer:
16 # report it when the spec is built, not when the first file is read.
17 ADJUST {
18 try { require YAML::XS }
19 catch ($error) { specError("config format 'yaml' requires the YAML::XS module") }
20 }
21  
22 # YAML::XS speaks UTF-8 octets on both sides while the Format seam
23 # speaks text, so the translation happens here and nowhere else.
24 47 ▶ method parse($text) {
Subroutine parse: called CC=2 SCAR=6.9
Pod documented
25 # A config file is data: a !!perl/... tag never blesses anything,
26 # whatever the installed YAML::XS defaults to.
27 47 local $YAML::XS::LoadBlessed = 0;
28 47 my @documents = YAML::XS::Load(Encode::encode('UTF-8', $text));
29  
30 # A file without a document, empty or holding only comments, sets
31 # nothing. Of several documents the last one counts.
32 47 ▶ return @documents ? $documents[-1] : {};
Branch: 1 branch
BranchTrueFalseTotal
@documents ? : 45 2 47
33 5 }
34  
35 5 ▶ method dump($data) {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
36 5 return Encode::decode('UTF-8', YAML::XS::Dump($data));
37 5 }
38 }
39  
40 5 1;
41  
42 __END__
« Pad/Error.pm ↑ Summary Pad/Type/Dir.pm »