Sha256: 3ecde8c2d7b2a6f2e9b096e6102e9134516d0f7c548f24f9c7f5af28689fbce5

Contents?: true

Size: 875 Bytes

Versions: 25

Compression:

Stored size: 875 Bytes

Contents

module Stove
  class Plugin::Base
    include Logify

    extend Mixin::Optionable
    extend Mixin::Validatable

    class << self
      def run(description, &block)
        actions << Proc.new do |instance|
          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

25 entries across 25 versions & 3 rubygems

Version Path
chef-stove-7.1.5 lib/stove/plugins/base.rb
stove-7.1.5 lib/stove/plugins/base.rb
chef-stove-7.1.1 lib/stove/plugins/base.rb
stove-7.1.0 lib/stove/plugins/base.rb
stove-7.0.1 lib/stove/plugins/base.rb
stove-7.0.0 lib/stove/plugins/base.rb
stove-6.1.1 lib/stove/plugins/base.rb
stove-6.1.0 lib/stove/plugins/base.rb
stove-6.0.0 lib/stove/plugins/base.rb
stove-5.2.0 lib/stove/plugins/base.rb
stove-5.1.0 lib/stove/plugins/base.rb
stove-5.0.0 lib/stove/plugins/base.rb
stove-4.1.1 lib/stove/plugins/base.rb
stove-4.1.0 lib/stove/plugins/base.rb
stove-4.0.0 lib/stove/plugins/base.rb
stove-3.2.8 lib/stove/plugins/base.rb
wood-stove-3.2.9000 lib/stove/plugins/base.rb
stove-3.2.7 lib/stove/plugins/base.rb
stove-3.2.6 lib/stove/plugins/base.rb
stove-3.2.5 lib/stove/plugins/base.rb