Object/XPath/Root.pm

filter: Statementstmt 95.2% 40 / 42 Branchbran 50.0% 2 / 4 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 84.6% 11 / 13 Podpod 100% 5 / 5 totaltotal 83.3% 60 / 72 CC 5 SCAR 5.5
CC
5
Cov
86%
_class_for
3.1
new
2.1
evaluate
2.0
CRAP 1.7
« Object/DOM/Element/Meta.pm ↑ Summary Object/DOM/Screen.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/XPath/Root.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/04
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::XPath::Root;
15 BEGIN
16 14 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 14 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 14 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 14 warnings::register_categories( 'HTML::Object' );
20 14 ▶ use parent qw( Module::Generic );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 14 ▶ use vars qw( $BASE_CLASS $DEBUG $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 14 our $BASE_CLASS = 'HTML::Object::XPath';
23 14 our $DEBUG = 0;
24 14 our $VERSION = 'v0.2.0';
25 };
26  
27 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 sub new
31 46 ▶{
Subroutine new: called CC=2 SCAR=7.6
Pod documented
32 46 my $this = shift( @_ );
33 46 my $str = shift( @_ );
34 46 ▶ return( bless( \$str => ( ref( $this ) || $this ) ) );
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0460
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
35 }
36  
37 0 ▶sub as_string { return; }
Subroutine as_string: not called CC=1 SCAR=6.9
Pod documented
38  
39 0 ▶sub as_xml { return( "<Root/>\n" ); }
Subroutine as_xml: not called CC=1 SCAR=6.9
Pod documented
40  
41 sub evaluate
42 58 ▶{
Subroutine evaluate: called CC=2 SCAR=7.0
Pod documented
43 58 my $self = shift( @_ );
44 58 my $nodeset = shift( @_ );
45  
46 # must only ever occur on 1 node
47 58 ▶ die "Can't go to root on > 1 node!" unless $nodeset->size == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $nodeset->size == 1 0 58 58
48 # return( $self->error( "Can't go to root on > 1 node!" ) ) unless( $nodeset->size == 1 );
49  
50 58 my $newset = $self->new_nodeset;
51 # $newset->push($nodeset->get_node(1)->getRootNode());
52 58 my $node = $nodeset->get_node(1);
53 # $node->debug(4);
54 58 my $rootNode = $node->getRootNode();
55 58 $newset->push( $rootNode );
56 58 return( $newset );
57 }
58  
59 58 ▶sub new_nodeset { return( shift->_class_for( 'NodeSet' )->new( @_ ) ); }
Subroutine new_nodeset: called CC=1 SCAR=0.0
Pod documented
60  
61 sub _class_for
62 58 ▶{
Subroutine _class_for: called CC=3 SCAR=11.3
63 58 my( $self, $mod ) = @_;
64 58 eval( "require ${BASE_CLASS}\::${mod};" );
65 58 ▶ die( $@ ) if( $@ );
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 58 58
66 # ${"${BASE_CLASS}\::${mod}\::DEBUG"} = $DEBUG;
67 58 ▶ eval( "\$${BASE_CLASS}\::${mod}\::DEBUG = " . ( $DEBUG // 0 ) );
Condition50%1/2
$HTML::Object::XPath::Root::DEBUG // 0
l!l
580
MC/DC0%0/1
$HTML::Object::XPath::Root::DEBUG // 0
$HTML::Object::XPath::Root::DEBUG
Truth table50%1/2
A
A= $HTML::Object::XPath::Root::DEBUG
Aresult
11
00
68 58 return( "${BASE_CLASS}::${mod}" );
69 }
70  
71 14 1;
72 # NOTE: POD
73 __END__
« Object/DOM/Element/Meta.pm ↑ Summary Object/DOM/Screen.pm »