<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
  Module: Doing::Util
  
    &mdash; Documentation by YARD 0.9.26
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" />

<script type="text/javascript">
  pathId = "Doing::Util";
  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 (U)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Doing.html" title="Doing (module)">Doing</a></span></span>
     &raquo; 
    <span class="title">Util</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: Doing::Util
  
  
  
</h1>
<div class="box_info">
  

  
  
  <dl>
      <dt>Extended by:</dt>
      <dd><span class='object_link'><a href="" title="Doing::Util (module)">Util</a></span></dd>
  </dl>
  
  
  
  

  
  <dl>
    <dt>Included in:</dt>
    <dd><span class='object_link'><a href="" title="Doing::Util (module)">Util</a></span></dd>
  </dl>
  

  
  <dl>
    <dt>Defined in:</dt>
    <dd>lib/doing/util.rb</dd>
  </dl>
  
</div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>Utilities</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="#args_for_editor-instance_method" title="#args_for_editor (instance method)">#<strong>args_for_editor</strong>(editor)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#deep_merge_hashes-instance_method" title="#deep_merge_hashes (instance method)">#<strong>deep_merge_hashes</strong>(master_hash, other_hash)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Non-destructive version of deep_merge_hashes! See that method.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#deep_merge_hashes!-instance_method" title="#deep_merge_hashes! (instance method)">#<strong>deep_merge_hashes!</strong>(target, overwrite)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Merges a master hash with another hash, recursively.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#default_editor-instance_method" title="#default_editor (instance method)">#<strong>default_editor</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#duplicable%3F-instance_method" title="#duplicable? (instance method)">#<strong>duplicable?</strong>(obj)  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#duplicate_frozen_values-instance_method" title="#duplicate_frozen_values (instance method)">#<strong>duplicate_frozen_values</strong>(target)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#editor_with_args-instance_method" title="#editor_with_args (instance method)">#<strong>editor_with_args</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#exec_available-instance_method" title="#exec_available (instance method)">#<strong>exec_available</strong>(cli)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Test if command line tool is available.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#find_default_editor-instance_method" title="#find_default_editor (instance method)">#<strong>find_default_editor</strong>(editor_for = &#39;default&#39;)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#first_available_exec-instance_method" title="#first_available_exec (instance method)">#<strong>first_available_exec</strong>(*commands)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Return the first valid executable from a list of commands.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#mergable%3F-instance_method" title="#mergable? (instance method)">#<strong>mergable?</strong>(value)  &#x21d2; Boolean </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#merge_default_proc-instance_method" title="#merge_default_proc (instance method)">#<strong>merge_default_proc</strong>(target, overwrite)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#merge_values-instance_method" title="#merge_values (instance method)">#<strong>merge_values</strong>(target, overwrite)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#safe_load_file-instance_method" title="#safe_load_file (instance method)">#<strong>safe_load_file</strong>(filename)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#user_home-instance_method" title="#user_home (instance method)">#<strong>user_home</strong>  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#write_to_file-instance_method" title="#write_to_file (instance method)">#<strong>write_to_file</strong>(file, content, backup: true)  &#x21d2; Object </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Write content to a file.</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="args_for_editor-instance_method">
  
    #<strong>args_for_editor</strong>(editor)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="deep_merge_hashes-instance_method">
  
    #<strong>deep_merge_hashes</strong>(master_hash, other_hash)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Non-destructive version of deep_merge_hashes! See that
method.</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>master_hash</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Hash.html" title="Hash (class)">Hash</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The master hash</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>other_hash</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../Hash.html" title="Hash (class)">Hash</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The other hash</p>
</div>
      
    </li>
  
</ul>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'></span>
      
      
      
        
        <div class='inline'><p>the merged hashes.</p>
</div>
      
    </li>
  
</ul>

</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="deep_merge_hashes!-instance_method">
  
    #<strong>deep_merge_hashes!</strong>(target, overwrite)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Merges a master hash with another hash, recursively.</p>

<p>master_hash - the &quot;parent&quot; hash whose values will be overridden
other_hash  - the other hash whose values will be persisted after the merge</p>

<p>This code was lovingly stolen from some random gem:
<a href="http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html">http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html</a></p>

<p>Thanks to whoever made it.</p>


  </div>
</div>
<div class="tags">
  

</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="default_editor-instance_method">
  
    #<strong>default_editor</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="duplicable?-instance_method">
  
    #<strong>duplicable?</strong>(obj)  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
    </li>
  
</ul>

</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="duplicate_frozen_values-instance_method">
  
    #<strong>duplicate_frozen_values</strong>(target)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="editor_with_args-instance_method">
  
    #<strong>editor_with_args</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="exec_available-instance_method">
  
    #<strong>exec_available</strong>(cli)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Test if command line tool is available</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>cli</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The name or path of the cli</p>
</div>
      
    </li>
  
</ul>


</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="find_default_editor-instance_method">
  
    #<strong>find_default_editor</strong>(editor_for = &#39;default&#39;)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="first_available_exec-instance_method">
  
    #<strong>first_available_exec</strong>(*commands)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Return the first valid executable from a list of commands</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
        <p class="example_title"><div class='inline'><p><code>Doing::Util.first_available_exec(&#39;bat&#39;, &#39;less -Xr&#39;, &#39;more -r&#39;, &#39;cat&#39;)</code></p>
</div></p>
      
      <pre class="example code"><code></code></pre>
    
  </div>


</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="mergable?-instance_method">
  
    #<strong>mergable?</strong>(value)  &#x21d2; <tt>Boolean</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
    </li>
  
</ul>

</div>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="merge_default_proc-instance_method">
  
    #<strong>merge_default_proc</strong>(target, overwrite)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="merge_values-instance_method">
  
    #<strong>merge_values</strong>(target, overwrite)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="safe_load_file-instance_method">
  
    #<strong>safe_load_file</strong>(filename)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="user_home-instance_method">
  
    #<strong>user_home</strong>  &#x21d2; <tt>Object</tt> 
  

  

  
</h3>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="write_to_file-instance_method">
  
    #<strong>write_to_file</strong>(file, content, backup: true)  &#x21d2; <tt>Object</tt> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>Write content to a file</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>file</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The path to the file to (over)write</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>content</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="../String.html" title="String (class)">String</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>The content to write to the file</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>backup</span>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
        <em class="default">(defaults to: <tt>true</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>create a ~ backup</p>
</div>
      
    </li>
  
</ul>


</div>
</div>
    
  </div>

</div>

      <div id="footer">
  Generated on Sat Nov 27 13:57:12 2021 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.9.26 (ruby-3.0.1).
</div>

    </div>
  </body>
</html>