Class: RobotArmy::DependencyLoader
- Defined in:
- lib/robot-army/dependency_loader.rb
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
- #add_dependency(name, version_str = nil) ⇒ Object
-
#initialize ⇒ DependencyLoader
constructor
A new instance of DependencyLoader.
- #load! ⇒ Object
Constructor Details
#initialize ⇒ DependencyLoader
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
#dependencies ⇒ Object (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. end end unless errors.empty? raise DependencyError.new(errors.join("\n")) end end |