Involved Projects and Packages
sorry, no description found
sorry, no description found
String::Formatter is a tool for building sprintf-like formatting routines.
It supports named or positional formatting, custom conversions, fixed
string interpolation, and simple width-matching out of the box. It is easy
to alter its behavior to write new kinds of format string expanders. For
most cases, it should be easy to build all sorts of formatters out of the
options built into String::Formatter.
Normally, String::Formatter will be used to import a sprintf-like routine
referred to as "'stringf'", but which can be given any name you like. This
routine acts like sprintf in that it takes a string and some inputs and
returns a new string:
my $output = stringf "Some %a format %s for you to %u.\n", { ... };
This routine is actually a wrapper around a String::Formatter object
created by importing stringf. In the following code, the entire hashref
after "stringf" is passed to String::Formatter's constructor (the 'new'
method), save for the '-as' key and any other keys that start with a dash.
use String::Formatter
stringf => {
-as => 'fmt_time',
codes => { ... },
format_hunker => ...,
input_processor => ...,
},
stringf => {
-as => 'fmt_date',
codes => { ... },
string_replacer => ...,
hunk_formatter => ...,
},
;
As you can see, this will generate two stringf routines, with different
behaviors, which are installed with different names. Since the behavior of
these routines is based on the 'format' method of a String::Formatter
object, the rest of the documentation will describe the way the object
behaves.
There's also a 'named_stringf' export, which behaves just like the
'stringf' export, but defaults to the 'named_replace' and
'require_named_input' arguments. There's a 'method_stringf' export, which
defaults 'method_replace' and 'require_single_input'. Finally, a
'indexed_stringf', which defaults to 'indexed_replaced' and
'require_arrayref_input'. For more on these, keep reading, and check out
the cookbook.
the String::Formatter::Cookbook manpage provides a number of recipes for
ways to put String::Formatter to use.
a module for when strings are too long to be displayed in...
The synopsis section, above, looks almost indistinguishable from any other
use of Sub::Exporter, apart from the use of 'method_installer'. It is
nearly indistinguishable in behavior, too. The only change is that
subroutines exported from Method::Builder into named slots in
Vehicle::Autobot will be wrapped in a subroutine called
'Vehicle::Autobot::transform'. This will insert a named frame into stack
traces to aid in debugging.
More importantly (for the author, anyway), they will not be removed by
namespace::autoclean. This makes the following code work:
package MyLibrary;
use Math::Trig qw(tan); # uses Exporter.pm
use String::Truncate qw(trunc); # uses Sub::Exporter's defaults
use Sub::Exporter::ForMethods qw(method_installer);
use Mixin::Linewise { installer => method_installer }, qw(read_file);
use namespace::autoclean;
...
1;
After MyLibrary is compiled, 'namespace::autoclean' will remove 'tan' and
'trunc' as foreign contaminants, but will leave 'read_file' in place. It
will also remove 'method_installer', an added win.
This module enables you to export shared globs with Sub::Exporter
collectors
This class provides a set of assertion methods useful for writing tests.
The API is based on JUnit4 and the Test::Unit::Lite manpage and the methods
die on failure.
These assertion methods might be not useful for common the Test::Builder
manpage-based (the Test::Simple manpage, the Test::More manpage, etc.) test
units.
The assertion methods can be used in class which is derived from
'Test::Assert' or used as standard Perl functions after importing them into
user's namespace.
'Test::Assert' can also wrap standard the Test::Simple manpage, the
Test::More manpage or other the Test::Builder manpage-based tests.
The assertions can be also used for run-time checking.
This module checks that you _Changes_ file has an entry for the current
version of the *Module* being tested.
The version information for the distribution being tested is taken out of
the Build data, or if that is not found, out of the Makefile.
It then attempts to open, in order, a file with the name _Changes_ or
_CHANGES_.
The _Changes_ file is then parsed for version numbers. If one and only one
of the version numbers matches the test passes. Otherwise the test fails.
A message with the current version is printed if the test passes, otherwise
dialog messages are printed to help explain the failure.
The _examples_ directory contains examples of the different formats of
_Changes_ files that are recognized.
'Test::Command' intends to bridge the gap between the well tested functions
and objects you choose and their usage in your programs. By examining the
exit status, terminating signal, STDOUT and STDERR of your program you can
determine if it is behaving as expected.
This includes testing the various combinations and permutations of options
and arguments as well as the interactions between the various functions and
objects that make up your program.
The various test functions below can accept either a command string or an
array reference for the first argument. If the command is expressed as a
string it is passed to 'system' as is. If the command is expressed as an
array reference it is dereferenced and passed to 'system' as a list. See
''perldoc -f system'' for how these may differ.
The final argument for the test functions, '$name', is optional. By default
the '$name' is a concatenation of the test function name, the command
string and the expected value. This construction is generally sufficient
for identifying a failing test, but you may always specify your own '$name'
if desired.
Any of the test functions can be used as instance methods on a
'Test::Command' object. This is done by dropping the initial '$cmd'
argument and instead using arrow notation.
All of the following 'exit_is_num' calls are equivalent.
exit_is_num('true', 0);
exit_is_num('true', 0, 'exit_is_num: true, 0');
exit_is_num(['true'], 0);
exit_is_num(['true'], 0, 'exit_is_num: true, 0');
my $cmd = Test::Command->new( cmd => 'true' );
exit_is_num($cmd, 0);
exit_is_num($cmd, 0, 'exit_is_num: true, 0');
$cmd->exit_is_num(0);
$cmd->exit_is_num(0, 'exit_is_num: true, 0');
$cmd = Test::Command->new( cmd => ['true'] );
exit_is_num($cmd, 0);
exit_is_num($cmd, 0, 'exit_is_num: true, 0');
$cmd->exit_is_num(0);
$cmd->exit_is_num(0, 'exit_is_num: true, 0');
This module was written to ensure that a META.yml file, provided with a
standard distribution uploaded to CPAN, meets the specifications that are
slowly being introduced to module uploads, via the use of package makers
and installers such as the ExtUtils::MakeMaker manpage, the Module::Build
manpage and the Module::Install manpage.
See the CPAN::Meta manpage for further details of the CPAN Meta
Specification.
This module scans your project/distribution for any perl files (scripts,
modules, etc) for the presence of windows line endings.
Do you wanna check that every one of your Perl modules in a distribution
has a version number? You wanna make sure you don't forget the brand new
modules you just added? Well, that's the module you have been looking for.
Use it!
Do you wanna check someone else's distribution to make sure the author have
not commited the sin of leaving Perl modules without a version that can be
used to tell if you have this or that feature? 'Test::HasVersion' is also
for you, nasty little fellow.
There's a script _test_version_ which is installed with this distribution.
You may invoke it from within the root directory of a distribution you just
unpacked, and it will check every _.pm_ file in the directory and under
_lib/_ (if any).
$ test_version
You may also provide directories and files as arguments.
$ test_version *.pm lib/ inc/
$ test_version .
(Be warned that many Perl modules in a _t/_ directory do not receive
versions because they are not used outside the distribution.)
Ok. That's not a very useful module by now. But it will be. Wait for the
upcoming releases.
FUNCTIONS
* PRIVATE *_pm_version*
$v = _pm_version($pm);
Parses a PM file and return what it thinks is $VERSION in this file.
(Actually implemented with 'use ExtUtils::MakeMaker;
MM->parse_version($file)'.) '$pm' is the filename (eg.,
_lib/Data/Dumper.pm_).
* *pm_version_ok*
pm_version_ok('Module.pm');
pm_version_ok('M.pm', 'Has valid version');
Checks to see if the given file has a valid version. Actually a valid
version number is defined and not equal to ''undef'' (the string)
which is return by '_pm_version' if a version cannot be determined.
* *all_pm_version_ok*
all_pm_version_ok();
all_pm_version_ok(@PM_FILES);
Checks every given file and _.pm_ files found under given directories
to see if they provide valid version numbers. If no argument is
given, it defaults to check every file _*.pm_ in the current
directory and recurses under the _lib/_ directory (if it exists).
If no test plan was setted, 'Test::HasVersion' will set one after
computing the number of files to be tested. Otherwise, the plan is
left untouched.
* PRIVATE *_list_pm_files*
@pm_files = _list_pm_files(@dirs);
Returns all PM files under the given directories.
* *all_pm_files*
@files = all_pm_files()
@files = all_pm_files(@files_and_dirs);
Implements finding the Perl modules according to the semantics of the
previous function 'all_pm_version_ok'.