title: Is there a better way to ensure ruby's LOAD_PATH doesn't get messed up?
body: <p>I'm trying to avoid ever adding a redundant path to ruby's <code>LOAD_PATH</code>. It's not a remarkably complicated task, I'm just wondering if there is a cleaner method then what I've come up with.</p>
  
  <p>This is my current solution as it stands now:</p>
  
  <pre><code>def add_loadpath(new_path)
    included = $LOAD_PATH.inject(false) do |acc,path|
      acc || new_path == File.expand_path(path)
    end
    $LOAD_PATH.unshift new_path unless included
  end
  </code></pre>
  
  <p>Then instead of doing the usual <code>$LOAD_PATH.unshift SOME_PATH</code> you'd call<br>
  <code>add_loadpath SOME_PATH</code></p>
  
  <p>This is to avoid problems when the load path includes two paths that point to the same folder but are not the same string. For example <code>foo/../bar</code> and <code>bar</code></p>