Last active
August 29, 2015 14:17
-
-
Save deivid-rodriguez/74551ccab0d395c64df5 to your computer and use it in GitHub Desktop.
wwtd chruby support
This file contains 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
diff --git a/lib/wwtd/ruby.rb b/lib/wwtd/ruby.rb | |
index ead4876..fb41fb3 100644 | |
--- a/lib/wwtd/ruby.rb | |
+++ b/lib/wwtd/ruby.rb | |
@@ -6,6 +6,7 @@ module WWTD | |
end | |
# - rvm: "rvm xxx do" | |
+ # - chruby: "chruby-exec xxx --" | |
# - others: env hash | |
# - unknown: nil | |
def switch_statement(version, options={}) | |
@@ -22,6 +23,9 @@ module WWTD | |
# don't print giant path hack :/ | |
"USE-RUBY-#{version}" | |
end | |
+ elsif chruby_executable | |
+ command = "chruby-exec #{version} -- " | |
+ command if cache_command("#{command} ruby -v") | |
else | |
if ruby_root = ENV["RUBY_ROOT"] # chruby or RUBY_ROOT set | |
switch_via_env(File.dirname(ruby_root), version) | |
@@ -54,6 +58,10 @@ module WWTD | |
cache_command("which rbenv") | |
end | |
+ def chruby_executable | |
+ cache_command("which chruby-exec") | |
+ end | |
+ | |
def cache_command(command) | |
cache(command) do | |
if result = capture(command) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment