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.8';
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.8
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 SLOTS
98  
99 =head2 module_base
100  
101 The basename of the distribution - used for dist dir.
102  
103 =head2 data_dir
104  
105 The data directory where the XML assets can be found (the RELAX NG schema, etc.)
106  
107 =head1 METHODS
108  
109 =head2 $self->dist_path($basename)
110  
111 Returns the $basename relative to data_dir().
112  
113 Utility method.
114  
115 =head2 $self->dist_path_slot($slot)
116  
117 Returns the basename of $self->$slot() relative to data_dir().
118  
119 Utility method.
120  
121 =head1 AUTHOR
122  
123 Shlomi Fish, C<< <shlomif at cpan.org> >>
124  
125 =head1 ACKNOWLEDGEMENTS
126  
127 =head1 COPYRIGHT & LICENSE
128  
129 Copyright 2009 Shlomi Fish.
130  
131 This program is distributed under the MIT (X11) License:
132 L<http://www.opensource.org/licenses/mit-license.php>
133  
134 Permission is hereby granted, free of charge, to any person
135 obtaining a copy of this software and associated documentation
136 files (the "Software"), to deal in the Software without
137 restriction, including without limitation the rights to use,
138 copy, modify, merge, publish, distribute, sublicense, and/or sell
139 copies of the Software, and to permit persons to whom the
140 Software is furnished to do so, subject to the following
141 conditions:
142  
143 The above copyright notice and this permission notice shall be
144 included in all copies or substantial portions of the Software.
145  
146 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
147 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
148 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
149 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
150 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
151 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
152 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
153 OTHER DEALINGS IN THE SOFTWARE.
154  
155 =for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
156  
157 =head1 SUPPORT
158  
159 =head2 Websites
160  
161 The following websites have more information about this module, and may be of help to you. As always,
162 in addition to those websites please use your favorite search engine to discover more resources.
163  
164 =over 4
165  
166 =item *
167  
168 MetaCPAN
169  
170 A modern, open-source CPAN search engine, useful to view POD in HTML format.
171  
172 L<https://metacpan.org/release/XML-GrammarBase>
173  
174 =item *
175  
176 RT: CPAN's Bug Tracker
177  
178 The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.
179  
180 L<https://rt.cpan.org/Public/Dist/Display.html?Name=XML-GrammarBase>
181  
182 =item *
183  
184 CPANTS
185  
186 The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
187  
188 L<http://cpants.cpanauthors.org/dist/XML-GrammarBase>
189  
190 =item *
191  
192 CPAN Testers
193  
194 The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.
195  
196 L<http://www.cpantesters.org/distro/X/XML-GrammarBase>
197  
198 =item *
199  
200 CPAN Testers Matrix
201  
202 The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.
203  
204 L<http://matrix.cpantesters.org/?dist=XML-GrammarBase>
205  
206 =item *
207  
208 CPAN Testers Dependencies
209  
210 The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.
211  
212 L<http://deps.cpantesters.org/?module=XML::GrammarBase>
213  
214 =back
215  
216 =head2 Bugs / Feature Requests
217  
218 Please report any bugs or feature requests by email to C<bug-xml-grammarbase at rt.cpan.org>, or through
219 the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=XML-GrammarBase>. You will be automatically notified of any
220 progress on the request by the system.
221  
222 =head2 Source Code
223  
224 The code is open to the world, and available for you to hack on. Please feel free to browse it and play
225 with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
226 from your repository :)
227  
228 L<https://github.com/shlomif/perl-XML-GrammarBase>
229  
230 git clone git://github.com/shlomif/perl-XML-GrammarBase.git
231  
232 =head1 AUTHOR
233  
234 Shlomi Fish <shlomif@cpan.org>
235  
236 =head1 BUGS
237  
238 Please report any bugs or feature requests on the bugtracker website
239 L<https://github.com/shlomif/perl-XML-GrammarBase/issues>
240  
241 When submitting a bug or request, please include a test-file or a
242 patch to an existing test-file that illustrates the bug or desired
243 feature.
244  
245 =head1 COPYRIGHT AND LICENSE
246  
247 This software is Copyright (c) 2018 by Shlomi Fish.
248  
249 This is free software, licensed under:
250  
251 The MIT (X11) License
252  
253 =cut
« Build ↑ Summary blib/lib/XML/GrammarBase/Role/RelaxNG.pm »