From 9e8194355c1a4f69dc52fbe2699fbce1be5c6493 Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Sun, 12 Jun 2011 13:13:39 +0200 Subject: [PATCH 01/10] Added bundler-exec plugin --- plugins/bundler-exec/bundler-exec.plugin.zsh | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 plugins/bundler-exec/bundler-exec.plugin.zsh diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh new file mode 100644 index 00000000..96672597 --- /dev/null +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -0,0 +1,37 @@ +# This plugin is based on https://github.com/gma/bundler-exec +# modify the BUNDLED_COMMANDS if needed + +BUNDLED_COMMANDS=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) + +## Functions + +bundler-installed() +{ + which bundle > /dev/null 2>&1 +} + +within-bundled-project() +{ + local dir="$(pwd)" + while [ "$(dirname $dir)" != "/" ]; do + [ -f "$dir/Gemfile" ] && return + dir="$(dirname $dir)" + done + false +} + +run-with-bundler() +{ + local command="$1" + shift + if bundler-installed && within-bundled-project; then + bundle exec $command "$@" + else + $command "$@" + fi +} + +## Main program +for CMD in $BUNDLED_COMMANDS; do + alias $CMD="run-with-bundler $CMD" +done From 05883f383143fa4821a5b07a748a800c0299f1fd Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Sun, 12 Jun 2011 15:52:58 +0200 Subject: [PATCH 02/10] use lowercase for variablenames --- plugins/bundler-exec/bundler-exec.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index 96672597..cfab16c5 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -1,7 +1,7 @@ # This plugin is based on https://github.com/gma/bundler-exec # modify the BUNDLED_COMMANDS if needed -BUNDLED_COMMANDS=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) +bundled_commands=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) ## Functions @@ -32,6 +32,6 @@ run-with-bundler() } ## Main program -for CMD in $BUNDLED_COMMANDS; do - alias $CMD="run-with-bundler $CMD" +for cmd in $bundled_commands; do + alias $cmd="run-with-bundler $cmd" done From 3aee5c19412dea541495e10f1c4cc7a6d8e4af50 Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Sun, 12 Jun 2011 19:16:04 +0200 Subject: [PATCH 03/10] changed names of functions and variables to fit naming conventions --- plugins/bundler-exec/bundler-exec.plugin.zsh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index cfab16c5..4684dcb8 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -5,26 +5,26 @@ bundled_commands=(cucumber heroku rackup rails rake rspec ruby shotgun spec spor ## Functions -bundler-installed() +_bundler-installed() { which bundle > /dev/null 2>&1 } -within-bundled-project() +_within-bundled-project() { - local dir="$(pwd)" - while [ "$(dirname $dir)" != "/" ]; do - [ -f "$dir/Gemfile" ] && return - dir="$(dirname $dir)" + local check_dir=$PWD + while [ "$(dirname $check_dir)" != "/" ]; do + [ -f "$check_dir/Gemfile" ] && return + dir="$(dirname $check_dir)" done false } -run-with-bundler() +_run-with-bundler() { local command="$1" shift - if bundler-installed && within-bundled-project; then + if _bundler-installed && _within-bundled-project; then bundle exec $command "$@" else $command "$@" @@ -33,5 +33,5 @@ run-with-bundler() ## Main program for cmd in $bundled_commands; do - alias $cmd="run-with-bundler $cmd" + alias $cmd="_run-with-bundler $cmd" done From 86958a32f3d3e647fc61e92700a9ce393e11a3cb Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Sun, 12 Jun 2011 20:28:27 +0200 Subject: [PATCH 04/10] forgot to rename one variable --- plugins/bundler-exec/bundler-exec.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index 4684dcb8..bc4d35a8 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -15,7 +15,7 @@ _within-bundled-project() local check_dir=$PWD while [ "$(dirname $check_dir)" != "/" ]; do [ -f "$check_dir/Gemfile" ] && return - dir="$(dirname $check_dir)" + check_dir="$(dirname $check_dir)" done false } @@ -27,7 +27,7 @@ _run-with-bundler() if _bundler-installed && _within-bundled-project; then bundle exec $command "$@" else - $command "$@" + $command "$@" fi } From 69d30a6302f8c7daf6ad5ecf23224074789843db Mon Sep 17 00:00:00 2001 From: Bodo Tasche Date: Sun, 12 Jun 2011 23:16:47 +0200 Subject: [PATCH 05/10] Moved opening braces --- plugins/bundler-exec/bundler-exec.plugin.zsh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index bc4d35a8..09f44ed5 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -1,17 +1,15 @@ # This plugin is based on https://github.com/gma/bundler-exec -# modify the BUNDLED_COMMANDS if needed +# modify the bundled_commands if needed bundled_commands=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) ## Functions -_bundler-installed() -{ +_bundler-installed() { which bundle > /dev/null 2>&1 } -_within-bundled-project() -{ +_within-bundled-project() { local check_dir=$PWD while [ "$(dirname $check_dir)" != "/" ]; do [ -f "$check_dir/Gemfile" ] && return @@ -20,8 +18,7 @@ _within-bundled-project() false } -_run-with-bundler() -{ +_run-with-bundler() { local command="$1" shift if _bundler-installed && _within-bundled-project; then From 37fcd4af049ad9b755d7b1d32cf63b537da0342c Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 13 Jul 2011 22:39:23 +0100 Subject: [PATCH 06/10] update bundled commands --- plugins/bundler-exec/bundler-exec.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index 09f44ed5..61829eb2 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -1,7 +1,7 @@ # This plugin is based on https://github.com/gma/bundler-exec # modify the bundled_commands if needed -bundled_commands=(cucumber heroku rackup rails rake rspec ruby shotgun spec spork) +bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails) ## Functions From a77e6fb003cc80fbbff5d453a5ca3d38638d99ed Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 13 Jul 2011 22:40:23 +0100 Subject: [PATCH 07/10] fix indentation --- plugins/bundler-exec/bundler-exec.plugin.zsh | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh index 61829eb2..3417ea81 100644 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ b/plugins/bundler-exec/bundler-exec.plugin.zsh @@ -6,29 +6,29 @@ bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgu ## Functions _bundler-installed() { - which bundle > /dev/null 2>&1 + which bundle > /dev/null 2>&1 } _within-bundled-project() { - local check_dir=$PWD - while [ "$(dirname $check_dir)" != "/" ]; do - [ -f "$check_dir/Gemfile" ] && return - check_dir="$(dirname $check_dir)" - done - false + local check_dir=$PWD + while [ "$(dirname $check_dir)" != "/" ]; do + [ -f "$check_dir/Gemfile" ] && return + check_dir="$(dirname $check_dir)" + done + false } _run-with-bundler() { - local command="$1" - shift - if _bundler-installed && _within-bundled-project; then - bundle exec $command "$@" - else - $command "$@" - fi + local command="$1" + shift + if _bundler-installed && _within-bundled-project; then + bundle exec $command "$@" + else + $command "$@" + fi } ## Main program for cmd in $bundled_commands; do - alias $cmd="_run-with-bundler $cmd" + alias $cmd="_run-with-bundler $cmd" done From 60e104acd1710c04057d079cfa5ac9316762f580 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 13 Jul 2011 22:41:09 +0100 Subject: [PATCH 08/10] merge bundler and bundle-exec plugins --- plugins/bundler-exec/bundler-exec.plugin.zsh | 34 -------------------- plugins/bundler/bundler.plugin.zsh | 34 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 plugins/bundler-exec/bundler-exec.plugin.zsh diff --git a/plugins/bundler-exec/bundler-exec.plugin.zsh b/plugins/bundler-exec/bundler-exec.plugin.zsh deleted file mode 100644 index 3417ea81..00000000 --- a/plugins/bundler-exec/bundler-exec.plugin.zsh +++ /dev/null @@ -1,34 +0,0 @@ -# This plugin is based on https://github.com/gma/bundler-exec -# modify the bundled_commands if needed - -bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails) - -## Functions - -_bundler-installed() { - which bundle > /dev/null 2>&1 -} - -_within-bundled-project() { - local check_dir=$PWD - while [ "$(dirname $check_dir)" != "/" ]; do - [ -f "$check_dir/Gemfile" ] && return - check_dir="$(dirname $check_dir)" - done - false -} - -_run-with-bundler() { - local command="$1" - shift - if _bundler-installed && _within-bundled-project; then - bundle exec $command "$@" - else - $command "$@" - fi -} - -## Main program -for cmd in $bundled_commands; do - alias $cmd="_run-with-bundler $cmd" -done diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index fb40e2ce..fcf3e85f 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -1,3 +1,37 @@ alias be="bundle exec" alias bi="bundle install" alias bu="bundle update" + +# The following is based on https://github.com/gma/bundler-exec + +bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails) + +## Functions + +_bundler-installed() { + which bundle > /dev/null 2>&1 +} + +_within-bundled-project() { + local check_dir=$PWD + while [ "$(dirname $check_dir)" != "/" ]; do + [ -f "$check_dir/Gemfile" ] && return + check_dir="$(dirname $check_dir)" + done + false +} + +_run-with-bundler() { + local command="$1" + shift + if _bundler-installed && _within-bundled-project; then + bundle exec $command "$@" + else + $command "$@" + fi +} + +## Main program +for cmd in $bundled_commands; do + alias $cmd="_run-with-bundler $cmd" +done From ba5fa3abc8ccf1f05e48c9b201282792c956c337 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 13 Jul 2011 22:41:36 +0100 Subject: [PATCH 09/10] alias bundle list --- plugins/bundler/bundler.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index fcf3e85f..c91dc9ab 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -1,5 +1,6 @@ alias be="bundle exec" alias bi="bundle install" +alias bl="bundle list" alias bu="bundle update" # The following is based on https://github.com/gma/bundler-exec From 7d19ae8fab80c826156f984aa6dd8221a9aaada0 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Wed, 13 Jul 2011 22:42:44 +0100 Subject: [PATCH 10/10] clean up rails plugin, removing bundler-specific logic --- plugins/rails3/rails3.plugin.zsh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/plugins/rails3/rails3.plugin.zsh b/plugins/rails3/rails3.plugin.zsh index f669ef04..f4ee637e 100644 --- a/plugins/rails3/rails3.plugin.zsh +++ b/plugins/rails3/rails3.plugin.zsh @@ -1,13 +1,5 @@ # Rails 3 aliases, backwards-compatible with Rails 2. -function _bundle_command { - if command -v bundle && [ -e "Gemfile" ]; then - bundle exec $@ - else - $@ - fi -} - function _rails_command () { if [ -e "script/server" ]; then ruby script/$@ @@ -25,6 +17,3 @@ alias rp='_rails_command plugin' alias rs='_rails_command server' alias rsd='_rails_command server --debugger' alias devlog='tail -f log/development.log' - -alias rspec='_bundle_command rspec' -alias cuke='_bundle_command cucumber'