blib/lib/File/ShareDir/PathClass.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 71.7% 33 / 46 CC 4 SCAR 18.7
CC
4
Cov
72%
__ANON__
16.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.5
↑ Summary
1 #
2 # This file is part of File-ShareDir-PathClass
3 #
4 # This software is copyright (c) 2010 by Jerome Quelin.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package File::ShareDir::PathClass;
14 {
15 3 $File::ShareDir::PathClass::VERSION = '1.112440';
16 }
17 # ABSTRACT: File::ShareDir returning Path::Class objects
18  
19 3 ▶use File::ShareDir ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use Sub::Exporter -setup => {
Subroutine BEGIN: called CC=1 SCAR=0.0
22 exports => [ @File::ShareDir::EXPORT_OK ],
23 #groups => { },
24 3 };
25  
26  
27 # wrap all file::sharedir relevant methods
28 3 foreach my $sub ( @File::ShareDir::EXPORT_OK ) {
29 3 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
30 # create a new sub...
31 18 ▶ *{ $sub } = sub {
Subroutine __ANON__: not called CC=4 SCAR=27.7
32 0 ▶ shift if defined($_[0]) && $_[0] eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] and $_[0] eq __PACKAGE__ 0 0 0
Condition0%0/3
defined $_[0] and $_[0] eq __PACKAGE__
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0] and $_[0] eq __PACKAGE__
defined $_[0] $_[0] eq __PACKAGE__
Truth table0%0/3
A and B
A= defined $_[0]B= $_[0] eq __PACKAGE__
ABresult
0X0
100
111
33 # ... that just pass through to file::sharedir method...
34 0 my $result = "File::ShareDir::$sub"->(@_);
35 # ... and wrap the result as a path::class object
36 0 ▶ return $sub =~ /_file\z/ ? file( $result ) : dir( $result );
Branch: 1 branch
BranchTrueFalseTotal
$sub =~ /_file\z/ ? : 0 0 0
37 18 };
38 }
39  
40 3 1;
41  
42  
43 =pod
44  
45 =head1 NAME
46  
47 File::ShareDir::PathClass - File::ShareDir returning Path::Class objects
48  
49 =head1 VERSION
50  
51 version 1.112440
52  
53 =head1 SYNOPSIS
54  
55 use File::ShareDir::PathClass '-all';
56 my $dir = dist_dir("File-ShareDir-PathClass")
57 # $dir is a Path::Class object now
58  
59 # - or -
60  
61 use File::ShareDir::PathClass;
62 my $dir = File::ShareDir::PathClass->dist_dir("File-ShareDir-PathClass");
63 # $dir is a Path::Class object now
64  
65 =head1 DESCRIPTION
66  
67 This module is just a wrapper around L<File::ShareDir> functions,
68 transforming their return value to L<Path::Class> objects. This allows
69 for easier usage of the value.
70  
71 Refer to L<File::ShareDir> (section FUNCTIONS) for a list of which
72 functions are supported.
73  
74 C<File::ShareDir::PathClass> supports both a procedural and a clas
75 methods API.
76  
77 =head2 Procedural mode
78  
79 All functions are exportable. Nothing is exported by default, though.
80 One has to list which function(s) she wants to import.
81  
82 Some groups are defined for your convenience:
83  
84 =over 4
85  
86 =item * C<all> - all available functions.
87  
88 =back
89  
90 Note that this module is exporting subs via L<Sub::Exporter>, so groups
91 are available either as C<:group> or C<-group>. One can also play any
92 trick supported by L<Sub::Exporter>, check its documentation for further
93 information.
94  
95 =head2 Class method mode
96  
97 Otherwise, functions are available as class methods, called as:
98  
99 File::ShareDir::PathClass->method();
100  
101 In this case, one doesn't need to import anything during module use-age.
102  
103 =for Pod::Coverage dist_.*
104 module_.*
105 class_.*
106  
107 =head1 SEE ALSO
108  
109 Find other relevant information in L<File::ShareDir> and L<Path::Class>.
110  
111 You can also look for information on this module at:
112  
113 =over 4
114  
115 =item * AnnoCPAN: Annotated CPAN documentation
116  
117 L<http://annocpan.org/dist/File-ShareDir-PathClass>
118  
119 =item * CPAN Ratings
120  
121 L<http://cpanratings.perl.org/d/File-ShareDir-PathClass>
122  
123 =item * Open bugs
124  
125 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-ShareDir-PathClass>
126  
127 =item * Git repository
128  
129 L<http://github.com/jquelin/file-sharedir-pathclass.git>.
130  
131 =back
132  
133 =head1 AUTHOR
134  
135 Jerome Quelin
136  
137 =head1 COPYRIGHT AND LICENSE
138  
139 This software is copyright (c) 2010 by Jerome Quelin.
140  
141 This is free software; you can redistribute it and/or modify it under
142 the same terms as the Perl 5 programming language system itself.
143  
144 =cut
145  
146  
147 __END__
↑ Summary