docs/Bovem/ShellMethods/Execute.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Bovem::ShellMethods::Execute
— Documentation by YARD 0.9.7
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
<script type="text/javascript" charset="utf-8">
pathId = "Bovem::ShellMethods::Execute";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (E)</a> »
<span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> » <span class='title'><span class='object_link'><a href="../ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span></span>
»
<span class="title">Execute</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Module: Bovem::ShellMethods::Execute
</h1>
<div class="box_info">
<dl>
<dt>Included in:</dt>
<dd><span class='object_link'><a href="../Shell.html" title="Bovem::Shell (class)">Bovem::Shell</a></span></dd>
</dl>
<dl>
<dt>Defined in:</dt>
<dd>lib/bovem/shell.rb</dd>
</dl>
</div>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>Methods to run commands or delete entries.</p>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong>(*files, run: true, show_errors: false, fatal_errors: true) ⇒ Boolean </a>
</span>
<span class="summary_desc"><div class='inline'><p>Deletes a list of files.</p>
</div></span>
</li>
<li class="public ">
<span class="summary_signature">
<a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong>(command, message = nil, run: true, show_exit: true, show_output: false, show_command: false, fatal_errors: true) ⇒ Hash </a>
</span>
<span class="summary_desc"><div class='inline'><p>Runs a command into the shell.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="delete-instance_method">
#<strong>delete</strong>(*files, run: true, show_errors: false, fatal_errors: true) ⇒ <tt>Boolean</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Deletes a list of files.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>files</span>
<span class='type'>(<tt>Array</tt>)</span>
—
<div class='inline'><p>The list of files to remove</p>
</div>
</li>
<li>
<span class='name'>run</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If <code>false</code>, it will just print a list of message that would be deleted.</p>
</div>
</li>
<li>
<span class='name'>show_errors</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If show errors.</p>
</div>
</li>
<li>
<span class='name'>fatal_errors</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If quit in case of fatal errors.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p><code>true</code> if operation succeeded, <code>false</code> otherwise.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
330
331
332
333
334
335
336
337
338
339
340
341</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 330</span>
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_files'>files</span><span class='comma'>,</span> <span class='label'>run:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>show_errors:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>fatal_errors:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='kw'>true</span>
<span class='id identifier rubyid_files'>files</span> <span class='op'>=</span> <span class='id identifier rubyid_files'>files</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='lparen'>(</span><span class='label'>no_duplicates:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>compact:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>flatten:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span>
<span class='id identifier rubyid_show_dry_delete'>show_dry_delete</span><span class='lparen'>(</span><span class='id identifier rubyid_files'>files</span><span class='rparen'>)</span>
<span class='kw'>else</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_perform_delete'>perform_delete</span><span class='lparen'>(</span><span class='id identifier rubyid_files'>files</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal_errors'>fatal_errors</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
<div class="method_details ">
<h3 class="signature " id="run-instance_method">
#<strong>run</strong>(command, message = nil, run: true, show_exit: true, show_output: false, show_command: false, fatal_errors: true) ⇒ <tt>Hash</tt>
</h3><div class="docstring">
<div class="discussion">
<p>Runs a command into the shell.</p>
</div>
</div>
<div class="tags">
<p class="tag_title">Parameters:</p>
<ul class="param">
<li>
<span class='name'>command</span>
<span class='type'>(<tt>String</tt>)</span>
—
<div class='inline'><p>The string to run.</p>
</div>
</li>
<li>
<span class='name'>message</span>
<span class='type'>(<tt>String</tt>)</span>
<em class="default">(defaults to: <tt>nil</tt>)</em>
—
<div class='inline'><p>A message to show before running.</p>
</div>
</li>
<li>
<span class='name'>run</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If <code>false</code>, it will just print a message with the full command that will be run.</p>
</div>
</li>
<li>
<span class='name'>show_exit</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If show the exit status.</p>
</div>
</li>
<li>
<span class='name'>show_output</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If show command output.</p>
</div>
</li>
<li>
<span class='name'>show_command</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If show the command that will be run.</p>
</div>
</li>
<li>
<span class='name'>fatal_errors</span>
<span class='type'>(<tt>Boolean</tt>)</span>
—
<div class='inline'><p>If quit in case of fatal errors.</p>
</div>
</li>
</ul>
<p class="tag_title">Returns:</p>
<ul class="return">
<li>
<span class='type'>(<tt>Hash</tt>)</span>
—
<div class='inline'><p>An hash with <code>status</code> and <code>output</code> keys.</p>
</div>
</li>
</ul>
</div><table class="source_code">
<tr>
<td>
<pre class="lines">
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 305</span>
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_message'>message</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>run:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>show_exit:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>show_output:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>show_command:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>fatal_errors:</span> <span class='kw'>true</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>status:</span> <span class='int'>0</span><span class='comma'>,</span> <span class='label'>output:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span>
<span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
<span class='comment'># Show the command
</span> <span class='ivar'>@console</span><span class='period'>.</span><span class='id identifier rubyid_begin'>begin</span><span class='lparen'>(</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_message'>message</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
<span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_run'>run</span> <span class='comment'># Print a message
</span> <span class='id identifier rubyid_show_dry_run'>show_dry_run</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='rparen'>)</span>
<span class='kw'>else</span> <span class='comment'># Run
</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_execute_command'>execute_command</span><span class='lparen'>(</span><span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_show_command'>show_command</span><span class='comma'>,</span> <span class='id identifier rubyid_show_output'>show_output</span><span class='rparen'>)</span>
<span class='kw'>end</span>
<span class='comment'># Return
</span> <span class='id identifier rubyid_handle_command_exit'>handle_command_exit</span><span class='lparen'>(</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_show_exit'>show_exit</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal_errors'>fatal_errors</span><span class='rparen'>)</span>
<span class='id identifier rubyid_rv'>rv</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Thu Jan 12 16:10:58 2017 by
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.7 (ruby-2.3.0).
</div>
</div>
</body>
</html>