Alternatywa dla RVM gemsets

Trójmiejska Grupa Użytkowników Ruby
Gdańsk, 22 Maja 2013

Paweł Gościcki

pawelgoscicki.com
@pawelgoscicki
github.com/pjg



Pracuję w Exvo.com

bundle exec


Kto ręcznie wpisuje `bundle exec`?

Kto ma aliasy be, bi, ber, brake, itp.?

Sposób I

bundler.plugin.zsh (z oh-my-zsh)





(jest też wersja dla Basha: bundler-exec)

Sposób II

rubygems-bundler

Sposób III

RVM gemsets

Mój sposób

Bundler BINstubs


http://bit.ly/bundler-binstubs

.rvmrc

export rvm_without_gems="rubygems-bundler"
          

.bundle/config

BUNDLE_PATH: .bundle
BUNDLE_BIN: .bundle/bin
          

.zshrc



Kod na następnym slajdzie...

export DEFAULT_GEM_HOME=$GEM_HOME

autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_add_binstubs_to_paths

function chpwd_add_binstubs_to_paths {
  # always delete from $OLDPWD (.bundle/bin/ from $PATH and .bundle/ from $GEM_PATH) AND restore $GEM_HOME
  export PATH=${PATH//$OLDPWD\/\.bundle\/bin:}
  export GEM_PATH=${GEM_PATH//$OLDPWD\/\.bundle:}
  export GEM_HOME=$DEFAULT_GEM_HOME

  if [ -r $PWD/Gemfile.lock ] && [ -d $PWD/.bundle/bin ]; then
    # add .bundle/bin to $PATH and .bundle/ to $GEM_PATH (deleting existing entries first) AND set a new $GEM_HOME
    export PATH=$PWD/.bundle/bin:${PATH//$PWD\/\.bundle\/bin:}
    export GEM_PATH=$PWD/.bundle:${GEM_PATH//$PWD\/\.bundle:}
    export GEM_HOME=$PWD/.bundle
  fi
}

chpwd_add_binstubs_to_paths # initial execution
          

Zalety:


Wady:

http://bit.ly/bundler-binstubs