| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::GrammarBase::Role::DataDir; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13157
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
XML::GrammarBase::Role::DataDir - provide the data_dir accessor. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.2.3 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
3995
|
use MooX::Role 'late'; |
|
|
1
|
|
|
|
|
204
|
|
|
|
1
|
|
|
|
|
10
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
2699
|
use File::ShareDir qw(dist_dir); |
|
|
1
|
|
|
|
|
10124
|
|
|
|
1
|
|
|
|
|
417
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.2.3'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $_component_re = qr/[A-Za-z_]\w*/; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has 'module_base' => (isa => sub { |
|
26
|
|
|
|
|
|
|
my ($dist_name) = @_; |
|
27
|
|
|
|
|
|
|
if (not ( |
|
28
|
|
|
|
|
|
|
(ref($dist_name) eq '') |
|
29
|
|
|
|
|
|
|
&& |
|
30
|
|
|
|
|
|
|
($dist_name =~ m/\A$_component_re(?:-$_component_re)*\z/) |
|
31
|
|
|
|
|
|
|
) |
|
32
|
|
|
|
|
|
|
) |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
|
|
|
|
|
|
die "module_base must be a distribution string of components separated by dashes"; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
, is => 'rw'); |
|
38
|
|
|
|
|
|
|
has 'data_dir' => (isa => 'Str', is => 'rw', |
|
39
|
|
|
|
|
|
|
default => sub { return shift->_calc_default_data_dir(); }, |
|
40
|
|
|
|
|
|
|
lazy => 1, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _calc_default_data_dir |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return dist_dir( $self->module_base() ); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _undefize |
|
51
|
|
|
|
|
|
|
{ |
|
52
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
53
|
0
|
|
|
|
|
|
my $v = shift; |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
|
return defined($v) ? $v : "(undef)"; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub dist_path |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
0
|
|
|
0
|
1
|
|
my ($self, $basename) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return File::Spec->catfile($self->data_dir, $basename); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub dist_path_slot |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
0
|
|
|
0
|
1
|
|
my ($self, $slot) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return $self->dist_path($self->$slot()); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
package MyClass::WithDataDir; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use MooX 'late'; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
with ('XML::GrammarBase::Role::DataDir'); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
has '+module_base' => (default => 'XML-Grammar-MyGrammar'); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package main; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $obj = MyClass::WithDataDir->new( |
|
85
|
|
|
|
|
|
|
data_dir => "/path/to/data-dir", |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SLOTS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 module_base |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The basename of the distribution - used for dist dir. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 data_dir |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The data directory where the XML assets can be found (the RELAX NG schema, etc.) |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 METHODS |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 $self->dist_path($basename) |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the $basename relative to data_dir(). |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Utility method. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 $self->dist_path_slot($slot) |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Returns the basename of $self->$slot() relative to data_dir(). |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Utility method. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Shlomi Fish, C<< >> |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 BUGS |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
119
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
120
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SUPPORT |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
perldoc XML::GrammarBase |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
You can also look for information at: |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * Search CPAN |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright 2009 Shlomi Fish. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is distributed under the MIT (X11) License: |
|
162
|
|
|
|
|
|
|
L |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person |
|
165
|
|
|
|
|
|
|
obtaining a copy of this software and associated documentation |
|
166
|
|
|
|
|
|
|
files (the "Software"), to deal in the Software without |
|
167
|
|
|
|
|
|
|
restriction, including without limitation the rights to use, |
|
168
|
|
|
|
|
|
|
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
169
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the |
|
170
|
|
|
|
|
|
|
Software is furnished to do so, subject to the following |
|
171
|
|
|
|
|
|
|
conditions: |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be |
|
174
|
|
|
|
|
|
|
included in all copies or substantial portions of the Software. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
177
|
|
|
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
178
|
|
|
|
|
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
179
|
|
|
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
180
|
|
|
|
|
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
181
|
|
|
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
182
|
|
|
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
183
|
|
|
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; # End of XML::GrammarBase::RelaxNG::Validate |
|
188
|
|
|
|
|
|
|
|