Elemental/Document.pm

filter: Statementstmt 81.6% 49 / 60 Branchbran 41.6% 5 / 12 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 68.7% 66 / 96 CC 13 SCAR 25.4
CC
13
Cov
71%
_elem_from_lol_entry
25.8
as_pod_string
3.1
as_debug_string
2.0
CRAP 12.7
↑ Summary Elemental/Transformer/Nester.pm »
1 package Pod::Elemental::Document 0.103006;
2 # ABSTRACT: a pod document
3  
4 12 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 with 'Pod::Elemental::Node';
6  
7 12 ▶use Class::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use Pod::Elemental::Element::Generic::Blank;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use String::RewritePrefix;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #pod =head1 OVERVIEW
14 #pod
15 #pod Pod::Elemental::Document is a container for Pod documents. It performs
16 #pod L<Pod::Elemental::Node> but I<not> L<Pod::Elemental::Paragraph>.
17 #pod
18 #pod Documents are used almost exclusively to give a small amount of behavior to
19 #pod arrayrefs of paragraphs, and have few methods of their own.
20 #pod
21 #pod =cut
22  
23 32 ▶sub _expand_name {
Subroutine _expand_name: called CC=1 SCAR=0.0
24 32 my ($self, $name) = @_;
25  
26 32 return String::RewritePrefix->rewrite(
27 {
28 '' => 'Pod::Elemental::Element::',
29 '=' => ''
30 },
31 $name,
32 );
33 }
34  
35 4 ▶sub as_pod_string {
Subroutine as_pod_string: called CC=3 SCAR=11.2
Pod undocumented
36 4 my ($self) = @_;
37  
38 4 my $str = join q{}, map { $_->as_pod_string } @{ $self->children };
39  
40 4 ▶ $str = "=pod\n\n$str" unless $str =~ /\A=pod\n/;
Branch: 1 branch
BranchTrueFalseTotal
unless $str =~ /\A=pod\n/ 4 0 4
41 4 ▶ $str .= "=cut\n" unless $str =~ /=cut\n+\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $str =~ /=cut\n+\z/ 4 0 4
42  
43 4 return $str;
44 }
45  
46 0 ▶sub as_debug_string {
Subroutine as_debug_string: not called CC=1 SCAR=6.9
47 0 return 'Document'
48 }
49  
50 16 ▶sub _elem_from_lol_entry {
Subroutine _elem_from_lol_entry: called CC=10 SCAR=32.5
51 16 my ($self, $entry) = @_;
52 16 my ($type, $content, $arg) = @$entry;
53 16 ▶ $arg ||= {};
Condition50%1/2
$arg ||= {}
l!l
016
MC/DC0%0/1
$arg ||= {}
$arg
Truth table50%1/2
A
A= $arg
Aresult
11
00
54  
55 16 ▶ if (! defined $type) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $type) { } 7 9 16
elsif ($type =~ /\A=(\w+)\z/) { } 9 0 9
56 7 ▶ my $n_class = $self->_expand_name($arg->{class} || 'Generic::Text');
Condition50%1/2
$arg->{'class'} || 'Generic::Text'
l!l
07
MC/DC0%0/1
$arg->{'class'} || 'Generic::Text'
$arg->{'class'}
Truth table50%1/2
A
A= $arg->{'class'}
Aresult
11
00
57 7 Class::Load::load_class($n_class);
58 7 return $n_class->new({ content => "$content\n" });
59 } elsif ($type =~ /\A=(\w+)\z/) {
60 9 my $command = $1;
61 9 ▶ my $n_class = $self->_expand_name($arg->{class} || 'Generic::Command');
Condition50%1/2
$arg->{'class'} || 'Generic::Command'
l!l
09
MC/DC0%0/1
$arg->{'class'} || 'Generic::Command'
$arg->{'class'}
Truth table50%1/2
A
A= $arg->{'class'}
Aresult
11
00
62 9 Class::Load::load_class($n_class);
63 9 return $n_class->new({
64 command => $command,
65 content => "$content\n"
66 });
67 } else {
68 0 ▶ my $n_class = $self->_expand_name($arg->{class} || 'Pod5::Region');
Condition0%0/2
$arg->{'class'} || 'Pod5::Region'
l!l
00
MC/DC0%0/1
$arg->{'class'} || 'Pod5::Region'
$arg->{'class'}
Truth table0%0/2
A
A= $arg->{'class'}
Aresult
11
00
69 0 Class::Load::load_class($n_class);
70  
71 0 my @children;
72  
73 0 for my $child (@$content) {
74 0 push @children, $self->_elem_from_lol_entry($child);
75 } continue {
76 0 my $blank = $self->_expand_name('Generic::Blank');
77 0 push @children, $blank->new({ content => "\n" });
78 }
79  
80 pop @children
81 0 ▶ while $children[-1]->isa('Pod::Elemental::Element::Generic::Blank');
Branch: 1 branch
BranchTrueFalseTotal
$children[-1]->isa("Pod::Elemental::Element::Generic::Blank") and do { pop @children } 0 0 0
82  
83 0 my ($colon, $target) = $type =~ /\A(:)?(.+)\z/;
84  
85 0 ▶ return $n_class->new({
Branch: 1 branch
BranchTrueFalseTotal
$colon ? : 0 0 0
86 format_name => $target,
87 is_pod => $colon ? 1 : 0,
88 content => "\n",
89 children => \@children,
90 })
91 }
92 }
93  
94 1 ▶sub new_from_lol {
Subroutine new_from_lol: called CC=2 SCAR=6.9
Pod undocumented
95 1 my ($class, $lol) = @_;
96  
97 1 my $self = $class->new;
98  
99 1 my @children;
100 1 ENTRY: for my $entry (@$lol) {
101 16 my $elem = $self->_elem_from_lol_entry($entry);
102 16 push @children, $elem;
103 } continue {
104 16 my $blank = $self->_expand_name('Generic::Blank');
105 16 push @children, $blank->new({ content => "\n" });
106 }
107  
108 1 push @{ $self->children }, @children;
109  
110 1 return $self;
111 }
112  
113 12 __PACKAGE__->meta->make_immutable;
114  
115 12 1;
116  
117 __END__
↑ Summary Elemental/Transformer/Nester.pm »