Module: Inventory::Dependency
- Included in:
- Inventory::Dependencies::Development, Inventory::Dependencies::Optional, Inventory::Dependencies::Runtime
- Defined in:
- lib/inventory-1.0/dependency.rb
Overview
Instance Attribute Summary collapse
-
#feature ⇒ String
readonly
The name of the feature to #require.
-
#major ⇒ Integer
readonly
The major version atom of the dependency.
-
#minor ⇒ Integer
readonly
The minor version atom of the dependency.
-
#name ⇒ String
readonly
The name of the project that this dependency pertains to.
-
#patch ⇒ Integer
readonly
The patch version atom of the dependency.
Instance Method Summary collapse
-
#add_to_gem_specification(specification) ⇒ self
Add the receiver as a runtime dependency to SPECIFICATION.
-
#initialize(name, major, minor, patch, options = {}) ⇒ Object
Sets up a dependency on project NAME, version MAJOR, MINOR, PATCH, along with any OPTIONS.
-
#require ⇒ Boolean
The result of requiring #feature.
- #to_s ⇒ String
Instance Attribute Details
#feature ⇒ String (readonly)
Returns The name of the feature to #require.
71 72 73 |
# File 'lib/inventory-1.0/dependency.rb', line 71 def feature @feature end |
#major ⇒ Integer (readonly)
Returns The major version atom of the dependency.
62 63 64 |
# File 'lib/inventory-1.0/dependency.rb', line 62 def major @major end |
#minor ⇒ Integer (readonly)
Returns The minor version atom of the dependency.
65 66 67 |
# File 'lib/inventory-1.0/dependency.rb', line 65 def minor @minor end |
#name ⇒ String (readonly)
Returns The name of the project that this dependency pertains to.
59 60 61 |
# File 'lib/inventory-1.0/dependency.rb', line 59 def name @name end |
#patch ⇒ Integer (readonly)
Returns The patch version atom of the dependency.
68 69 70 |
# File 'lib/inventory-1.0/dependency.rb', line 68 def patch @patch end |
Instance Method Details
#add_to_gem_specification(specification) ⇒ self
Add the receiver as a runtime dependency to SPECIFICATION.
48 49 50 51 |
# File 'lib/inventory-1.0/dependency.rb', line 48 def add_to_gem_specification(specification) specification.add_runtime_dependency name, gem_requirement self end |
#initialize(name, major, minor, patch, options = {}) ⇒ Object
Sets up a dependency on project NAME, version MAJOR, MINOR, PATCH, along with any OPTIONS. Any methods may be overridden on the instance in the optionally #instance_exec’d block, if a dependency has any non-standard requirements.
20 21 22 23 24 25 26 27 28 |
# File 'lib/inventory-1.0/dependency.rb', line 20 def initialize(name, major, minor, patch, = {}) @name, @major, @minor, @patch = name, major, minor, patch @altfeature = nil @feature = .fetch(:feature){ @altfeature = '%s-%d.0' % [name.gsub('-', '/'), major] '%s-%d.0' % [name, major] } instance_exec(&Proc.new) if block_given? end |
#require ⇒ Boolean
Returns The result of requiring #feature.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/inventory-1.0/dependency.rb', line 31 def require super feature rescue LoadError => e if @altfeature and (not e.respond_to? :path or e.path.end_with? feature) begin super @altfeature rescue LoadError raise e end else raise e end end |