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#
9use 5.010;
10use strict;
11use warnings;
12
13package File::ShareDir::PathClass;
14{
15  $File::ShareDir::PathClass::VERSION = '1.112440';
16}
17# ABSTRACT: File::ShareDir returning Path::Class objects
18
19use File::ShareDir ();
20use Path::Class;
21use Sub::Exporter -setup => {
22    exports => [ @File::ShareDir::EXPORT_OK ],
23    #groups => {    },
24};
25
26
27# wrap all file::sharedir relevant methods
28foreach my $sub ( @File::ShareDir::EXPORT_OK ) {
29    no strict 'refs';   ## no critic
30    # create a new sub...
31    *{ $sub } = sub {
32        shift if defined($_[0]) && $_[0] eq __PACKAGE__;
33        # ... that just pass through to file::sharedir method...
34        my $result = "File::ShareDir::$sub"->(@_);
35        # ... and wrap the result as a path::class object
36        return $sub =~ /_file\z/ ? file( $result ) : dir( $result );
37    };
38}
39
401;
41
42
43=pod
44
45=head1 NAME
46
47File::ShareDir::PathClass - File::ShareDir returning Path::Class objects
48
49=head1 VERSION
50
51version 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
67This module is just a wrapper around L<File::ShareDir> functions,
68transforming their return value to L<Path::Class> objects. This allows
69for easier usage of the value.
70
71Refer to L<File::ShareDir> (section FUNCTIONS) for a list of which
72functions are supported.
73
74C<File::ShareDir::PathClass> supports both a procedural and a clas
75methods API.
76
77=head2 Procedural mode
78
79All functions are exportable. Nothing is exported by default, though.
80One has to list which function(s) she wants to import.
81
82Some groups are defined for your convenience:
83
84=over 4
85
86=item * C<all> - all available functions.
87
88=back
89
90Note that this module is exporting subs via L<Sub::Exporter>, so groups
91are available either as C<:group> or C<-group>. One can also play any
92trick supported by L<Sub::Exporter>, check its documentation for further
93information.
94
95=head2 Class method mode
96
97Otherwise, functions are available as class methods, called as:
98
99    File::ShareDir::PathClass->method();
100
101In 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
109Find other relevant information in L<File::ShareDir> and L<Path::Class>.
110
111You can also look for information on this module at:
112
113=over 4
114
115=item * AnnoCPAN: Annotated CPAN documentation
116
117L<http://annocpan.org/dist/File-ShareDir-PathClass>
118
119=item * CPAN Ratings
120
121L<http://cpanratings.perl.org/d/File-ShareDir-PathClass>
122
123=item * Open bugs
124
125L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-ShareDir-PathClass>
126
127=item * Git repository
128
129L<http://github.com/jquelin/file-sharedir-pathclass.git>.
130
131=back
132
133=head1 AUTHOR
134
135Jerome Quelin
136
137=head1 COPYRIGHT AND LICENSE
138
139This software is copyright (c) 2010 by Jerome Quelin.
140
141This is free software; you can redistribute it and/or modify it under
142the same terms as the Perl 5 programming language system itself.
143
144=cut
145
146
147__END__
148
149