Sha256: 5605628d903c79ee1637d4fe4f7f9179518a636a09e0e08aa0c0113dd61d4399

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

module Stove
  class Plugin::Base
    extend Mixin::Optionable
    extend Mixin::Validatable

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

      def actions
        @actions ||= []
      end
    end

    option :id
    option :description

    attr_reader :cookbook
    attr_reader :options

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

    def run
      run_validations
      run_actions
    end

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

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
chef-stove-7.1.6 lib/stove/plugins/base.rb
stove-7.1.6 lib/stove/plugins/base.rb