line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Zoom::StreamBase; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
91
|
use strictures 1; |
|
15
|
|
|
|
|
75
|
|
|
15
|
|
|
|
|
303
|
|
4
|
15
|
|
|
15
|
|
6899
|
use HTML::Zoom::TransformBuilder; |
|
15
|
|
|
|
|
32
|
|
|
15
|
|
|
|
|
10732
|
|
5
|
|
|
|
|
|
|
|
6
|
221
|
|
|
221
|
|
986
|
sub _zconfig { shift->{_zconfig} } |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub peek { |
9
|
573
|
|
|
573
|
0
|
490
|
my ($self) = @_; |
10
|
573
|
100
|
|
|
|
1038
|
if (exists $self->{_peeked}) { |
11
|
2
|
|
|
|
|
6
|
return ($self->{_peeked}); |
12
|
|
|
|
|
|
|
} |
13
|
571
|
100
|
|
|
|
1067
|
if (my ($peeked) = $self->_next(1)) { |
14
|
567
|
|
|
|
|
1500
|
return ($self->{_peeked} = $peeked); |
15
|
|
|
|
|
|
|
} |
16
|
4
|
|
|
|
|
22
|
return; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub next { |
20
|
6499
|
|
|
6499
|
0
|
5005
|
my ($self) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# peeked entry so return that |
23
|
|
|
|
|
|
|
|
24
|
6499
|
100
|
|
|
|
9440
|
if (exists $self->{_peeked}) { |
25
|
563
|
100
|
|
|
|
950
|
if (my $peeked_from = delete $self->{_peeked_from}) { |
26
|
210
|
|
|
|
|
305
|
$peeked_from->next; |
27
|
|
|
|
|
|
|
} |
28
|
563
|
|
|
|
|
967
|
return (delete $self->{_peeked}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
5936
|
|
|
|
|
9149
|
$self->_next; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub flatten { |
36
|
135
|
|
|
135
|
0
|
167
|
my $self = shift; |
37
|
135
|
|
|
|
|
5913
|
require HTML::Zoom::FlattenedStream; |
38
|
135
|
|
|
|
|
326
|
HTML::Zoom::FlattenedStream->new({ |
39
|
|
|
|
|
|
|
source => $self, |
40
|
|
|
|
|
|
|
zconfig => $self->_zconfig |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub map { |
45
|
18
|
|
|
18
|
0
|
29
|
my ($self, $mapper) = @_; |
46
|
18
|
|
|
|
|
3316
|
require HTML::Zoom::MappedStream; |
47
|
18
|
|
|
|
|
83
|
HTML::Zoom::MappedStream->new({ |
48
|
|
|
|
|
|
|
source => $self, mapper => $mapper, zconfig => $self->_zconfig |
49
|
|
|
|
|
|
|
}); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub with_filter { |
53
|
0
|
|
|
0
|
0
|
0
|
my ($self, $selector, $filter) = @_; |
54
|
0
|
|
|
|
|
0
|
my $match = $self->_parse_selector($selector); |
55
|
0
|
|
|
|
|
0
|
$self->_zconfig->stream_utils->wrap_with_filter($self, $match, $filter); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub with_transform { |
59
|
58
|
|
|
58
|
0
|
71
|
my ($self, $transform) = @_; |
60
|
58
|
|
|
|
|
122
|
$transform->apply_to_stream($self); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub select { |
64
|
68
|
|
|
68
|
0
|
173
|
my ($self, $selector) = @_; |
65
|
68
|
|
|
|
|
134
|
return HTML::Zoom::TransformBuilder->new({ |
66
|
|
|
|
|
|
|
zconfig => $self->_zconfig, |
67
|
|
|
|
|
|
|
selector => $selector, |
68
|
|
|
|
|
|
|
filters => [], |
69
|
|
|
|
|
|
|
proto => $self, |
70
|
|
|
|
|
|
|
}); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub then { |
74
|
6
|
|
|
6
|
0
|
3
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
# see notes in HTML/Zoom.pm for why this needs to be fixed |
76
|
6
|
|
|
|
|
13
|
$self->select($self->transform->selector); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub apply { |
80
|
0
|
|
|
0
|
0
|
0
|
my ($self, $code) = @_; |
81
|
0
|
|
|
|
|
0
|
local $_ = $self; |
82
|
0
|
|
|
|
|
0
|
$self->$code; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub apply_if { |
86
|
0
|
|
|
0
|
0
|
0
|
my ($self, $predicate, $code) = @_; |
87
|
0
|
0
|
|
|
|
0
|
if($predicate) { |
88
|
0
|
|
|
|
|
0
|
local $_ = $self; |
89
|
0
|
|
|
|
|
0
|
$self->$code; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
|
|
|
|
0
|
$self; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub to_html { |
97
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
98
|
0
|
|
|
|
|
0
|
$self->_zconfig->producer->html_from_stream($self); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub AUTOLOAD { |
102
|
10
|
|
|
10
|
|
65
|
my ($self, $selector, @args) = @_; |
103
|
10
|
|
|
|
|
28
|
my $sel = $self->select($selector); |
104
|
10
|
|
|
|
|
15
|
my $meth = our $AUTOLOAD; |
105
|
10
|
|
|
|
|
59
|
$meth =~ s/.*:://; |
106
|
10
|
100
|
|
|
|
26
|
if (ref($selector) eq 'HASH') { |
107
|
2
|
|
|
|
|
3
|
my $ret = $self; |
108
|
2
|
|
|
|
|
7
|
$ret = $ret->_do($_, $meth, @{$selector->{$_}}) for keys %$selector; |
|
4
|
|
|
|
|
12
|
|
109
|
2
|
|
|
|
|
9
|
$ret; |
110
|
|
|
|
|
|
|
} else { |
111
|
8
|
|
|
|
|
22
|
$self->_do($selector, $meth, @args); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _do { |
116
|
12
|
|
|
12
|
|
20
|
my ($self, $selector, $meth, @args) = @_; |
117
|
12
|
|
|
|
|
17
|
return $self->select($selector)->$meth(@args); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
|
|
sub DESTROY {} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |