Configd/Syntax/Spaced.pm

filter: Statementstmt 47.0% 16 / 34 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 42.5% 23 / 54 CC 8 SCAR 28.2
CC
8
Cov
36%
emit
30.0
parse
20.0
BEGIN
1.0
CRAP 16.8
« Configd/Unit.pm ↑ Summary Configd.pm »
1 package Configd::Syntax::Spaced;
2 4 $Configd::Syntax::Spaced::VERSION = '0.005';
3 #ABSTRACT: Config files that are a directive, some whitespace and a value.
4  
5 4 ▶use 5.034;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 ▶use re '/aa';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use parent qw{Configd::Language};
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 0 ▶sub parse {
Subroutine parse: not called CC=4 SCAR=30.0
Pod documented
16 0 my ( $self, $text ) = @_;
17  
18 0 my @directives;
19 0 foreach my $line ( split( qq{\n}, $text ) ) {
20 0 ▶ if ( $line =~ m/\A\s*(?:#.*)?\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\A\s*(?:#.*)?\z/aa) 0 0 0
21 0 push @directives, { text => $line };
22 0 next;
23 }
24  
25 # Tabs as often as spaces in these files, and a value that runs to the
26 # end of the line: opendkim's Canonicalization is one word, its
27 # InternalHosts is a list, and neither is quoted.
28 0 my ( $key, $value ) = $line =~ m/\A\s*(\S+)\s+(.*?)\s*\z/;
29  
30 # A directive on its own is legal in some of these -- redis has bare
31 # flags -- and means itself.
32 0 ▶ ( $key, $value ) = ( $line =~ s/\A\s+|\s+\z//gr, q{} ) if !defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $key 0 0 0
33  
34 0 push @directives, { key => $key, value => $value };
35 }
36  
37 0 return \@directives;
38 }
39  
40  
41 0 ▶sub emit {
Subroutine emit: not called CC=5 SCAR=34.0
Pod documented
42 0 my ( $self, $directives ) = @_;
43  
44 0 my $out = q{};
45 0 foreach my $directive (@$directives) {
46 0 ▶ if ( !defined $directive->{key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $directive->{"key"}) 0 0 0
47 0 ▶ $out .= ( $directive->{text} // q{} ) . "\n";
Condition0%0/2
$directive->{"text"} // ""
l!l
00
MC/DC0%0/1
$directive->{"text"} // ""
$directive->{"text"}
Truth table0%0/2
A
A= $directive->{"text"}
Aresult
11
00
48 0 next;
49 }
50  
51 $out .=
52 length $directive->{value}
53 0 ▶ ? "$directive->{key} $directive->{value}\n"
Branch: 1 branch
BranchTrueFalseTotal
length $directive->{'value'} ? : 0 0 0
54 : "$directive->{key}\n";
55 }
56  
57 0 return $out;
58 }
59  
60  
61 4 1;
62  
63 __END__
« Configd/Unit.pm ↑ Summary Configd.pm »