Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

test::file::sharedir(3pm) [debian man page]

Test::File::ShareDir(3pm)				User Contributed Perl Documentation				 Test::File::ShareDir(3pm)

NAME
Test::File::ShareDir - Create a Fake ShareDir for your modules for testing. VERSION
version 0.3.1 SYNOPSIS
use Test::More; # use FindBin; optional use Test::File::ShareDir # -root => "$FindBin::Bin/../" # optional, -share => { -module => { 'My::Module' => 'share/MyModule' } -dist => { 'My-Dist' => 'share/somefolder' } }; use My::Module; use File::ShareDir qw( module_dir dist_dir ); module_dir( 'My::Module' ) # dir with files from $dist/share/MyModule dist_dir( 'My-Dist' ) # dir with files from $dist/share/somefolder DESCRIPTION
This module only has support for creating 'new' style share dirs and are NOT compatible with old File::ShareDirs. For this reason, unless you have File::ShareDir 1.00 or later installed, this module will not be usable by you. IMPORTING
-root This parameter is the prefix the other paths are relative to. If this parameter is not specified, it defaults to the Current Working Directory ( "CWD" ). In versions prior to 0.3.0, this value was mandatory. The rationale behind using "CWD" as the default value is as follows. o Most users of this module are likely to be using it to test distributions o Most users of this module will be using it in "$project/t/" to load files from "$project/share/" o Most "CPAN" tools run tests with "CWD" = $project Therefor, defaulting to "CWD" is a reasonably sane default for most people, but where it is not it can still be overridden. -root => "$FindBin::Bin/../" # resolves to project root from t/ regardless of Cwd. -share This parameter is mandatory, and contains a "hashref" containing the data that explains what directories you want shared. -share => { ..... } -module "-module" contains a "hashref" mapping Module names to path names for module_dir style share dirs. -share => { -module => { 'My::Module' => 'share/mymodule/', } } ... module_dir('My::Module') Notedly, it is a "hashref", which means there is a limitation of one share dir per module. This is simply because having more than one share dir per module makes no sense at all. -dist "-dist" contains a "hashref" mapping Distribution names to path names for dist_dir style share dirs. The same limitation applied to "-module" applies here. -share => { -dist => { 'My-Dist' => 'share/mydist' } } ... dist_dir('My-Dist') AUTHOR
Kent Fredric <kentnl@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Kent Fredric <kentnl@cpan.org>. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-24 Test::File::ShareDir(3pm)

Check Out this Related Man Page

File::UserConfig(3pm)					User Contributed Perl Documentation				     File::UserConfig(3pm)

NAME
File::UserConfig - Get a user's existing config directory, or copy in defaults # The most simple Do What I Mean usage. $configdir = File::UserConfig->configdir; # Or without taking advantage of convention-based defaults $configdir = File::UserConfig->new( dist => 'My-Application', module => 'My::Application', dirname => '.myapp', sharedir => $defaults_here, )->configdir; DESCRIPTION
Many modules or applications maintain a user-spec configuration data directory. And the implementation pattern is generally the same. A directory like /home/myuser/.application is created and populating by a set of default files the first time an application runs, and from there on, the files in that directory are modified. "File::UserConfig" provides standard, light and sub-classable default implementation of this concept that Does The Right Thing with the directory names. Applying Perl Conventions "File::UserConfig" applies and automates the following conventions. 1. We are using the distribution name? The use of "File::ShareDir" is based on distribution name (more on that later) so we need to know it. The CPAN convention is for a dist to be named "Foo-Bar" after the main module "Foo::Bar" in the distribution, but sometimes this varies, and sometimes you will want to call "File::UserConfig" from other than the main module. But unless you say otherwise, "File::UserConfig" will assume that if you call it from "Module::Name", that is probably the main module, and thus your dist is probably called "Module-Name". 2. What config directory name is used On platforms which keep application-specific data in its own directory, well away from the data the user actually create themself, we just use the dist name. On Unix, which has a combined home directory, we remap the dist name to be a lowercase hidden name with all '-' chars as '_'. So on unix only, "Module::Name" will become ".module_name". Most of the time, this will end up what you would have used anyway. 3. Where does the config directory live "File::UserConfig" knows where your home directory is by using File::HomeDir. And more specifically, on platforms that support application data being kept in a subdirectory, it will use that as well. On Unix, Windows, and Mac OS X, it will just Do The Right Thing. 4. Where do the defaults come from? The ability for a distribution to provide a directory full of default files is provided in Perl by File::ShareDir. Of course, we're also assuming you are using Module::Install so you have access to its "install_share" command, and that the only thing your dist is going to install to it will be the default config dir. METHODS
The 6 accessors all feature implicit constructors. In other words, the two following lines are equivalent. # Explicitly $configdir = File::UserConfig->new( ... )->configdir; # Auto-construction $configdir = File::UserConfig->configdir( ... ); # Thus, using all default params we can just $configdir = File::UserConfig->configdir; new my $config = File::UserConfig->new( dist => 'Not-This-Class', dirname => '.myconfig', sharedir => 'defaultconfig', homedir => $username, ); The "new" constructor takes a set of optional named params, and finds the user's configuration directory, creating it by copying in a default directory if an existing one cannot be found. In almost every case, you will want to use all the defaults and let everything be determined automatically for you. The sample above tries to show some of the limited number of situations in which you might want to consider providing your own values. But most times, you don't want to or need to. Try it without params first, and add some params if it isn't working for you. If you want to do some custom actions after you copy in the directory, the subclass and add it after you call the parent "new" method. Returns a new "File::UserConfig" object, or dies on error. dist $name = File::UserConfig->new(...)->dist; $name = File::UserConfig->dist(...); The "dist" accessor returns the name of the distribution. module $name = File::UserConfig->new(...)->module; $name = File::UserConfig->module(...); The "module" accessor returns the name of the module. Although the default dirname is based off the dist name, the module name is the one used to find the shared dir. dirname $dir = File::UserConfig->new(...)->dirname; $dir = File::UserConfig->dirname(...); The "dirname" accessor returns the name to be used for the config directory name, below the homedir. For example '.foo_bar'. sharedir $dir = File::UserConfig->new(...)->sharedir; $dist = File::UserConfig->sharedir(...); The "sharedir" accessor returns the name of the directory where the shared default configuration is held. Returns a path string, verified to exist before being returned. homedir $dir = File::UserConfig->new(...)->homedir; $dist = File::UserConfig->homedir(...); The "homedir" accessor returns the location of the home direcotry, that the config dir will be created or found below. Returns a path string, verified to exist before being returned. configdir $dir = File::UserConfig->new(...)->configdir; $dist = File::UserConfig->configdir(...); The "sharedir" accessor returns the name of the directory where the shared default configuration is held. Returns a path string, verified to exist before being returned. SUPPORT
Bugs should always be submitted via the CPAN bug tracker <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-UserConfig> For other issues, contact the maintainer AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
File::HomeDir, File::ShareDir COPYRIGHT
Copyright 2006 - 2008 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. perl v5.10.1 2008-08-24 File::UserConfig(3pm)
Man Page