Class: Inventory::Dependencies
- Inherits:
-
Object
- Object
- Inventory::Dependencies
- Includes:
- Enumerable
- Defined in:
- lib/inventory-1.0/dependencies.rb
Overview
Contains zero or more dependencies of the project. Dependencies can be added, #required, enumerated, and added to Gem specifications. Dependencies are set up by passing a block to #initialize and calling #development, #runtime, and #optional inside it.
Defined Under Namespace
Classes: Development, Optional, Runtime
Instance Method Summary collapse
-
#+(other) ⇒ Dependencies
The dependencies of the receiver and those of OTHER.
-
#add_to_gem_specification(specification) ⇒ self
Add each dependency to a Gem specification.
- #each ⇒ Object
-
#initialize(*dependencies) {|?| ... } ⇒ Dependencies
constructor
Creates a new list of DEPENDENCIES and allows more to be added in the optionally #instance_exec’d block by calling #development, #runtime, and #optional inside it.
-
#require ⇒ self
Require each dependency in turn.
Constructor Details
#initialize(*dependencies) {|?| ... } ⇒ Dependencies
Creates a new list of DEPENDENCIES and allows more to be added in the optionally #instance_exec’d block by calling #development, #runtime, and #optional inside it.
23 24 25 26 |
# File 'lib/inventory-1.0/dependencies.rb', line 23 def initialize(*dependencies) @dependencies = dependencies instance_exec(&Proc.new) if block_given? end |
Instance Method Details
#+(other) ⇒ Dependencies
Returns The dependencies of the receiver and those of OTHER.
66 67 68 |
# File 'lib/inventory-1.0/dependencies.rb', line 66 def +(other) self.class.new(*(dependencies + other.dependencies)) end |
#add_to_gem_specification(specification) ⇒ self
Add each dependency to a Gem specification.
95 96 97 98 99 100 |
# File 'lib/inventory-1.0/dependencies.rb', line 95 def add_to_gem_specification(specification) each do |dependency| dependency.add_to_gem_specification specification end self end |
# {|dependency| ... } ⇒ Object # ⇒ Enumerator<Dependency>
76 77 78 79 80 81 82 |
# File 'lib/inventory-1.0/dependencies.rb', line 76 def each return enum_for(__method__) unless block_given? dependencies.each do |dependency| yield dependency end self end |
#require ⇒ self
Require each dependency in turn.
86 87 88 89 |
# File 'lib/inventory-1.0/dependencies.rb', line 86 def require map{ |dependency| dependency.require } self end |