Add new method 'ensure_rbenv_gem()' #13

Open
wants to merge 2 commits into
from

2 participants

@veenstra

No description provided.

@philc philc and 1 other commented on an outdated diff Mar 3, 2013
lib/terraform/dsl.rb
@@ -85,6 +85,21 @@ def ensure_gem(gem)
end
end
+ def rbenv_gem_installed?(gem, ruby_version = nil)
+ rbenv_root = ENV["RBENV_ROOT"] || "#{ENV["HOME"]}/.rbenv"
+ prefix = "env RBENV_VERSION=#{ruby_version} #{rbenv_root}/shims/" unless ruby_version.nil?
+ `#{prefix}gem list '#{gem}'`.include?(gem)
+ end
+
+ def ensure_rbenv_gem(gem, ruby_version = nil)
+ rbenv_root = ENV["RBENV_ROOT"] || "#{ENV["HOME"]}/.rbenv"
+ prefix = "env RBENV_VERSION=#{ruby_version} #{rbenv_root}/shims/" unless ruby_version.nil?
@philc
Owner
philc added a line comment Mar 3, 2013

Let's pull this prefix into its own method

@veenstra
veenstra added a line comment Mar 20, 2013

Fixed in 81142da

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@philc
Owner

I've forgotten the context of this change. Can you describe the problem it's fixing?

@veenstra

It's been a while, but this allows the setup script do something like this:

ensure_rbenv_ruby("1.9.3-p194")
ensure_rbenv_gem("bundler", "1.9.3-p194")

This will install the bundler gem in the newly installed Ruby 1.9.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment