Knit/Document/WebQuery.pm

filter: Statementstmt 100% 32 / 32 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 89.5% 43 / 48 CC 5 SCAR 10.0
CC
5
Cov
95%
find_or_create_section
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Knit/Document/Mojo.pm ↑ Summary Knit.pm »
1 package Pod::Knit::Document::WebQuery;
2 8 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: manipulate Pod::Knit documents using Web::Query
4 8 $Pod::Knit::Document::WebQuery::VERSION = '0.0.1';
5 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 8 ▶use Web::Query::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 ▶use experimental qw/ signatures postderef /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 has dom => (
15 is => 'ro',
16 clearer => 'clear_dom',
17 lazy => 1,
18 15 ▶ default => sub ($self) {
Subroutine __ANON__: called CC=1 SCAR=0.0
19 8 ▶ use DDP;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 15 my $x = $self->xml_pod;
21  
22 # https://github.com/tokuhirom/HTML-TreeBuilder-LibXML/pull/15
23 15 HTML::TreeBuilder::LibXML::_parser->keep_blanks(1);
24 15 Web::Query::LibXML->new_from_html(
25 $x,
26 { no_space_compacting => 1 },
27 );
28 },
29 8 );
30  
31 7 ▶sub find_or_create_section( $self, $name, $level = 1, $class = $name, @rest ) {
Subroutine find_or_create_section: called CC=5 SCAR=16.3
Pod undocumented
32  
33 7 ▶ $class //= $name;
Condition66%2/3
$class //= $name
l!l&&r!l&&!r
250
MC/DC0%0/2
$class //= $name
$class $name
Truth table66%2/3
A //= B
A= $classB= $name
ABresult
1X1
011
000
34  
35 7 my $section = $self->dom->find( join '.', 'section', $name );
36  
37 7 ▶ return $section if $section->size;
Branch: 1 branch
BranchTrueFalseTotal
if $section->size 0 7 7
38  
39 7 $self->dom->append(
40 $self->xml_write( section => [
41 ':class' => lc($class),
42 'head' . $level => $name,
43 @rest,
44 ])
45 );
46  
47 7 return $self->dom->find( 'section.'. $name );
48 }
49  
50 8 1;
51  
52 __END__
« Knit/Document/Mojo.pm ↑ Summary Knit.pm »