Created
January 11, 2010 17:36
-
-
Save bitprophet/274410 to your computer and use it in GitHub Desktop.
Designed for use with non-system gem location e.g. homebrew or ~/.gems
This file contains hidden or 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
# | |
# Try to make up for Ruby's lack of easy setup.py develop sorta thing. | |
# | |
function fakegem() { | |
if [[ `env | grep GEM_HOME` ]]; then | |
projects=~/Documents/Code | |
for project in `ls -1 $projects`; do | |
bin=$projects/$project/bin | |
lib=$projects/$project/lib | |
# if project seems to be ruby and doesn't exist as an installed gem | |
has_ruby=`find $projects/$project -name "*.rb"` | |
has_gem=`find $GEM_HOME/gems -maxdepth 1 -mindepth 1 -name "$project*"` | |
# and if it's not already in our bin/lib paths | |
in_path=`echo $PATH | grep $bin` | |
in_lib=`echo $RUBYLIB | grep $lib` | |
if ( \ | |
[[ $has_ruby ]] \ | |
&& [[ ! $has_gem ]] \ | |
&& [[ ! ($in_path || $in_lib) ]] \ | |
); then | |
# add project/bin to PATH and project/lib to RUBYLIB | |
export PATH=$PATH:$bin | |
if [[ `env | grep RUBYLIB` ]]; then | |
export RUBYLIB=$RUBYLIB:$lib | |
else | |
export RUBYLIB=$lib | |
fi | |
fi | |
done | |
fi | |
} | |
fakegem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment