line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
88157
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo::Role; |
7
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
326
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
has buffer_size => (is => 'ro', lazy => 1, builder => 'default_buffer_size'); |
10
|
|
|
|
|
|
|
has buffer => (is => 'rwp', lazy => 1, default => sub {[]}); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
0
|
5424
|
$_[0]->_set_buffer([]); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
1
|
7
|
scalar @{$_[0]->buffer}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $self = $_[0]; |
20
|
7
|
|
|
7
|
1
|
606
|
$self->buffer_used >= $self->buffer_size ? 1 : 0; |
|
7
|
|
|
|
|
126
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $buffer = shift->buffer; |
24
|
3
|
|
|
3
|
1
|
3349
|
push @$buffer, @_; |
25
|
3
|
100
|
|
|
|
8
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
1
|
41
|
|
30
|
2
|
|
|
|
|
17
|
=pod |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Catmandu::Buffer - A base class for modules that need an array buffer |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
package MyPackage; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use Moo; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
with 'Catmandu::Buffer'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Print only when the buffer is full... |
45
|
|
|
|
|
|
|
sub print { |
46
|
|
|
|
|
|
|
my ($self,$str) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if ($self->buffer_is_full) { |
49
|
|
|
|
|
|
|
print join "\n" , @{ $self->buffer }; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$self->clear_buffer; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$self->buffer_add($str); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package main; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $x = MyPackage->new; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
for (my $i = 0 ; $i < 1000 ; $i++) { |
62
|
|
|
|
|
|
|
$x->print($x); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 buffer |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
A ARRAY reference to the content of the buffer. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 buffer_size(MAX) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The maximum size of a buffer. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 clear_buffer() |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Empty the buffer. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 buffer_used() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns a true value when there is content in the buffer. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 buffer_is_full() |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns a true value when the buffer has reached its maximum capacity. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 buffer_add($x) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Adds $x to the buffer. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SEE ALSO |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L<Catmandu::Solr::Bag> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |