Create a gist now

Instantly share code, notes, and snippets.

namespace :gems do
desc "Install missing gem dependencies"
task :install do
File.read("#{File.dirname(__FILE__)}/.gems").each do |gem_decl|
gem_name, version, source = gem_decl[/^([^\s]+)/,1], gem_decl[/--version ([^\s]+)/,1], gem_decl[/--source ([^\s]+)/,1]
begin
version ? gem(gem_name, version) : gem(gem_name)
rescue Gem::LoadError
puts "Installing #{gem_name} #{version}..."
cmd = "gem install #{gem_name}"
cmd += " --version #{version}" if version
cmd += " --source #{source}" if source
puts `#{cmd}`
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment