Skip to content

Instantly share code, notes, and snippets.

@renier
Last active October 5, 2016 08:39
Show Gist options
  • Save renier/5d8db4d7c1995fcab5b0 to your computer and use it in GitHub Desktop.
Save renier/5d8db4d7c1995fcab5b0 to your computer and use it in GitHub Desktop.
libraries/helpers.rb
module GemHelper
GEMS = [{ name: 'my_gem', version: '~> 0.0.2' }]
def self.install_dependencies
GemHelper::GEMS.each do |gem|
version = Gem::Requirement.create gem[:version]
installed = Gem::Specification.each.any? do |spec|
gem[:name] == spec.name && version.satisfied_by?(spec.version)
end
next if installed
Gem::DependencyInstaller.new.install gem[:name], version
end
end
end
Gem.sources << 'https://my.additional.ruby.server.com/'
GemHelper.install_dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment