Module: WWTD::Ruby
- Defined in:
- lib/wwtd/ruby.rb
Class Method Summary collapse
- .available?(version) ⇒ Boolean
-
.switch_statement(version, options = {}) ⇒ Object
-
rvm: “rvm xxx do” - chruby: “chruby-exec xxx –” - others: env hash - unknown: nil.
-
Class Method Details
.available?(version) ⇒ Boolean
4 5 6 |
# File 'lib/wwtd/ruby.rb', line 4 def available?(version) !version || switch_statement(version) end |
.switch_statement(version, options = {}) ⇒ Object
-
rvm: “rvm xxx do”
-
chruby: “chruby-exec xxx –”
-
others: env hash
-
unknown: nil
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wwtd/ruby.rb', line 12 def switch_statement(version, ={}) return unless version version = normalize_ruby_version(version) if rvm_executable command = "rvm-exec #{version} " command if cache_command("#{command} ruby -v") elsif chruby_executable command = "chruby-exec #{version} -- " command if cache_command("#{command} ruby -v") elsif [:rerun] if rbenv_executable # cannot call different ruby from inside ruby, but ok for copy-paste "RBENV_VERSION=#{version} " else # don't print giant path hack :/ "USE-RUBY-#{version}" end else if ruby_root = ENV["RUBY_ROOT"] # chruby or RUBY_ROOT set switch_via_env(File.dirname(ruby_root), version) elsif rbenv_executable rubies_root = cache_command("rbenv root") + "/versions" switch_via_env(rubies_root, version) end end end |