-
-
20 Nov 2007 02:14:45 UTC
- Distribution: Data-Package
- Module version: 1.05
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (538 / 158 / 1)
- Kwalitee
Bus factor: 1- 79.03% Coverage
- License: perl_5
- Perl: v5.5.0
- Activity
24 month- Tools
- Download (27.11KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
++ed by:1 non-PAUSE user- Dependencies
- Class::Inspector
- File::ShareDir
- File::Spec
- Params::Coerce
- Params::Util
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Data::Package::File - Data::Package base class for data stored in a local file
DESCRIPTION
The Data::Package::File base class provides a series of additional methods that ease the development of Data::Package classes that source their data from files on the local filesystem.
METHODS
Data::Package::File extends the interface of Data::Package with a few additional methods.
file
my $to_load = My::Data:Class->file;
The
file
method can be defined by a Data::Package::File subclass, and should return an absolute path for a file reable by the current user, in the form of a simple scalar string.At load-time, this value will be checked for correctness, and if the value returned is invalid, loading of the file will fail.
dist_file
package My::Dist::DataSubclass; sub dist_file { return ( 'My-Dist', 'data.txt' ); }
The
dist_file
method is one of two that provide integration with File::ShareDir. Instead of defining afile
method, you can instead definedist_file
.If
dist_file
exists, and any values are returned, those values will be passed through to theFile::ShareDir::dist_file
function, with the resulting value converted to an absolute path (if needed) and used to provide the appropriate object to the caller.Should return a list with two values, the name of the distribution the package is in, and the file path within the package's share directory.
module_file
package My::DataClass; # Get a file from this module sub module_file { return 'data.txt'; } # Get a file for another (loaded) module sub module_file { return ( 'My::RelatedClass', 'data.txt' ); }
The
dist_file
method is one of two that provide integration with File::ShareDir. Instead of defining afile
method, you can instead definemodule_file
.If
module_file
exists, and any values are returned, those values will be passed through to theFile::ShareDir::module_file
function, with the resulting value converted to an absolute path (if needed) and used to provide the appropriate object to the caller.Should return a list with two values, the module to get the shared files for, and the the file path within the module's share directory.
If
module_file
returns a single value, the name of the class will be automatically prepended as the module name.SUPPORT
Bugs should always be submitted via the CPAN bug tracker.
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Package
For other issues, contact the maintainer
AUTHOR
Adam Kennedy <adamk@cpan.org>
COPYRIGHT
Copyright 2007 Adam Kennedy.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Module Install Instructions
To install Data::Package, copy and paste the appropriate command in to your terminal.
cpanm Data::Package
perl -MCPAN -e shell install Data::Package
For more information on module installation, please visit the detailed CPAN module installation guide.