Class: Divvy::Package
- Inherits:
-
Object
- Object
- Divvy::Package
- Defined in:
- lib/divvy/package.rb
Instance Attribute Summary collapse
-
#apply_block ⇒ Object
readonly
Returns the value of attribute apply_block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#verifications ⇒ Object
readonly
Returns the value of attribute verifications.
Instance Method Summary collapse
- #apply(&block) ⇒ Object
- #dependencies ⇒ Object
-
#initialize(name, options = {}, &block) ⇒ Package
constructor
A new instance of Package.
- #requires(*packages) ⇒ Object
- #verify(description = '', &block) ⇒ Object
Constructor Details
#initialize(name, options = {}, &block) ⇒ Package
Returns a new instance of Package.
4 5 6 7 8 9 10 11 |
# File 'lib/divvy/package.rb', line 4 def initialize(name, = {}, &block) # raise ArgumentError.new('Name is required') unless name @name = name.to_sym @options = @dependencies = [] @verifications = [] self.instance_eval(&block) end |
Instance Attribute Details
#apply_block ⇒ Object (readonly)
Returns the value of attribute apply_block.
13 14 15 |
# File 'lib/divvy/package.rb', line 13 def apply_block @apply_block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/divvy/package.rb', line 13 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/divvy/package.rb', line 13 def @options end |
#verifications ⇒ Object (readonly)
Returns the value of attribute verifications.
13 14 15 |
# File 'lib/divvy/package.rb', line 13 def verifications @verifications end |
Instance Method Details
#apply(&block) ⇒ Object
25 26 27 |
# File 'lib/divvy/package.rb', line 25 def apply(&block) @apply_block = block end |
#dependencies ⇒ Object
20 21 22 23 |
# File 'lib/divvy/package.rb', line 20 def dependencies @dependencies.each { |package| raise "Package #{package} not found!" unless Divvy.packages.key?(package) } @dependencies.map { |key| Divvy.packages[key] } end |
#requires(*packages) ⇒ Object
15 16 17 18 |
# File 'lib/divvy/package.rb', line 15 def requires(*packages) @dependencies << packages @dependencies.flatten! end |
#verify(description = '', &block) ⇒ Object
29 30 31 |
# File 'lib/divvy/package.rb', line 29 def verify(description = '', &block) @verifications << Verification.new(self, description, &block) end |