File Coverage

blib/lib/File/ShareDir/PathClass.pm
Criterion Covered Total %
statement 21 24 87.5
branch 0 4 0.0
condition 0 3 0.0
subroutine 7 8 87.5
pod n/a
total 28 39 71.7


line stmt bran cond sub pod time code
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 2     2   29986 use 5.010;
  2         11  
  2         111  
10 2     2   14 use strict;
  2         6  
  2         67  
11 2     2   14 use warnings;
  2         4  
  2         140  
12              
13             package File::ShareDir::PathClass;
14             {
15             $File::ShareDir::PathClass::VERSION = '1.112440';
16             }
17             # ABSTRACT: File::ShareDir returning Path::Class objects
18              
19 2     2   12 use File::ShareDir ();
  2         4  
  2         39  
20 2     2   2970 use Path::Class;
  2         803252  
  2         248  
21 2         30 use Sub::Exporter -setup => {
22             exports => [ @File::ShareDir::EXPORT_OK ],
23             #groups => { },
24 2     2   4895 };
  2         627490  
25              
26              
27             # wrap all file::sharedir relevant methods
28             foreach my $sub ( @File::ShareDir::EXPORT_OK ) {
29 2     2   1700 no strict 'refs'; ## no critic
  2         5  
  2         936  
30             # create a new sub...
31             *{ $sub } = sub {
32 0 0 0 0     shift if defined($_[0]) && $_[0] eq __PACKAGE__;
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 0         return $sub =~ /_file\z/ ? file( $result ) : dir( $result );
37             };
38             }
39              
40             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__
148