Skip to content

Instantly share code, notes, and snippets.

@mmasashi
Created April 3, 2015 20:48
Show Gist options
  • Select an option

  • Save mmasashi/66691e0cdfe4df88371e to your computer and use it in GitHub Desktop.

Select an option

Save mmasashi/66691e0cdfe4df88371e to your computer and use it in GitHub Desktop.
Append a new load path to the head of $LOAD_PATH if not exists.
def append_load_path_if_not_exist(new_lib_path)
absolute_path = File.realpath(new_lib_path)
$LOAD_PATH.unshift absolute_path unless $LOAD_PATH.include? absolute_path
end
another_lib_dir = File.realpath('../../lib', __FILE__)
append_load_path_if_not_exist(another_lib_dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment