line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Rackspace::CloudFiles::Object::Iterator; |
2
|
4
|
|
|
4
|
|
112334
|
use Moo; |
|
4
|
|
|
|
|
11410
|
|
|
4
|
|
|
|
|
23
|
|
3
|
4
|
|
|
4
|
|
2983
|
use Types::Standard qw(Bool CodeRef); |
|
4
|
|
|
|
|
76926
|
|
|
4
|
|
|
|
|
58
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has 'callback', is => 'ro', isa => CodeRef; |
6
|
|
|
|
|
|
|
has 'is_done', is => 'rwp', isa => Bool; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub next { |
9
|
5
|
|
|
5
|
1
|
3242
|
my $self = shift; |
10
|
5
|
50
|
|
|
|
19
|
return if $self->is_done; |
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
|
|
10
|
my $cb = $self->callback; |
13
|
5
|
|
|
|
|
13
|
my $next = $self->$cb; |
14
|
5
|
100
|
|
|
|
27
|
return $next if $next; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
30
|
$self->_set_is_done(1); |
17
|
1
|
|
|
|
|
51
|
return; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub items { |
21
|
1
|
|
|
1
|
1
|
616
|
my $self = shift; |
22
|
1
|
50
|
|
|
|
4
|
if (my $a = $self->next) { |
23
|
1
|
|
|
|
|
4
|
return @$a; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
0
|
return (); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub all { |
29
|
1
|
|
|
1
|
1
|
553
|
my $self = shift; |
30
|
1
|
|
|
|
|
3
|
my @all = (); |
31
|
1
|
|
|
|
|
4
|
while (my $next = $self->next) { |
32
|
2
|
|
|
|
|
7
|
push @all, @$next; |
33
|
|
|
|
|
|
|
} |
34
|
1
|
|
|
|
|
5
|
return @all; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
sub cat { $_[0]->upgrade_to_data_stream_bulk; shift->cat(@_); } |
|
0
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
|
sub list_cat { $_[0]->upgrade_to_data_stream_bulk; shift->list_calt(@_); } |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
sub filter { $_[0]->upgrade_to_data_stream_bulk; shift->filter(@_); } |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
1
|
|
sub chunk { $_[0]->upgrade_to_data_stream_bulk; shift->chunk(@_); } |
|
0
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub upgrade_to_data_stream_bulk { |
42
|
0
|
|
|
0
|
1
|
|
require Data::Stream::Bulk::Callback; |
43
|
0
|
|
|
|
|
|
$_[0] = Data::Stream::Bulk::Callback->new(callback => $_[0]->callback); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
WebService::Rackspace::CloudFiles::Object::Iterator - A simple iterator |
53
|
|
|
|
|
|
|
for CloudFiles file objects. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# $container is an instance of WebService::Rackspace::CloudFiles::Container |
58
|
|
|
|
|
|
|
my @objects = $container->objects->all; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# or |
61
|
|
|
|
|
|
|
my $next = $container->objects->next; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Since Rackspace CloudFiles can only return 10,000 files at a time, an iterator |
66
|
|
|
|
|
|
|
is needed. WebService::RackSpace::CloudFiles used to use |
67
|
|
|
|
|
|
|
Data::Bulk::Streamer but this relied upon Moose. It was replaced with this |
68
|
|
|
|
|
|
|
module in order to allow use of Moo instead. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This class supports the methods next, items, all, and is_done. For backward |
71
|
|
|
|
|
|
|
compatibility with previous versions of WebService::Rackspace::CloudFiles, if |
72
|
|
|
|
|
|
|
you call one of unsupported Data::Stream::Bulk's methods on an instance of this |
73
|
|
|
|
|
|
|
class, it will be converted to a Data::Stream::Bulk::Callback object. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 next |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Retrieves the next block of items, if any, as an arrayref. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 items |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Retrieves the next block of items and dereferences the result. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 all |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Retrieves all items. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 callback |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 cat |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 chunk |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 filter |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 list_cat |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 upgrade_to_data_stream_bulk |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 is_done |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns true if there are no more items. Note that a false value means |
104
|
|
|
|
|
|
|
that there MAY or MAY NOT be additional items. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<WebService::Rackspace::CloudFiles>, |
109
|
|
|
|
|
|
|
L<WebService::Rackspace::CloudFiles::Container>, |
110
|
|
|
|
|
|
|
L<WebService::Rackspace::CloudFiles::Object>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Dondi Michael Stroma <dstroma@gmail.com>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 COPYRIGHT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Copyright (C) 2017, Dondi Michael Stroma |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This module is free software; you can redistribute it or modify it |
123
|
|
|
|
|
|
|
under the same terms as Perl itself. |