Plugin/Selector.pm

filter: Statementstmt 50.0% 8 / 16 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 36.6% 11 / 30 CC 5 SCAR 30.8
CC
5
Cov
33%
selector
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
« PhantomJS.pm ↑ Summary PhantomJS/DSL.pm »
1 package WWW::Mechanize::Plugin::Selector;
2 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 33 our $VERSION= '0.24';
4 33 ▶use HTML::Selector::XPath 'selector_to_xpath';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 SYNOPSIS
7  
8 =head1 NAME
9  
10 WWW::Mechanize::Plugin::Selector - CSS selector method for WWW::Mechanize
11  
12 =cut
13  
14 =head1 ADDED METHODS
15  
16 =head2 C<< $mech->selector( $css_selector, %options ) >>
17  
18 my @text = $mech->selector('p.content');
19  
20 Returns all nodes matching the given CSS selector. If
21 C<$css_selector> is an array reference, it returns
22 all nodes matched by any of the CSS selectors in the array.
23  
24 This takes the same options that C<< ->xpath >> does.
25  
26 =cut
27  
28 sub selector {
29 0 ▶ my ($self,$query,%options) = @_;
Subroutine selector: not called CC=5 SCAR=34.0
Pod documented
30 0 ▶ $options{ user_info } ||= "CSS selector '$query'";
Condition0%0/2
$options{"user_info"} ||= "CSS selector '${query}'"
l!l
00
MC/DC0%0/1
$options{"user_info"} ||= "CSS selector '${query}'"
$options{"user_info"}
Truth table0%0/2
A
A= $options{"user_info"}
Aresult
11
00
31 0 ▶ if ('ARRAY' ne (ref $query || '')) {
Branch: 1 branch
BranchTrueFalseTotal
if ("ARRAY" ne (ref $query || "")) 0 0 0
Condition0%0/2
ref $query || ''
l!l
00
MC/DC0%0/1
ref $query || ''
ref $query
Truth table0%0/2
A
A= ref $query
Aresult
11
00
32 0 $query = [$query];
33 };
34 0 ▶ my $root = $options{ node } ? './' : '';
Branch: 1 branch
BranchTrueFalseTotal
$options{'node'} ? : 0 0 0
35 0 my @q = map { selector_to_xpath($_, root => $root) } @$query;
36 0 $self->xpath(\@q, %options);
37 };
38  
39 33 1;
« PhantomJS.pm ↑ Summary PhantomJS/DSL.pm »