| 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.01'; | |||||||||||||||||||
| 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 | 117 | ▶ | sub _build_tree { | ||||||||||||||||||
|
Subroutine
_build_tree: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 117 | my $tree = HTML::TreeBuilder::LibXML->new(); | |||||||||||||||||||
| 21 | 117 | $tree->ignore_unknown(0); | |||||||||||||||||||
| 22 | 117 | $tree->store_comments(1); | |||||||||||||||||||
| 23 | 117 | $tree; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 22 | ▶ | sub _is_same_node { | ||||||||||||||||||
|
Subroutine
_is_same_node: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 27 | 22 | $_[1]->{node}->isSameNode($_[2]->{node}); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 1 | ▶ | sub prev { | ||||||||||||||||||
|
Subroutine
prev: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||
| 31 | 1 | my $self = shift; | |||||||||||||||||||
| 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
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 22 | ▶ | sub next { | ||||||||||||||||||
|
Subroutine
next: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||
| 40 | 22 | my $self = shift; | |||||||||||||||||||
| 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
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 16 | ▶ | sub tagname { | ||||||||||||||||||
|
Subroutine
tagname: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 49 | 16 | my $self = shift; | |||||||||||||||||||
| 50 | 16 | ▶ | my $method = @_ ? 'setNodeName' : 'nodeName'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 16 | my @retval = map { $_->{node}->$method(@_) } @{$self->{trees}}; | |||||||||||||||||||
| 53 | 16 | ▶ | return wantarray ? @retval : $retval[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||