blib/lib/XML/GrammarBase/Role/DataDir.pm

filter: Statementstmt 90.0% 27 / 30 Branchbran 75.0% 3 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 80.0% 8 / 10 Podpod 100% 2 / 2 totaltotal 84.3% 43 / 51 CC 4 SCAR 5.8
CC
4
Cov
86%
__ANON__
3.0
_undefize
2.0
__ANON__
2.0
CRAP 1.8
« Build ↑ Summary blib/lib/XML/GrammarBase/Role/RelaxNG.pm »
1 package XML::GrammarBase::Role::DataDir;
2 6 $XML::GrammarBase::Role::DataDir::VERSION = '0.2.6';
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 6 ▶use MooX::Role 'late';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 6 ▶use File::ShareDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 my $_component_re = qr/[A-Za-z_]\w*/;
12  
13 has 'module_base' => (
14 isa => sub {
15 7 ▶ my ($dist_name) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
16 7 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $dist_name eq "" && $dist_name =~ /\A$_component_re(?:-$_component_re)*\z/) 1 6 7
Condition66%2/3
ref $dist_name eq '' && $dist_name =~ /\A$_component_re(?:-$_component_re)*\z/
!ll&&!rl&&r
016
MC/DC50%1/2
ref $dist_name eq '' && $dist_name =~ /\A$_component_re(?:-$_component_re)*\z/
ref $dist_name eq '' $dist_name =~ /\A$_component_re(?:-$_component_re)*\z/
Truth table66%2/3
A && B
A= ref $dist_name eq ''B= $dist_name =~ /\A$_component_re(?:-$_component_re)*\z/
ABresult
0X0
100
111
17 not( ( ref($dist_name) eq '' )
18 && ( $dist_name =~ m/\A$_component_re(?:-$_component_re)*\z/ ) )
19 )
20 {
21 1 die
22 "module_base must be a distribution string of components separated by dashes";
23 }
24 },
25 ,
26 6 is => 'rw'
27 );
28 has 'data_dir' => (
29 isa => 'Str',
30 is => 'rw',
31 0 ▶ default => sub { return shift->_calc_default_data_dir(); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 6 lazy => 1,
33 );
34  
35 sub _calc_default_data_dir
36 {
37 0 ▶ my ($self) = @_;
Subroutine _calc_default_data_dir: not called CC=1 SCAR=6.9
38  
39 0 return dist_dir( $self->module_base() );
40 }
41  
42 sub _undefize
43 {
44 3 ▶ my $class = shift;
Subroutine _undefize: called CC=2 SCAR=7.1
45 3 my $v = shift;
46  
47 3 ▶ return defined($v) ? $v : "(undef)";
Branch: 1 branch
BranchTrueFalseTotal
defined $v ? : 0 3 3
48 }
49  
50 sub dist_path
51 {
52 6 ▶ my ( $self, $basename ) = @_;
Subroutine dist_path: called CC=1 SCAR=0.0
Pod documented
53  
54 6 return File::Spec->catfile( $self->data_dir, $basename );
55 }
56  
57 sub dist_path_slot
58 {
59 6 ▶ my ( $self, $slot ) = @_;
Subroutine dist_path_slot: called CC=1 SCAR=0.0
Pod documented
60  
61 6 return $self->dist_path( $self->$slot() );
62 }
63  
64  
65 6 1; # End of XML::GrammarBase::RelaxNG::Validate
66  
67 __END__
68  
69 =pod
70  
71 =encoding UTF-8
72  
73 =head1 NAME
74  
75 XML::GrammarBase::Role::DataDir - provide the data_dir accessor.
76  
77 =head1 VERSION
78  
79 version 0.2.6
80  
81 =head1 SYNOPSIS
82  
83 package MyClass::WithDataDir;
84  
85 use MooX 'late';
86  
87 with ('XML::GrammarBase::Role::DataDir');
88  
89 has '+module_base' => (default => 'XML-Grammar-MyGrammar');
90  
91 package main;
92  
93 my $obj = MyClass::WithDataDir->new(
94 data_dir => "/path/to/data-dir",
95 );
96  
97 =head1 VERSION
98  
99 version 0.2.6
100  
101 =head1 SLOTS
102  
103 =head2 module_base
104  
105 The basename of the distribution - used for dist dir.
106  
107 =head2 data_dir
108  
109 The data directory where the XML assets can be found (the RELAX NG schema, etc.)
110  
111 =head1 METHODS
112  
113 =head2 $self->dist_path($basename)
114  
115 Returns the $basename relative to data_dir().
116  
117 Utility method.
118  
119 =head2 $self->dist_path_slot($slot)
120  
121 Returns the basename of $self->$slot() relative to data_dir().
122  
123 Utility method.
124  
125 =head1 AUTHOR
126  
127 Shlomi Fish, C<< <shlomif at cpan.org> >>
128  
129 =head1 BUGS
130  
131 Please report any bugs or feature requests to C<bug-xml-grammarbase at rt.cpan.org>, or through
132 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-GrammarBase>. I will be notified, and then you'll
133 automatically be notified of progress on your bug as I make changes.
134  
135 =head1 SUPPORT
136  
137 You can find documentation for this module with the perldoc command.
138  
139 perldoc XML::GrammarBase
140  
141 You can also look for information at:
142  
143 =over 4
144  
145 =item * RT: CPAN's request tracker
146  
147 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-GrammarBase>
148  
149 =item * AnnoCPAN: Annotated CPAN documentation
150  
151 L<http://annocpan.org/dist/XML-GrammarBase>
152  
153 =item * CPAN Ratings
154  
155 L<http://cpanratings.perl.org/d/XML-GrammarBase>
156  
157 =item * Search CPAN
158  
159 L<http://search.cpan.org/dist/XML-GrammarBase/>
160  
161 =back
162  
163 =head1 ACKNOWLEDGEMENTS
164  
165 =head1 COPYRIGHT & LICENSE
166  
167 Copyright 2009 Shlomi Fish.
168  
169 This program is distributed under the MIT (X11) License:
170 L<http://www.opensource.org/licenses/mit-license.php>
171  
172 Permission is hereby granted, free of charge, to any person
173 obtaining a copy of this software and associated documentation
174 files (the "Software"), to deal in the Software without
175 restriction, including without limitation the rights to use,
176 copy, modify, merge, publish, distribute, sublicense, and/or sell
177 copies of the Software, and to permit persons to whom the
178 Software is furnished to do so, subject to the following
179 conditions:
180  
181 The above copyright notice and this permission notice shall be
182 included in all copies or substantial portions of the Software.
183  
184 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
185 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
186 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
187 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
188 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
189 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
190 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
191 OTHER DEALINGS IN THE SOFTWARE.
192  
193 =head1 AUTHOR
194  
195 Shlomi Fish <shlomif@cpan.org>
196  
197 =head1 COPYRIGHT AND LICENSE
198  
199 This software is Copyright (c) 2018 by Shlomi Fish.
200  
201 This is free software, licensed under:
202  
203 The MIT (X11) License
204  
205 =head1 BUGS
206  
207 Please report any bugs or feature requests on the bugtracker website
208 L<https://github.com/shlomif/perl-XML-GrammarBase/issues>
209  
210 When submitting a bug or request, please include a test-file or a
211 patch to an existing test-file that illustrates the bug or desired
212 feature.
213  
214 =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
215  
216 =head1 SUPPORT
217  
218 =head2 Perldoc
219  
220 You can find documentation for this module with the perldoc command.
221  
222 perldoc XML::GrammarBase::Role::DataDir
223  
224 =head2 Websites
225  
226 The following websites have more information about this module, and may be of help to you. As always,
227 in addition to those websites please use your favorite search engine to discover more resources.
228  
229 =over 4
230  
231 =item *
232  
233 MetaCPAN
234  
235 A modern, open-source CPAN search engine, useful to view POD in HTML format.
236  
237 L<https://metacpan.org/release/XML-GrammarBase>
238  
239 =item *
240  
241 Search CPAN
242  
243 The default CPAN search engine, useful to view POD in HTML format.
244  
245 L<http://search.cpan.org/dist/XML-GrammarBase>
246  
247 =item *
248  
249 RT: CPAN's Bug Tracker
250  
251 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
252  
253 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-GrammarBase>
254  
255 =item *
256  
257 AnnoCPAN
258  
259 The AnnoCPAN is a website that allows community annotations of Perl module documentation.
260  
261 L<http://annocpan.org/dist/XML-GrammarBase>
262  
263 =item *
264  
265 CPAN Ratings
266  
267 The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.
268  
269 L<http://cpanratings.perl.org/d/XML-GrammarBase>
270  
271 =item *
272  
273 CPANTS
274  
275 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
276  
277 L<http://cpants.cpanauthors.org/dist/XML-GrammarBase>
278  
279 =item *
280  
281 CPAN Testers
282  
283 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
284  
285 L<http://www.cpantesters.org/distro/X/XML-GrammarBase>
286  
287 =item *
288  
289 CPAN Testers Matrix
290  
291 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
292  
293 L<http://matrix.cpantesters.org/?dist=XML-GrammarBase>
294  
295 =item *
296  
297 CPAN Testers Dependencies
298  
299 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
300  
301 L<http://deps.cpantesters.org/?module=XML::GrammarBase>
302  
303 =back
304  
305 =head2 Bugs / Feature Requests
306  
307 Please report any bugs or feature requests by email to C<bug-xml-grammarbase at rt.cpan.org>, or through
308 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-GrammarBase>. You will be automatically notified of any
309 progress on the request by the system.
310  
311 =head2 Source Code
312  
313 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
314 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
315 from your repository :)
316  
317 L<https://github.com/shlomif/perl-XML-GrammarBase>
318  
319 git clone git://github.com/shlomif/perl-XML-GrammarBase.git
320  
321 =cut
« Build ↑ Summary blib/lib/XML/GrammarBase/Role/RelaxNG.pm »