Created
April 4, 2013 23:55
-
-
Save Jamedjo/5315469 to your computer and use it in GitHub Desktop.
Extract ENV["RUBY_VERSION"] with gemset by capturing everything after rvm/gems, then everything before a '/'
Alternative to http://rubular.com/r/knx27JoODH
This file contains hidden or 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
1.9.3p385 :010 > GEM_HOME = ENV["GEM_HOME"] | |
=> "/home/james/.rvm/gems/ruby-1.9.3-p385-perf@njist325" | |
1.9.3p385 :011 > if GEM_HOME && GEM_HOME =~ %r{rvm/gems/(.+)} | |
1.9.3p385 :012?> puts $1.sub(/\/.*/, '') | |
1.9.3p385 :013?> end | |
ruby-1.9.3-p385-perf@njist325 |
This file contains hidden or 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
1.9.3p385 :001 > GEM_HOME = ENV["GEM_HOME"];if GEM_HOME && GEM_HOME =~ %r{rvm/gems/(.+)};puts $1.sub(/\/.*/, '');end | |
ruby-1.9.3-p385-perf@njist325 | |
1.9.3p385 :002 > GEM_HOME | |
=> "/home/bitnami/.rvm/gems/ruby-1.9.3-p385-perf@njist325/ruby/1.9.1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment