line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dezi::Types; |
2
|
19
|
|
|
|
|
187
|
use Type::Library -base, -declare => qw( |
3
|
|
|
|
|
|
|
DeziFileRules |
4
|
|
|
|
|
|
|
DeziIndexerConfig |
5
|
|
|
|
|
|
|
DeziPathClassFile |
6
|
|
|
|
|
|
|
DeziInvIndex |
7
|
|
|
|
|
|
|
DeziInvIndexArr |
8
|
|
|
|
|
|
|
DeziFileOrCodeRef |
9
|
|
|
|
|
|
|
DeziUriStr |
10
|
|
|
|
|
|
|
DeziEpoch |
11
|
|
|
|
|
|
|
DeziLogLevel |
12
|
19
|
|
|
19
|
|
1586
|
); |
|
19
|
|
|
|
|
45575
|
|
13
|
19
|
|
|
19
|
|
40619
|
use Type::Utils -all; |
|
19
|
|
|
|
|
92469
|
|
|
19
|
|
|
|
|
202
|
|
14
|
19
|
|
|
19
|
|
60095
|
use Types::Standard -types; |
|
19
|
|
|
|
|
83392
|
|
|
19
|
|
|
|
|
117
|
|
15
|
19
|
|
|
19
|
|
81993
|
use Carp; |
|
19
|
|
|
|
|
40
|
|
|
19
|
|
|
|
|
1218
|
|
16
|
19
|
|
|
19
|
|
15421
|
use File::Rules; |
|
19
|
|
|
|
|
866282
|
|
|
19
|
|
|
|
|
688
|
|
17
|
19
|
|
|
19
|
|
15737
|
use HTTP::Date; |
|
19
|
|
|
|
|
72382
|
|
|
19
|
|
|
|
|
1274
|
|
18
|
19
|
|
|
19
|
|
155
|
use Scalar::Util qw( blessed ); |
|
19
|
|
|
|
|
38
|
|
|
19
|
|
|
|
|
896
|
|
19
|
19
|
|
|
19
|
|
102
|
use Data::Dump qw( dump ); |
|
19
|
|
|
|
|
42
|
|
|
19
|
|
|
|
|
13257
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
class_type DeziIndexerConfig, { class => 'Dezi::Indexer::Config' }; |
22
|
|
|
|
|
|
|
class_type DeziPathClassFile, { class => 'Path::Class::File' }; |
23
|
|
|
|
|
|
|
coerce DeziIndexerConfig, # wrap |
24
|
|
|
|
|
|
|
from DeziPathClassFile, via { _coerce_indexer_config($_) }, |
25
|
|
|
|
|
|
|
from HashRef, via { _coerce_indexer_config($_) }, |
26
|
|
|
|
|
|
|
from Str, via { _coerce_indexer_config($_) }, |
27
|
|
|
|
|
|
|
from Undef, via { _coerce_indexer_config($_) }; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# InvIndex |
30
|
|
|
|
|
|
|
class_type DeziInvIndex, { class => 'Dezi::InvIndex' }; |
31
|
|
|
|
|
|
|
coerce DeziInvIndex, # wrap |
32
|
|
|
|
|
|
|
from DeziPathClassFile, via { _coerce_invindex($_) }, |
33
|
|
|
|
|
|
|
from Str, via { _coerce_invindex($_) }, |
34
|
|
|
|
|
|
|
from Undef, via { Dezi::InvIndex->new() }; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
declare DeziInvIndexArr, as ArrayRef []; |
37
|
|
|
|
|
|
|
coerce DeziInvIndexArr, from ArrayRef, via { |
38
|
|
|
|
|
|
|
[ map { _coerce_invindex($_) } @$_ ]; |
39
|
|
|
|
|
|
|
}, from DeziInvIndex, via { [$_] }; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# filter |
42
|
|
|
|
|
|
|
declare DeziFileOrCodeRef, as CodeRef; |
43
|
|
|
|
|
|
|
coerce DeziFileOrCodeRef, from Str, via { |
44
|
|
|
|
|
|
|
if ( -s $_ and -r $_ ) { return do $_ } |
45
|
|
|
|
|
|
|
else { return Eval::Closure::eval_closure( source => $_ ) } |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# File::Rules |
49
|
|
|
|
|
|
|
class_type DeziFileRules, { class => "File::Rules" }; |
50
|
|
|
|
|
|
|
coerce DeziFileRules, from ArrayRef, via { File::Rules->new($_) }; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# URI (coerce to Str) |
53
|
|
|
|
|
|
|
declare DeziUriStr, as Str; |
54
|
|
|
|
|
|
|
coerce DeziUriStr, from Object, q{"$_"}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Epoch |
57
|
|
|
|
|
|
|
declare DeziEpoch, as Maybe [Int]; |
58
|
|
|
|
|
|
|
coerce DeziEpoch, from Defined, via { |
59
|
|
|
|
|
|
|
m/\D/ ? str2time($_) : $_; |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# LogLevel |
63
|
|
|
|
|
|
|
declare DeziLogLevel, as Int; |
64
|
|
|
|
|
|
|
coerce DeziLogLevel, from Undef, via {0}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# |
67
|
19
|
|
|
19
|
|
1733
|
use namespace::autoclean; |
|
19
|
|
|
|
|
16883
|
|
|
19
|
|
|
|
|
192
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _coerce_indexer_config { |
70
|
5
|
|
|
5
|
|
14
|
my $config2 = shift; |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
4431
|
require Dezi::Indexer::Config; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#carp "verify_isa_config: $config2"; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $config2_object; |
77
|
0
|
0
|
0
|
|
|
|
if ( !$config2 ) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$config2_object = Dezi::Indexer::Config->new(); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
elsif ( !blessed($config2) && -r $config2 ) { |
81
|
0
|
|
|
|
|
|
$config2_object = Dezi::Indexer::Config->new( file => $config2 ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
elsif ( !blessed($config2) && ref $config2 eq 'HASH' ) { |
84
|
0
|
|
|
|
|
|
$config2_object = Dezi::Indexer::Config->new(%$config2); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif ( blessed($config2) ) { |
87
|
0
|
0
|
|
|
|
|
if ( $config2->isa('Path::Class::File') ) { |
|
|
0
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$config2_object = Dezi::Indexer::Config->new( file => $config2 ); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
elsif ( $config2->isa('Dezi::Indexer::Config') ) { |
91
|
0
|
|
|
|
|
|
$config2_object = $config2; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
0
|
|
|
|
|
|
confess |
95
|
|
|
|
|
|
|
"config object does not inherit from Dezi::Indexer::Config: $config2"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else { |
99
|
0
|
|
|
|
|
|
confess "$config2 is neither an object nor a readable file"; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $config2_object; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _coerce_invindex { |
106
|
0
|
0
|
|
0
|
|
|
my $inv = shift or confess "InvIndex required"; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
require Dezi::InvIndex; |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
0
|
|
|
|
if ( blessed($inv) and $inv->isa('Path::Class::Dir') ) { |
111
|
0
|
|
|
|
|
|
return Dezi::InvIndex->new("$inv"); |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
return Dezi::InvIndex->new("$inv"); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Dezi::Types - Type::Tiny constraints for Dezi::App components |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 SYNOPSIS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package MySearchThing; |
127
|
|
|
|
|
|
|
use Moose; |
128
|
|
|
|
|
|
|
use Dezi::Types qw( DeziInvIndexArr ); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
has 'invindex' => ( |
131
|
|
|
|
|
|
|
is => 'rw', |
132
|
|
|
|
|
|
|
isa => DeziInvIndexArr, |
133
|
|
|
|
|
|
|
required => 1, |
134
|
|
|
|
|
|
|
coerce => 1, |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 TYPES |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The following types are defined: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
DeziIndexerConfig |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
DeziInvIndex |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
DeziInvIndexArr |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
DeziFileOrCodeRef |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
DeziFileRules |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
DeziUriStr |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
DeziEpoch |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
DeziLogLevel |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Peter Karman, E<lt>karpet@dezi.orgE<gt> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 BUGS |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-dezi-app at rt.cpan.org>, or through |
184
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-App>. |
185
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 SUPPORT |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
perldoc Dezi::Types |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
You can also look for information at: |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=over 4 |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * Website |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
L<http://dezi.org/> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item * IRC |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
#dezisearch at freenode |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item * Mailing list |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L<https://groups.google.com/forum/#!forum/dezi-search> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dezi-App> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Dezi-App> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * CPAN Ratings |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Dezi-App> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * Search CPAN |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L<https://metacpan.org/dist/Dezi-App/> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Copyright 2014 by Peter Karman |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
232
|
|
|
|
|
|
|
it under the terms of the GPL v2 or later. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 SEE ALSO |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
L<http://dezi.org/>, L<http://swish-e.org/>, L<http://lucy.apache.org/> |
237
|
|
|
|
|
|
|
|