ShogunPanda/bovem

View on GitHub
docs/Bovem/ShellMethods/Directories.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Bovem::ShellMethods::Directories
  
    &mdash; 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::Directories";
  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 (D)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Bovem.html" title="Bovem (module)">Bovem</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../ShellMethods.html" title="Bovem::ShellMethods (module)">ShellMethods</a></span></span>
     &raquo; 
    <span class="title">Directories</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::Directories
  
  
  
</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 interact with directories.</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="#create_directories-instance_method" title="#create_directories (instance method)">#<strong>create_directories</strong>(*directories, mode: 0755, run: true, show_errors: false, fatal_errors: true)  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Creates a list of directories, included missing parent directories.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#within_directory-instance_method" title="#within_directory (instance method)">#<strong>within_directory</strong>(directory, restore: true, show_messages: false)  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Executes a block of code in another directory.</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="create_directories-instance_method">
  
    #<strong>create_directories</strong>(*directories, mode: 0755, run: true, show_errors: false, fatal_errors: true)  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Creates a list of directories, included missing parent directories.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>directories</span>
      
      
        <span class='type'>(<tt>Array</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The list of directories to create.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>mode</span>
      
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Initial permissions for the new directories.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>run</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If <code>false</code>, it will just print a list of directories that would be created.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>show_errors</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If show errors.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>fatal_errors</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <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>
      
      
      
        &mdash;
        <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">


424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 424</span>

<span class='kw'>def</span> <span class='id identifier rubyid_create_directories'>create_directories</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_directories'>directories</span><span class='comma'>,</span> <span class='label'>mode:</span> <span class='int'>0755</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='comment'># Adjust directory
</span>  <span class='id identifier rubyid_directories'>directories</span> <span class='op'>=</span> <span class='id identifier rubyid_directories'>directories</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_d'>d</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_d'>d</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='comment'># Just print
</span>    <span class='id identifier rubyid_dry_run_directory_creation'>dry_run_directory_creation</span><span class='lparen'>(</span><span class='id identifier rubyid_directories'>directories</span><span class='rparen'>)</span>
  <span class='kw'>else</span>
    <span class='id identifier rubyid_directories'>directories</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_directory'>directory</span><span class='op'>|</span>
      <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&amp;&amp;=</span> <span class='id identifier rubyid_try_create_directory'>try_create_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='id identifier rubyid_fatal_errors'>fatal_errors</span><span class='comma'>,</span> <span class='id identifier rubyid_directories'>directories</span><span class='comma'>,</span> <span class='id identifier rubyid_show_errors'>show_errors</span><span class='rparen'>)</span>
      <span class='kw'>break</span> <span class='kw'>unless</span> <span class='id identifier rubyid_rv'>rv</span>
    <span class='kw'>end</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="within_directory-instance_method">
  
    #<strong>within_directory</strong>(directory, restore: true, show_messages: false)  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Executes a block of code in another directory.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>directory</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The new working directory.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>restore</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>If to restore the original working directory.</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>show_messages</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>Show informative messages about working directory changes.</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p><code>true</code> if the directory was valid and the code executed, <code>false</code> otherwise.</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


405
406
407
408
409
410
411
412
413
414</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/bovem/shell.rb', line 405</span>

<span class='kw'>def</span> <span class='id identifier rubyid_within_directory'>within_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='label'>restore:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>show_messages:</span> <span class='kw'>false</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_directory'>directory</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_directory'>directory</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_original'>original</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_pwd'>pwd</span>

  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_enter_directory'>enter_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='comma'>,</span> <span class='id identifier rubyid_show_messages'>show_messages</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_move_in'>move_in</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span><span class='rparen'>)</span>
  <span class='kw'>yield</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
  <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_enter_directory'>enter_directory</span><span class='lparen'>(</span><span class='id identifier rubyid_original'>original</span><span class='comma'>,</span> <span class='id identifier rubyid_show_messages'>show_messages</span><span class='comma'>,</span> <span class='id identifier rubyid_i18n'>i18n</span><span class='period'>.</span><span class='id identifier rubyid_move_out'>move_out</span><span class='lparen'>(</span><span class='id identifier rubyid_directory'>directory</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_rv'>rv</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_restore'>restore</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>