| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of File-HomeDir-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::HomeDir::PathClass; | ||||||||||||||||||||||||||||
| 14 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 3 | $File::HomeDir::PathClass::VERSION = '1.112060'; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | # ABSTRACT: File::HomeDir returning Path::Class objects | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use File::HomeDir 0.93 (); | ||||||||||||||||||||||||||
|
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::HomeDir::EXPORT_OK ], | ||||||||||||||||||||||||||||
| 23 | #groups => { }, | ||||||||||||||||||||||||||||
| 24 | 3 | }; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # wrap all file::homedir relevant methods | ||||||||||||||||||||||||||||
| 28 | 3 | foreach my $sub ( @File::HomeDir::EXPORT_OK ) { | |||||||||||||||||||||||||||
| 29 | 3 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | # create a new sub... | ||||||||||||||||||||||||||||
| 31 | 51 | ▶ | *{ $sub } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 32 | 8 | ▶ | shift if defined($_[0]) && $_[0] eq __PACKAGE__; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and $_[0] eq __PACKAGE__
MC/DC50%1/2
defined $_[0] and $_[0] eq __PACKAGE__
defined $_[0]
$_[0] eq __PACKAGE__
Truth table66%2/3
A and B
A= defined $_[0]B= $_[0] eq __PACKAGE__
| |||||||||||||||||||||||||||||
| 33 | # ... that just pass through to file::homedir method... | ||||||||||||||||||||||||||||
| 34 | 8 | my $result = *{"File::HomeDir::$sub"}->(@_); | |||||||||||||||||||||||||||
| 35 | # ... and wrap the result as a path::class object | ||||||||||||||||||||||||||||
| 36 | 8 | return dir( $result ); | |||||||||||||||||||||||||||
| 37 | 51 | }; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3 | 1; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =pod | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 NAME | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | File::HomeDir::PathClass - File::HomeDir returning Path::Class objects | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 VERSION | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | version 1.112060 | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | use File::HomeDir::PathClass '-all'; | ||||||||||||||||||||||||||||
| 56 | my $home = home(); | ||||||||||||||||||||||||||||
| 57 | # $home is a Path::Class object now | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # - or - | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | use File::HomeDir::PathClass; | ||||||||||||||||||||||||||||
| 62 | my $home = File::HomeDir::PathClass->home; | ||||||||||||||||||||||||||||
| 63 | # $home is a Path::Class object now | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | This module is just a wrapper around L<File::HomeDir> methods, | ||||||||||||||||||||||||||||
| 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::HomeDir#METHODS> for a list of which functions are | ||||||||||||||||||||||||||||
| 72 | supported. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | C<File::HomeDir::PathClass> supports both original L<File::HomeDir> interfaces. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =head2 Procedural mode | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | All functions are exportable. Nothing is exported by default, though. | ||||||||||||||||||||||||||||
| 79 | One has to list which function(s) she wants to import. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Some groups are defined for your convenience: | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =over 4 | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item * C<all> - all available functions. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =back | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Note that this module is exporting subs via L<Sub::Exporter>, so groups | ||||||||||||||||||||||||||||
| 90 | are available either as C<:group> or C<-group>. One can also play any | ||||||||||||||||||||||||||||
| 91 | trick supported by L<Sub::Exporter>, check its documentation for further | ||||||||||||||||||||||||||||
| 92 | information. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head2 Class method mode | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Otherwise, functions are available as class methods, called as: | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | File::HomeDir::PathClass->method(); | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | In this case, one doesn't need to import anything during module use-age. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =for Pod::Coverage home my_.* users_.* | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Find other relevant information in L<File::HomeDir> and L<Path::Class>. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | You can also look for information on this module at: | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =over 4 | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | L<http://annocpan.org/dist/File-HomeDir-PathClass> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | L<http://cpanratings.perl.org/d/File-HomeDir-PathClass> | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =item * Open bugs | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-HomeDir-PathClass> | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =item * Git repository | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | L<http://github.com/jquelin/file-homedir-pathclass.git>. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =back | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Jerome Quelin | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | This software is copyright (c) 2010 by Jerome Quelin. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 139 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =cut | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||||||||||