line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Zoom::StreamBase; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
107
|
use strictures 1; |
|
16
|
|
|
|
|
93
|
|
|
16
|
|
|
|
|
395
|
|
4
|
16
|
|
|
16
|
|
11023
|
use HTML::Zoom::TransformBuilder; |
|
16
|
|
|
|
|
44
|
|
|
16
|
|
|
|
|
35462
|
|
5
|
|
|
|
|
|
|
|
6
|
221
|
|
|
221
|
|
1490
|
sub _zconfig { shift->{_zconfig} } |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub peek { |
9
|
573
|
|
|
573
|
0
|
766
|
my ($self) = @_; |
10
|
573
|
100
|
|
|
|
1325
|
if (exists $self->{_peeked}) { |
11
|
2
|
|
|
|
|
9
|
return ($self->{_peeked}); |
12
|
|
|
|
|
|
|
} |
13
|
571
|
100
|
|
|
|
1497
|
if (my ($peeked) = $self->_next(1)) { |
14
|
567
|
|
|
|
|
2174
|
return ($self->{_peeked} = $peeked); |
15
|
|
|
|
|
|
|
} |
16
|
4
|
|
|
|
|
24
|
return; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub next { |
20
|
6501
|
|
|
6501
|
0
|
12469
|
my ($self) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# peeked entry so return that |
23
|
|
|
|
|
|
|
|
24
|
6501
|
100
|
|
|
|
16672
|
if (exists $self->{_peeked}) { |
25
|
563
|
100
|
|
|
|
1302
|
if (my $peeked_from = delete $self->{_peeked_from}) { |
26
|
210
|
|
|
|
|
429
|
$peeked_from->next; |
27
|
|
|
|
|
|
|
} |
28
|
563
|
|
|
|
|
1471
|
return (delete $self->{_peeked}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
5938
|
|
|
|
|
14651
|
$self->_next; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub flatten { |
36
|
135
|
|
|
135
|
0
|
192
|
my $self = shift; |
37
|
135
|
|
|
|
|
9751
|
require HTML::Zoom::FlattenedStream; |
38
|
135
|
|
|
|
|
402
|
HTML::Zoom::FlattenedStream->new({ |
39
|
|
|
|
|
|
|
source => $self, |
40
|
|
|
|
|
|
|
zconfig => $self->_zconfig |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub map { |
45
|
18
|
|
|
18
|
0
|
47
|
my ($self, $mapper) = @_; |
46
|
18
|
|
|
|
|
5306
|
require HTML::Zoom::MappedStream; |
47
|
18
|
|
|
|
|
101
|
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
|
97
|
my ($self, $transform) = @_; |
60
|
58
|
|
|
|
|
179
|
$transform->apply_to_stream($self); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub select { |
64
|
68
|
|
|
68
|
0
|
234
|
my ($self, $selector) = @_; |
65
|
68
|
|
|
|
|
173
|
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
|
8
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
# see notes in HTML/Zoom.pm for why this needs to be fixed |
76
|
6
|
|
|
|
|
17
|
$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
|
|
86
|
my ($self, $selector, @args) = @_; |
103
|
10
|
|
|
|
|
43
|
my $sel = $self->select($selector); |
104
|
10
|
|
|
|
|
38
|
my $meth = our $AUTOLOAD; |
105
|
10
|
|
|
|
|
60
|
$meth =~ s/.*:://; |
106
|
10
|
100
|
|
|
|
29
|
if (ref($selector) eq 'HASH') { |
107
|
2
|
|
|
|
|
5
|
my $ret = $self; |
108
|
2
|
|
|
|
|
8
|
$ret = $ret->_do($_, $meth, @{$selector->{$_}}) for keys %$selector; |
|
4
|
|
|
|
|
17
|
|
109
|
2
|
|
|
|
|
13
|
$ret; |
110
|
|
|
|
|
|
|
} else { |
111
|
8
|
|
|
|
|
31
|
$self->_do($selector, $meth, @args); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub _do { |
116
|
12
|
|
|
12
|
|
28
|
my ($self, $selector, $meth, @args) = @_; |
117
|
12
|
|
|
|
|
28
|
return $self->select($selector)->$meth(@args); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
0
|
|
|
sub DESTROY {} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |