line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DataFlow::Proc::MultiPageURLGenerator; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2517
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: A processor that generates multi-paged URL lists |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.121830'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
580
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'DataFlow::Proc'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Moose::Autobox; |
14
|
|
|
|
|
|
|
use namespace::autoclean; |
15
|
|
|
|
|
|
|
use Carp; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'first_page' => ( |
18
|
|
|
|
|
|
|
'is' => 'ro', |
19
|
|
|
|
|
|
|
'isa' => 'Int', |
20
|
|
|
|
|
|
|
'default' => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'last_page' => ( |
24
|
|
|
|
|
|
|
'is' => 'ro', |
25
|
|
|
|
|
|
|
'isa' => 'Int', |
26
|
|
|
|
|
|
|
'required' => 1, |
27
|
|
|
|
|
|
|
'lazy' => 1, |
28
|
|
|
|
|
|
|
'default' => sub { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#warn 'last_page'; |
32
|
|
|
|
|
|
|
confess(q{DataFlow::Proc::MultiPageURLGenerator: paged_url not set!}) |
33
|
|
|
|
|
|
|
unless $self->has_paged_url; |
34
|
|
|
|
|
|
|
return $self->produce_last_page->( $self->_paged_url ); |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# calling convention for the sub: |
39
|
|
|
|
|
|
|
# - $self |
40
|
|
|
|
|
|
|
# - $url (Str) |
41
|
|
|
|
|
|
|
has 'produce_last_page' => ( |
42
|
|
|
|
|
|
|
'is' => 'ro', |
43
|
|
|
|
|
|
|
'isa' => 'CodeRef', |
44
|
|
|
|
|
|
|
'lazy' => 1, |
45
|
|
|
|
|
|
|
'default' => sub { confess(q{produce_last_page not implemented!}); }, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# calling convention for the sub: |
49
|
|
|
|
|
|
|
# - $self |
50
|
|
|
|
|
|
|
# - $paged_url (Str) |
51
|
|
|
|
|
|
|
# - $page (Int) |
52
|
|
|
|
|
|
|
has 'make_page_url' => ( |
53
|
|
|
|
|
|
|
'is' => 'ro', |
54
|
|
|
|
|
|
|
'isa' => 'CodeRef', |
55
|
|
|
|
|
|
|
'required' => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has '_paged_url' => ( |
59
|
|
|
|
|
|
|
'is' => 'rw', |
60
|
|
|
|
|
|
|
'isa' => 'Str', |
61
|
|
|
|
|
|
|
'predicate' => 'has_paged_url', |
62
|
|
|
|
|
|
|
'clearer' => 'clear_paged_url', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_p { |
66
|
|
|
|
|
|
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
return sub { |
69
|
|
|
|
|
|
|
my $url = $_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$self->_paged_url($url); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $first = $self->first_page; |
74
|
|
|
|
|
|
|
my $last = $self->last_page; |
75
|
|
|
|
|
|
|
$first = 1 + $last + $first if $first < 0; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $result = |
78
|
|
|
|
|
|
|
[ $first .. $last ] |
79
|
|
|
|
|
|
|
->map( sub { $self->make_page_url->( $self, $url, $_ ) } ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$self->clear_paged_url; |
82
|
|
|
|
|
|
|
return $result; |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
=pod |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=encoding utf-8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 NAME |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
DataFlow::Proc::MultiPageURLGenerator - A processor that generates multi-paged URL lists |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 VERSION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
version 1.121830 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<DataFlow|DataFlow> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Alexei Znamensky <russoz@cpan.org> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Alexei Znamensky. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
You can make new bug reports, and view existing ones, through the |
130
|
|
|
|
|
|
|
web interface at L<http://rt.cpan.org>. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
135
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT |
136
|
|
|
|
|
|
|
WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER |
137
|
|
|
|
|
|
|
PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, |
138
|
|
|
|
|
|
|
EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE |
139
|
|
|
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
140
|
|
|
|
|
|
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE |
141
|
|
|
|
|
|
|
SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME |
142
|
|
|
|
|
|
|
THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
145
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
146
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE |
147
|
|
|
|
|
|
|
TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR |
148
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE |
149
|
|
|
|
|
|
|
SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
150
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
151
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
152
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
153
|
|
|
|
|
|
|
DAMAGES. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|