<html><head><title>Footprintless::Util</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" >
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
BODY {
background: white;
color: black;
font-family: arial,sans-serif;
margin: 0;
padding: 1ex;
}
A:link, A:visited {
background: transparent;
color: #006699;
}
A[href="#POD_ERRORS"] {
background: transparent;
color: #FF0000;
}
DIV {
border-width: 0;
}
DT {
margin-top: 1em;
margin-left: 1em;
}
.pod { margin-right: 20ex; }
.pod PRE {
background: #eeeeee;
border: 1px solid #888888;
color: black;
padding: 1em;
white-space: pre;
}
.pod H1 {
background: transparent;
color: #006699;
font-size: large;
}
.pod H1 A { text-decoration: none; }
.pod H2 A { text-decoration: none; }
.pod H3 A { text-decoration: none; }
.pod H4 A { text-decoration: none; }
.pod H2 {
background: transparent;
color: #006699;
font-size: medium;
}
.pod H3 {
background: transparent;
color: #006699;
font-size: medium;
font-style: italic;
}
.pod H4 {
background: transparent;
color: #006699;
font-size: medium;
font-weight: normal;
}
.pod IMG {
vertical-align: top;
}
.pod .toc A {
text-decoration: none;
}
.pod .toc LI {
line-height: 1.2em;
list-style-type: none;
}
/*]]>*/-->
</style>
</head>
<body class='pod'>
<!--
generated by Pod::Simple::HTML v3.32,
using Pod::Simple::PullParser v3.32,
under Perl v5.025000 at Wed Aug 22 21:48:32 2018 GMT.
If you want to change this HTML document, you probably shouldn't do that
by changing it directly. Instead, see about changing the calling options
to Pod::Simple::HTML, and/or subclassing Pod::Simple::HTML,
then reconverting this document from the Pod source.
When in doubt, email the author of Pod::Simple::HTML for advice.
See 'perldoc Pod::Simple::HTML' for more info.
-->
<!-- start doc -->
<a name='___top' class='dummyTopAnchor' ></a>
<div class='indexgroup'>
<ul class='indexList indexList1'>
<li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
<li class='indexItem indexItem1'><a href='#VERSION'>VERSION</a>
<li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
<li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
<li class='indexItem indexItem1'><a href='#FUNCTIONS'>FUNCTIONS</a>
<ul class='indexList indexList2'>
<li class='indexItem indexItem2'><a href='#agent(%25options)'>agent(%options)</a>
<li class='indexItem indexItem2'><a href='#clean(%24paths%2C_%25options)'>clean($paths, %options)</a>
<li class='indexItem indexItem2'><a href='#default_command_runner()'>default_command_runner()</a>
<li class='indexItem indexItem2'><a href='#dumper(%40to_dump)'>dumper(@to_dump)</a>
<li class='indexItem indexItem2'><a href='#dynamic_module_new(%24module_name%2C_%40new_args)'>dynamic_module_new($module_name, @new_args)</a>
<li class='indexItem indexItem2'><a href='#exit_due_to(%24reason%2C_%24verbose)'>exit_due_to($reason, $verbose)</a>
<li class='indexItem indexItem2'><a href='#extract(%24archive%2C_%25options)'>extract($archive, %options)</a>
<li class='indexItem indexItem2'><a href='#factory(%24entities%2C_%25options)'>factory($entities, %options)</a>
<li class='indexItem indexItem2'><a href='#invalid_entity(%24message%2C_%24coordinate)'>invalid_entity($message, $coordinate)</a>
<li class='indexItem indexItem2'><a href='#rebase(%24path%2C_%5C%25rebase)'>rebase($path, \%rebase)</a>
<li class='indexItem indexItem2'><a href='#slurp(%5B%24file%5D)'>slurp([$file])</a>
<li class='indexItem indexItem2'><a href='#spurt(%24content%2C_%24file%2C_%25options)'>spurt($content, $file, %options)</a>
<li class='indexItem indexItem2'><a href='#temp_file()'>temp_file()</a>
<li class='indexItem indexItem2'><a href='#temp_dir()'>temp_dir()</a>
<li class='indexItem indexItem2'><a href='#terse_dumper(%40to_dump)'>terse_dumper(@to_dump)</a>
</ul>
<li class='indexItem indexItem1'><a href='#AUTHOR'>AUTHOR</a>
<li class='indexItem indexItem1'><a href='#COPYRIGHT_AND_LICENSE'>COPYRIGHT AND LICENSE</a>
<li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
</ul>
</div>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="NAME"
>NAME</a></h1>
<p>Footprintless::Util - A utility method package for common functionality in Footprintless</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="VERSION"
>VERSION</a></h1>
<p>version 1.29</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SYNOPSIS"
>SYNOPSIS</a></h1>
<pre> 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);</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DESCRIPTION"
>DESCRIPTION</a></h1>
<p>This module contains common utility methods used by Footprintless.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="FUNCTIONS"
>FUNCTIONS</a></h1>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="agent(%options)"
>agent(%options)</a></h2>
<p>Returns a new <a href="http://search.cpan.org/perldoc?LWP%3A%3AUserAgent" class="podlinkpod"
>agent</a>. By default <code>env_proxy</code> is set. The supported options are:</p>
<dl>
<dt><a name="cookie_jar"
>cookie_jar</a></dt>
<dd>
<p>A hashref for storing cookies. If not supplied, cookies will be ignored.</p>
<dt><a name="timeout"
>timeout</a></dt>
<dd>
<p>The http request timeout.</p>
</dd>
</dl>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="clean($paths,_%options)"
>clean($paths, %options)</a></h2>
<p>Removes all the entries in <code>$paths</code> (must be an array ref). If an entry ends with a <code>/</code> it is assumed to be a directory, and will be recreated.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="default_command_runner()"
>default_command_runner()</a></h2>
<p>Returns a new instance of the default implementation of <code>Footprintless::CommandRunner</code>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="dumper(@to_dump)"
>dumper(@to_dump)</a></h2>
<p>Prints a dump of <code>@to_dump</code> using <code>Data::Dumper</code> with <code>Data::Dumper::Indent</code> set to 1.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="dynamic_module_new($module_name,_@new_args)"
>dynamic_module_new($module_name, @new_args)</a></h2>
<p>Require's and creates a new instance of <code>$module_name</code>, passing <code>@new_args</code> to the <code>new</code> method.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="exit_due_to($reason,_$verbose)"
>exit_due_to($reason, $verbose)</a></h2>
<p>If <code>$reason</code> is an instance of <a href="http://search.cpan.org/perldoc?Footprintless%3A%3ACommandRunner%3A%3AExecutionException" class="podlinkpod"
>Footprintless::CommandRunner::ExecutionException</a>, <code>$reason->exit()</code> will be called. Otherwise, <code>$reason</code> will be printed to <code>STDERR</code> and <code>exit(255)</code> will be called. The <code>$verbose</code> argument will be passed on thusly: <code>$reason->exit($verbose)</code>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="extract($archive,_%options)"
>extract($archive, %options)</a></h2>
<p>Will extract <code>$archive</code>. Will attempt to use <a href="http://search.cpan.org/perldoc?Archive%3A%3AExtract%3A%3ALibarchive" class="podlinkpod"
>Archive::Extract::Libarchive</a> and if not found, will use <a href="http://search.cpan.org/perldoc?Archive%3A%3AExtract" class="podlinkpod"
>Archive::Extract</a>. The available options are:</p>
<dl>
<dt><a name="to"
>to</a></dt>
<dd>
<p>The location to extract to. Defaults to <a href="http://search.cpan.org/perldoc?Cwd#cwd" class="podlinkpod"
>cwd</a>.</p>
<dt><a name="type"
>type</a></dt>
<dd>
<p>The type of the archive. If not specified, the type will be inferred by the file extension according to <a href="http://search.cpan.org/perldoc?Lib%3A%3AArchive" class="podlinkpod"
>Lib::Archive</a>. The following additional extensions will be inferred as type <code>zip</code>: <code>ear</code>, <code>jar</code>, <code>twbx</code>, <code>war</code>.</p>
</dd>
</dl>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="factory($entities,_%options)"
>factory($entities, %options)</a></h2>
<p>Creates a new <a href="http://search.cpan.org/perldoc?Footprintless%3A%3AFactory" class="podlinkpod"
>Footprintless::Factory</a>. <code>$entities</code> can be either, a hashref, or a <a href="http://search.cpan.org/perldoc?Config%3A%3AEntities" class="podlinkpod"
>Config::Entities</a> object. If a hashref, it will be used to create a new entities object, then passed along with options to the <code>Footprintless::Factory</code> constructor.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="invalid_entity($message,_$coordinate)"
>invalid_entity($message, $coordinate)</a></h2>
<p>Dies with an instance of <a href="http://search.cpan.org/perldoc?Footprintless%3A%3AInvalidEntityException" class="podlinkpod"
>Footprintless::InvalidEntityException</a>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="rebase($path,_\%rebase)"
>rebase($path, \%rebase)</a></h2>
<p>Replaces a portion of the start of <code>$path</code>. <code>\%rebase</code> must have 2 keys, <code>from</code> and <code>to</code>. The <code>from</code> value will be removed from <code>$path</code> and replaced with the <code>to</code> value.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="slurp([$file])"
>slurp([$file])</a></h2>
<p>Reads the entire contents of <code>$file</code> in one gulp. If <code>$file</code> is omitted, then it will read <code>STDIN</code>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="spurt($content,_$file,_%options)"
>spurt($content, $file, %options)</a></h2>
<p>Writes <code>$content</code> to <code>$file</code>. The available options are:</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="temp_file()"
>temp_file()</a></h2>
<p>Creates a new temporary file with mode <code>0600</code> Returns the new <a href="http://search.cpan.org/perldoc?File%3A%3ATemp" class="podlinkpod"
>File::Temp</a> object. Uses <code>File::Temp</code> so you can set <code>File::Temp::HIGH</code> for extra safety.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="temp_dir()"
>temp_dir()</a></h2>
<p>Creates a new temporary directory with mode <code>2700</code>. Returns the new <a href="http://search.cpan.org/perldoc?File%3A%3ATemp" class="podlinkpod"
>File::Temp</a> object. Uses <code>File::Temp</code> so you can set <code>File::Temp::HIGH</code> for extra safety.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="terse_dumper(@to_dump)"
>terse_dumper(@to_dump)</a></h2>
<p>Prints a dump of <code>@to_dump</code> using <code>Data::Dumper</code> with <code>Data::Dumper::Indent</code> set to 1 and <code>Data::Dumper::Terse</code> set to 1 - this will basically be the same as the <code>dumper()</code> function, except it will not include the variable name (<code>$VAR1 = </code>).</p>
<dl>
<dt><a name="append"
>append</a></dt>
<dd>
<p>If <i>truthy</i>, <code>$content</code> will be appended to <code>$file</code> instead of overwriting.</p>
</dd>
</dl>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="AUTHOR"
>AUTHOR</a></h1>
<p>Lucas Theisen <lucastheisen@pastdev.com></p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="COPYRIGHT_AND_LICENSE"
>COPYRIGHT AND LICENSE</a></h1>
<p>This software is copyright (c) 2016 by Lucas Theisen.</p>
<p>This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.</p>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="SEE_ALSO"
>SEE ALSO</a></h1>
<p>Please see those modules/websites for more information related to this module.</p>
<ul>
<li><a href="http://search.cpan.org/perldoc?Footprintless" class="podlinkpod"
>Footprintless</a></li>
</ul>
<!-- end doc -->
</body></html>