Class: Stove::Plugin::Base

Inherits:
Object
  • Object
show all
Extended by:
Mixin::Optionable, Mixin::Validatable
Defined in:
lib/stove/plugins/base.rb

Direct Known Subclasses

Artifactory, Git, Supermarket

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixin::Optionable

extended, included

Methods included from Mixin::Validatable

validate, validations

Constructor Details

#initialize(cookbook, options = {}) ⇒ Base

Returns a new instance of Base.



25
26
27
# File 'lib/stove/plugins/base.rb', line 25

def initialize(cookbook, options = {})
  @cookbook, @options = cookbook, options
end

Instance Attribute Details

#cookbookObject (readonly)

Returns the value of attribute cookbook.



22
23
24
# File 'lib/stove/plugins/base.rb', line 22

def cookbook
  @cookbook
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/stove/plugins/base.rb', line 23

def options
  @options
end

Class Method Details

.actionsObject



14
15
16
# File 'lib/stove/plugins/base.rb', line 14

def actions
  @actions ||= []
end

.run(description, &block) ⇒ Object



7
8
9
10
11
12
# File 'lib/stove/plugins/base.rb', line 7

def run(description, &block)
  actions << Proc.new do |instance|
    Stove::Log.info { description }
    instance.instance_eval(&block)
  end
end

Instance Method Details

#runObject



29
30
31
32
# File 'lib/stove/plugins/base.rb', line 29

def run
  run_validations
  run_actions
end

#run_actionsObject



40
41
42
43
44
# File 'lib/stove/plugins/base.rb', line 40

def run_actions
  self.class.actions.each do |action|
    action.call(self)
  end
end

#run_validationsObject



34
35
36
37
38
# File 'lib/stove/plugins/base.rb', line 34

def run_validations
  self.class.validations.each do |id, validation|
    validation.run(cookbook, options)
  end
end