Data-Tubes
view release on metacpan or search on metacpan
strings
this will be considered a fully qualified sub name, i.e. including
the package name at the beginning.
The package name will be subject to some analysis that will make using
it a bit easier, by means of "resolve_module" in Data::Tubes::Util.
You can optionally pass a hash reference with options as the last
parameter, with the following options:
package
the package where the loaded sub should be imported. Defaults to the
package calling the summon function;
prefix
the prefix to apply when needed. Defaults to Data::Tubes::Plugin.
Note that you MUST NOT put the ::, it will be added automatically.
tube
$tube = tube($factory_locator, @parameters); # OR
$tube = tube(\@factory_locator, @parameters); # OR
$tube = tube(\%opts, $factory_locator, @parameters); # OR
$tube = tube(\%opts, \@factory_locator, @parameters);
this allows you to facilitate the creation of a tube, doing most of the
heavy-lifting automatically.
The first parameter can optionally be a hash reference of options.
Currently, the only supported option is prefix, which allows you to set
an alternative prefix with respect to what Data::Tubes::Util/load_sub
would assume by default.
The following (or first, if %opts is missing) parameter is used as a
locator of a factory method to generate the real tube. It can be either
a string, or an array reference containing two elements, a package name
and a subroutine name inside that package. The function "load_sub" in
Data::Tubes::Util is used to load the factory method automatically,
which means that the package name is subject to the same rules
described in "summon" above.
After the factory function is loaded, it is called with the provided
@parameters and the returned value... returned back.
Hence, this is a quick way to load some factory from a plugin and call
it in one, single call:
# no additional parameters
$files = tube('Source::iterate_files');
# set some parameters for iterate_files
$files = tube('Source::iterate_files', binmode => ':raw');
Most of the times, you are probably looking for "pipeline" above, as
that will eventually call tube automatically.
BUGS AND LIMITATIONS
Report bugs through GitHub (patches welcome) at
https://github.com/polettix/Data-Tubes.
AUTHOR
Flavio Poletti <polettix@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2022 by Flavio Poletti <polettix@cpan.org>
This module is free software. You can redistribute it and/or modify it
under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
( run in 0.581 second using v1.01-cache-2.11-cpan-39bf76dae61 )