Class: RobotArmy::DependencyLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/robot-army/dependency_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDependencyLoader

Returns a new instance of DependencyLoader.



7
8
9
# File 'lib/robot-army/dependency_loader.rb', line 7

def initialize
  @dependencies = []
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



5
6
7
# File 'lib/robot-army/dependency_loader.rb', line 5

def dependencies
  @dependencies
end

Instance Method Details

#add_dependency(name, version_str = nil) ⇒ Object



11
12
13
14
15
# File 'lib/robot-army/dependency_loader.rb', line 11

def add_dependency(name, version_str=nil)
  dep = [name]
  dep << version_str if version_str
  @dependencies << dep
end

#load!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/robot-army/dependency_loader.rb', line 17

def load!
  errors = []
  
  @dependencies.each do |name, version|
    begin
      if version
        gem name, version
      else
        gem name
      end
    rescue Gem::LoadError => e
      errors << e.message
    end
  end
  
  unless errors.empty?
    raise DependencyError.new(errors.join("\n"))
  end
end