Class: Fabrique::GemLoader
- Inherits:
-
Object
- Object
- Fabrique::GemLoader
- Defined in:
- lib/fabrique/gem_loader.rb
Instance Method Summary collapse
-
#initialize(gem_definitions) ⇒ GemLoader
constructor
A new instance of GemLoader.
- #load_gems ⇒ Object
Constructor Details
#initialize(gem_definitions) ⇒ GemLoader
Returns a new instance of GemLoader.
5 6 7 8 9 |
# File 'lib/fabrique/gem_loader.rb', line 5 def initialize(gem_definitions) @gem_defs = gem_definitions deps = @gem_defs.collect(&:dependency).reject { |x| not x.matching_specs.empty? } @gem_set = Gem::RequestSet.new(*deps) end |
Instance Method Details
#load_gems ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fabrique/gem_loader.rb', line 11 def load_gems require "rubygems/dependency_installer" @gem_set.resolve specs = @gem_set.install(Gem::DependencyInstaller::DEFAULT_OPTIONS.merge(document: [])) specs.each do |spec| spec.activate end @gem_defs.collect(&:required_as).each { |x| require x } rescue Gem::DependencyResolutionError, Gem::UnsatisfiableDependencyError => e raise Fabrique::GemDependencyError.new(e.) end |