Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 28 additions and 3 deletions.
  1. +28 −3 lib/language_pack/ruby.rb
View
31 lib/language_pack/ruby.rb
@@ -7,7 +7,7 @@
class LanguagePack::Ruby < LanguagePack::Base
LIBYAML_VERSION = "0.1.4"
LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}"
- BUNDLER_VERSION = "1.1.2"
+ BUNDLER_VERSION = "1.2.0.pre"
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
NODE_VERSION = "0.4.7"
NODE_JS_BINARY_PATH = "node-#{NODE_VERSION}"
@@ -82,10 +82,35 @@ def build_ruby_path
"/tmp/#{ruby_version}"
end
- # fetch the ruby version from the enviroment
+ # fetch the ruby version from bundler
# @return [String, nil] returns the ruby version if detected or nil if none is detected
def ruby_version
- ENV["RUBY_VERSION"]
+ return @ruby_version if @ruby_version
+
+ bootstrap_bundler do |bundler_path|
+ @ruby_version = run("env PATH=$PATH:#{bundler_path}/bin GEM_PATH=#{bundler_path} bundle platform --ruby").chomp
+ end
+
+ if @ruby_version == "No ruby version specified"
+ # for backwards compatibility.
+ # this will go away in the future
+ @ruby_version = ENV['RUBY_VERSION']
+ else
+ @ruby_version = @ruby_version.sub('(', '').sub(')', '').split.join('-')
+ end
+
+ @ruby_version
+ end
+
+ # bootstraps bundler so we can pull the ruby version
+ def bootstrap_bundler(&block)
+ Dir.mktmpdir("bundler-") do |tmpdir|
+ Dir.chdir(tmpdir) do
+ run("curl #{VENDOR_URL}/#{BUNDLER_GEM_PATH}.tgz -s -o - | tar xzf -")
+ end
+
+ yield tmpdir
+ end
end
# determine if we're using rbx

No commit comments for this range

Something went wrong with that request. Please try again.