Skip to content

Instantly share code, notes, and snippets.

@bitprophet
Created January 11, 2010 17:36
Show Gist options
  • Save bitprophet/274410 to your computer and use it in GitHub Desktop.
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
#
# 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