Query/LibXML.pm

filter: Statementstmt 100% 47 / 47 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 13 / 13 Podpod 100% 4 / 4 totaltotal 88.4% 69 / 78 SCAR 19.5
CC
7
Cov
91%
prev
3.1
next
3.1
tagname
3.0
CRAP 7.0
« Query.pm ↑ Summary
1 package Web::Query::LibXML;
2 41 our $AUTHORITY = 'cpan:TOKUHIROM';
3 # ABSTRACT: fast, drop-in replacement for Web::Query
4 41 $Web::Query::LibXML::VERSION = '1.00';
5  
6 41 ▶use 5.008005;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 41 ▶use parent qw/Web::Query Exporter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 41 ▶use HTML::TreeBuilder::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # version required for unique_key
13 41 ▶use XML::LibXML 2.0107;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 41 our @EXPORT = qw/wq/;
16  
17 88 ▶sub wq { Web::Query::LibXML->new(@_) }
Subroutine wq: called CC=1 SCAR=0.0
Pod documented
18  
19 sub _build_tree {
20 117 ▶ my $tree = HTML::TreeBuilder::LibXML->new();
Subroutine _build_tree: called CC=1 SCAR=0.0
21 117 $tree->ignore_unknown(0);
22 117 $tree->store_comments(1);
23 117 $tree;
24 }
25  
26 sub _is_same_node {
27 22 ▶ $_[1]->{node}->isSameNode($_[2]->{node});
Subroutine _is_same_node: called CC=1 SCAR=0.0
28 }
29  
30 sub prev {
31 1 ▶ my $self = shift;
Subroutine prev: called CC=3 SCAR=11.3
Pod documented
32 1 my @new;
33 1 for my $tree (@{$self->{trees}}) {
34 2 push @new, $tree->left;
35 }
36 1 ▶ return (ref $self || $self)->new_from_element(\@new, $self);
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
100
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
37 }
38  
39 sub next {
40 22 ▶ my $self = shift;
Subroutine next: called CC=3 SCAR=11.2
Pod documented
41 22 my @new;
42 22 for my $tree (@{$self->{trees}}) {
43 29 push @new, grep { $_ } $tree->right;
44 }
45 22 ▶ return (ref $self || $self)->new_from_element(\@new, $self);
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
2200
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
46 }
47  
48 sub tagname {
49 16 ▶ my $self = shift;
Subroutine tagname: called CC=3 SCAR=11.0
Pod documented
50 16 ▶ my $method = @_ ? 'setNodeName' : 'nodeName';
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 14 16
51
52 16 my @retval = map { $_->{node}->$method(@_) } @{$self->{trees}};
53 16 ▶ return wantarray ? @retval : $retval[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 16 16
54 }
55  
56 139 ▶sub _node_id { $_[1]{node}->unique_key }
Subroutine _node_id: called CC=1 SCAR=0.0
57 41 1;
58  
59 __END__
« Query.pm ↑ Summary