15c5d59892295291c529ca6aa5c7bbaf6822816f

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #2923 from Kriechi/bundler-fixes

Bundler fixes

Diff

  1diff --git a/plugins/bundler/README.md b/plugins/bundler/README.md
  2new file mode 100644
  3index 0000000000000000000000000000000000000000..56f0c71767c66d0ba5c3f0306a6450d8f438c278
  4--- /dev/null
  5+++ b/plugins/bundler/README.md
  6@@ -0,0 +1,49 @@
  7+# Bundler
  8+
  9+- adds completion for basic bundler commands
 10+- adds short aliases for common bundler commands
 11+  - `be` aliased to `bundle exec`
 12+  - `bl` aliased to `bundle list`
 13+  - `bp` aliased to `bundle package`
 14+  - `bo` aliased to `bundle open`
 15+  - `bu` aliased to `bundle update`
 16+  - `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
 17+- adds a wrapper for common gems:
 18+  - looks for a binstub under `./bin/` and executes it (if present)
 19+  - calls `bundle exec <gem executable>` otherwise
 20+
 21+For a full list of *common gems* being wrapped by default please look at the `bundler.plugin.zsh` file.
 22+
 23+## Configuration
 24+
 25+Please use the exact name of the executable and not the gem name.
 26+
 27+### Add additional gems to be wrapped
 28+
 29+Add this before the plugin-list in your `.zshrc`:
 30+```sh
 31+BUNDLED_COMMANDS=(rubocop)
 32+plugins=(... bundler ...)
 33+```
 34+This will add the wrapper for the `rubocop` gem (i.e. the executable).
 35+
 36+
 37+### Exclude gems from being wrapped
 38+
 39+Add this before the plugin-list in your `.zshrc`:
 40+```sh
 41+UNBUNDLED_COMMANDS=(foreman spin)
 42+plugins=(... bundler ...)
 43+```
 44+This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
 45+
 46+## Excluded gems
 47+
 48+These gems should not be called with `bundle exec`. Please see the Issues on GitHub for clarification.
 49+
 50+`berks`
 51+`foreman`
 52+`mailcatcher`
 53+`rails`
 54+`ruby`
 55+`spin`
 56diff --git a/plugins/bundler/_bundler b/plugins/bundler/_bundler
 57index 2ec3a5f9c7c97ea821c3ec6ac4e57108b8cc923d..ba647ab80a2abaf31724a9fdb8db0b0a8e769f63 100644
 58--- a/plugins/bundler/_bundler
 59+++ b/plugins/bundler/_bundler
 60@@ -18,11 +18,13 @@ case $state in
 61 			"check[Determine whether the requirements for your application are installed]" \
 62 			"list[Show all of the gems in the current bundle]" \
 63 			"show[Show the source location of a particular gem in the bundle]" \
 64+			"outdated[Show all of the outdated gems in the current bundle]" \
 65 			"console[Start an IRB session in the context of the current bundle]" \
 66 			"open[Open an installed gem in the editor]" \
 67 			"viz[Generate a visual representation of your dependencies]" \
 68 			"init[Generate a simple Gemfile, placed in the current directory]" \
 69 			"gem[Create a simple gem, suitable for development with bundler]" \
 70+			"platform[Displays platform compatibility information]" \
 71 			"clean[Cleans up unused gems in your bundler directory]" \
 72 			"help[Describe available tasks or one specific task]"
 73 		ret=0
 74@@ -39,11 +41,13 @@ case $state in
 75                     'check' \
 76                     'list' \
 77                     'show' \
 78+                    'outdated' \
 79                     'console' \
 80                     'open' \
 81                     'viz' \
 82                     'init' \
 83                     'gem' \
 84+                    'platform' \
 85                     'help' && ret=0
 86 				;;
 87 			install)
 88@@ -71,6 +75,15 @@ case $state in
 89 					'(--verbose)--verbose[Enable verbose output mode]'
 90 				ret=0
 91 				;;
 92+			outdated)
 93+				_arguments \
 94+					'(--pre)--pre[Check for newer pre-release gems]' \
 95+					'(--source)--source[Check against a specific source]' \
 96+					'(--local)--local[Do not attempt to fetch gems remotely and use the gem cache instead]' \
 97+					'(--no-color)--no-color[Disable colorization in output]' \
 98+					'(--verbose)--verbose[Enable verbose output mode]'
 99+				ret=0
100+				;;
101 			(open|show)
102 				_gems=( $(bundle show 2> /dev/null | sed -e '/^  \*/!d; s/^  \* \([^ ]*\) .*/\1/') )
103 				if [[ $_gems != "" ]]; then
104diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
105index fbdbc02447e30f4eb2732dffba9f86cac34edbf2..617dcde7111f5a811f391e15c685a8c712b16dd4 100644
106--- a/plugins/bundler/bundler.plugin.zsh
107+++ b/plugins/bundler/bundler.plugin.zsh
108@@ -5,15 +5,49 @@ alias bo="bundle open"
109 alias bu="bundle update"
110 alias bi="bundle_install"
111 
112-# The following is based on https://github.com/gma/bundler-exec
113-
114-bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard irb jekyll kitchen knife middleman nanoc puma rackup rainbows rake rspec ruby shotgun spec spin spork spring strainer tailor taps thin thor unicorn unicorn_rails)
115+bundled_commands=(
116+  annotate
117+  cap
118+  capify
119+  cucumber
120+  foodcritic
121+  guard
122+  irb
123+  jekyll
124+  kitchen
125+  knife
126+  middleman
127+  nanoc
128+  pry
129+  puma
130+  rackup
131+  rainbows
132+  rake
133+  rspec
134+  shotgun
135+  sidekiq
136+  spec
137+  spork
138+  spring
139+  strainer
140+  tailor
141+  taps
142+  thin
143+  thor
144+  unicorn
145+  unicorn_rails
146+)
147 
148 # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
149 for cmd in $UNBUNDLED_COMMANDS; do
150   bundled_commands=(${bundled_commands#$cmd});
151 done
152 
153+# Add $BUNDLED_COMMANDS to the bundled_commands list
154+for cmd in $BUNDLED_COMMANDS; do
155+  bundled_commands+=($cmd);
156+done
157+
158 ## Functions
159 
160 bundle_install() {
161@@ -55,7 +89,7 @@ _binstubbed() {
162 _run-with-bundler() {
163   if _bundler-installed && _within-bundled-project; then
164     if _binstubbed $1; then
165-      bundle exec "./bin/$@"
166+      ./bin/$@
167     else
168       bundle exec $@
169     fi
170@@ -71,7 +105,6 @@ for cmd in $bundled_commands; do
171   alias $cmd=bundled_$cmd
172 
173   if which _$cmd > /dev/null 2>&1; then
174-        compdef _$cmd bundled_$cmd=$cmd
175+    compdef _$cmd bundled_$cmd=$cmd
176   fi
177 done
178-