line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Pipeline::Adapter::UrlBuilder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1942
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
extends 'Data::Pipeline::Adapter'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Data::Pipeline::Iterator::Options; |
7
|
|
|
|
|
|
|
use URI; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has base => ( |
10
|
|
|
|
|
|
|
isa => 'Str', |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
required => 1, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has path_elements => ( |
16
|
|
|
|
|
|
|
isa => 'ArrayRef', |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
default => sub { [ ] } |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has query => ( |
23
|
|
|
|
|
|
|
isa => 'HashRef', |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
lazy => 1, |
26
|
|
|
|
|
|
|
default => sub { +{ } } |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Data::Dumper; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has '+source' => ( |
32
|
|
|
|
|
|
|
default => sub { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
my $query = Data::Pipeline::Iterator::Options -> new( |
35
|
|
|
|
|
|
|
params => $self -> query |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return Data::Pipeline::Iterator::Source -> new( |
39
|
|
|
|
|
|
|
has_next => sub { !$query -> finished }, |
40
|
|
|
|
|
|
|
get_next => sub { |
41
|
|
|
|
|
|
|
my $o = $query -> next; |
42
|
|
|
|
|
|
|
my $uri = URI->new(join('/', $self -> base, @{$o -> {path_elements}||[]})); |
43
|
|
|
|
|
|
|
$uri -> query_form( $o ); |
44
|
|
|
|
|
|
|
my $u = $uri -> canonical -> as_string; |
45
|
|
|
|
|
|
|
# print STDERR "UrlBuilder: $u\n"; |
46
|
|
|
|
|
|
|
return $u; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |