Footprintless::Util - A utility method package for common functionality in Footprintless
version 1.21
use Footprintless::Util qw( agent clean default_command_runner dumper exit_due_to extract slurp spurt temp_dir ); my $agent = agent(); my $command_runner = default_command_runner(); my $dumper = dumper(); eval { $command_runner->run_or_die('cat /foo/bar'); }; exit_due_to($@) if ($@); my $content = slurp('/foo/bar'); spurt('baz', '/foo/bar', append => 1);
This module contains common utility methods used by Footprintless.
Returns a new agent. By default env_proxy
is set. The supported options are:
A hashref for storing cookies. If not supplied, cookies will be ignored.
The http request timeout.
Removes all the entries in $paths
(must be an array ref). If an entry ends with a /
it is assumed to be a directory, and will be recreated.
Returns a new instance of the default implementation of Footprintless::CommandRunner
.
Prints a dump of @to_dump
using Data::Dumper
with Data::Dumper::Indent
set to 1.
Require's and creates a new instance of $module_name
, passing @new_args
to the new
method.
If $reason
is an instance of Footprintless::CommandRunner::ExecutionException, $reason->exit()
will be called. Otherwise, $reason
will be printed to STDERR
and exit(255)
will be called. The $verbose
argument will be passed on thusly: $reason->exit($verbose)
.
Will extract $archive
. Will attempt to use Archive::Extract::Libarchive and if not found, will use Archive::Extract. The available options are:
The location to extract to. Defaults to cwd.
The type of the archive. If not specified, the type will be inferred by the file extension according to Lib::Archive. The following additional extensions will be inferred as type zip
: ear
, jar
, twbx
, war
.
Creates a new Footprintless::Factory. $entities
can be either, a hashref, or a Config::Entities object. If a hashref, it will be used to create a new entities object, then passed along with options to the Footprintless::Factory
constructor.
Dies with an instance of Footprintless::InvalidEntityException.
Replaces a portion of the start of $path
. \%rebase
must have 2 keys, from
and to
. The from
value will be removed from $path
and replaced with the to
value.
Reads the entire contents of $file
in one gulp. If $file
is omitted, then it will read STDIN
.
Writes $content
to $file
. The available options are:
Creates a new temporary file with mode 0600
Returns the new File::Temp object. Uses File::Temp
so you can set File::Temp::HIGH
for extra safety.
Creates a new temporary directory with mode 2700
. Returns the new File::Temp object. Uses File::Temp
so you can set File::Temp::HIGH
for extra safety.
If truthy, $content
will be appended to $file
instead of overwriting.
Lucas Theisen <lucastheisen@pastdev.com>
This software is copyright (c) 2016 by Lucas Theisen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Please see those modules/websites for more information related to this module.