Created
January 18, 2013 03:32
-
-
Save jclosure/4562138 to your computer and use it in GitHub Desktop.
How to set the directory context to the same dir or nearby dir of currently executing Ruby script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#place at top of file | |
$:.unshift(File.dirname(__FILE__)) | |
#this will include the dir context to the same folder as the currently executing script | |
- | |
|-examples | |
|-example1.rb | |
|-lib | |
|-library1.rb | |
#with this structure and the code, you can do: | |
$:.unshift(File.dirname(__FILE__) + "/../lib") | |
#the case shown here is excellent for say having a gem with an examples directory and you want to set the dir context to the lib dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment