Class: Divvy::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/divvy/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {}, &block)
  # raise ArgumentError.new('Name is required') unless name
  @name = name.to_sym
  @options = options
  @dependencies = []
  @verifications = []
  self.instance_eval(&block)
end

Instance Attribute Details

#apply_blockObject (readonly)

Returns the value of attribute apply_block.



13
14
15
# File 'lib/divvy/package.rb', line 13

def apply_block
  @apply_block
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/divvy/package.rb', line 13

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



13
14
15
# File 'lib/divvy/package.rb', line 13

def options
  @options
end

#verificationsObject (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

#dependenciesObject



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