Sha256: d0ce9700b200d7143d960ab150b8a65d2cd7379bf397500ad22219ded74706a1

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

module Stove
  class Filter
    include Logify

    include Mixin::Insideable

    #
    # The class that created this filter.
    #
    # @return [~Plugin::Base]
    #
    attr_reader :klass

    #
    # The message given by the filter.
    #
    # @return [String]
    #
    attr_reader :message

    #
    # The block captured by the filter.
    #
    # @return [Proc]
    #
    attr_reader :block

    #
    # Create a new filter object.
    #
    # @param [~Plugin::Base] klass
    #   the class that created this filter
    # @param [String] message
    #   the message given by the filter
    # @param [Proc] block
    #   the block captured by this filter
    #
    def initialize(klass, message, &block)
      @klass   = klass
      @message = message
      @block   = block
    end

    #
    # Execute this filter in the context of the creating class, inside the
    # given cookbook's path.
    #
    # @param [Cookbook]
    #   the cookbook to run this filter against
    #
    def run(cookbook, options = {})
      log.info(message)
      instance = klass.new(cookbook, options)

      inside(cookbook) do
        instance.instance_eval(&block)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

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