line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Grepl::Results::Token; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
180
|
|
4
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
173
|
|
5
|
6
|
|
|
6
|
|
30
|
use App::Grepl; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
162
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
35
|
use base 'App::Grepl::Base'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
523
|
|
8
|
6
|
|
|
6
|
|
31
|
use Scalar::Util 'reftype'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
2011
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
App::Grepl::Results::Token - App::Grepl result by token type. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.01 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
OO interface to grepl's individual results. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use App::Grepl::Results::Token; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $found = App::Grepl::Results->new( { |
29
|
|
|
|
|
|
|
file => $file, |
30
|
|
|
|
|
|
|
} ); |
31
|
|
|
|
|
|
|
$found->add_results( $token => \@results ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
print $found->file, "\n"; |
34
|
|
|
|
|
|
|
while ( my $result = $found->next ) { |
35
|
|
|
|
|
|
|
print $result->token, "matched:\n"; |
36
|
|
|
|
|
|
|
while ( my $item = $result->next ) { |
37
|
|
|
|
|
|
|
print "\t$item\n"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Class Methods |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head3 C |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $grepl = App::Grepl::Results::Token->new( { |
48
|
|
|
|
|
|
|
token => 'pod', |
49
|
|
|
|
|
|
|
results => \@matching_pod, |
50
|
|
|
|
|
|
|
} ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _initialize { |
55
|
10
|
|
|
10
|
|
23
|
my ( $self, $arg_for ) = @_; |
56
|
10
|
|
|
|
|
43
|
$self->token( delete $arg_for->{token} ); |
57
|
9
|
|
|
|
|
34
|
$self->results( delete $arg_for->{results} ); |
58
|
8
|
|
|
|
|
16
|
return $self; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 Class Methods |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head3 C |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $token = $result->token; |
66
|
|
|
|
|
|
|
$result->token($token); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Getter/setter for token type. Will C if C does not |
69
|
|
|
|
|
|
|
recognize the token type. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub token { |
74
|
16
|
|
|
16
|
1
|
30
|
my $self = shift; |
75
|
16
|
100
|
|
|
|
69
|
return $self->{token} unless @_; |
76
|
10
|
|
|
|
|
17
|
my $token = shift; |
77
|
10
|
100
|
|
|
|
60
|
unless ( App::Grepl->handler_for($token) ) { |
78
|
1
|
|
|
|
|
9
|
$self->_croak("Do not know how to add a result for ($token)"); |
79
|
|
|
|
|
|
|
} |
80
|
9
|
|
|
|
|
39
|
$self->{token} = $token; |
81
|
9
|
|
|
|
|
16
|
return $self; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 C |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $results = $result->results; |
87
|
|
|
|
|
|
|
$result->results($results); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Getter/setter for results. Will C if not passed an array reference. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub results { |
94
|
9
|
|
|
9
|
1
|
12
|
my $self = shift; |
95
|
9
|
50
|
|
|
|
28
|
return $self->{results} unless @_; |
96
|
9
|
|
|
|
|
14
|
my $results = shift; |
97
|
9
|
100
|
|
|
|
42
|
unless ( 'ARRAY' eq reftype($results) ) { |
98
|
1
|
|
|
|
|
4
|
$self->_croak("Results must be an array references"); |
99
|
|
|
|
|
|
|
} |
100
|
8
|
|
|
|
|
16
|
$self->{results} = $results; |
101
|
8
|
|
|
|
|
14
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head3 C |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
while ( defined ( my $result = $found->next ) ) { |
107
|
|
|
|
|
|
|
... |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the next result found. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Note that the iterator is destructive. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub next { |
117
|
16
|
|
|
16
|
1
|
31
|
my $self = shift; |
118
|
16
|
|
|
|
|
18
|
shift @{ $self->{results} }; |
|
16
|
|
|
|
|
100
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Curtis Poe, C<< >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 BUGS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
129
|
|
|
|
|
|
|
C, or through the web interface at |
130
|
|
|
|
|
|
|
L. |
131
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
132
|
|
|
|
|
|
|
your bug as I make changes. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SUPPORT |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
perldoc App::Grepl::Results::Token |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
You can also look for information at: |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=over 4 |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * CPAN Ratings |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * Search CPAN |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=back |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright 2007 Curtis Poe, all rights reserved. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
169
|
|
|
|
|
|
|
under the same terms as Perl itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |