NAME
Footprintless::Util - A utility method package for common functionality in Footprintless
VERSION
version 1.0
SYNOPSIS
use Footprintless::Util qw(
agent
default_command_runner
dumper
exit_due_to
slurp
spurt
);
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);
DESCRIPTION
This module contains common utility methods used by Footprintless.
FUNCTIONS
agent()
Returns a new instance of LWP::UserAgent
configured with env_proxy
.
default_command_runner()
Returns a new instance of the default implementation of Footprintless::CommandRunner
.
dumper(@to_dump)
Prints a dump of @to_dump
using Data::Dumper
with Data::Dumper::Indent
set to 1.
exit_due_to($reason)
If $reason
is an instance of Footprintless::CommandRunner::Exception
, $reason->exit()
will be called. Otherwise, $reason
will be printed to STDERR
and exit(255)
will be called.
slurp($file)
Reads the entire contents of $file
in one gulp.
spurt($content, $file, %options)
Writes $content
to $file
. The available options are:
- append
-
If truthy,
$content
will be appended to$file
instead of overwriting.
AUTHOR
Lucas Theisen <lucastheisen@pastdev.com>
COPYRIGHT AND LICENSE
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.
SEE ALSO
Please see those modules/websites for more information related to this module.