Class: Stove::Plugin::Base

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

Direct Known Subclasses

Community, Git

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.



27
28
29
# File 'lib/stove/plugins/base.rb', line 27

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

Instance Attribute Details

#cookbookObject (readonly)

Returns the value of attribute cookbook.



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

def cookbook
  @cookbook
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

.actionsObject



16
17
18
# File 'lib/stove/plugins/base.rb', line 16

def actions
  @actions ||= []
end

.run(description, &block) ⇒ Object



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

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

Instance Method Details

#runObject



31
32
33
34
# File 'lib/stove/plugins/base.rb', line 31

def run
  run_validations
  run_actions
end

#run_actionsObject



42
43
44
45
46
# File 'lib/stove/plugins/base.rb', line 42

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

#run_validationsObject



36
37
38
39
40
# File 'lib/stove/plugins/base.rb', line 36

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