Sha256: 33e60ce16bdcf9e01f740c21a22726a42ce2798d6cae7eb9928e8c09c27d72e0

Contents?: true

Size: 971 Bytes

Versions: 16

Compression:

Stored size: 971 Bytes

Contents

module Nanoc
  module RuleDSL
    class RecordingExecutor
      include Nanoc::Int::ContractsSupport

      def initialize(rule_memory)
        @rule_memory = rule_memory
      end

      def filter(filter_name, filter_args = {})
        @rule_memory.add_filter(filter_name, filter_args)
      end

      def layout(layout_identifier, extra_filter_args = {})
        unless layout_identifier.is_a?(String)
          raise ArgumentError.new('The layout passed to #layout must be a string')
        end

        unless @rule_memory.any_layouts?
          @rule_memory.add_snapshot(:pre, nil)
        end

        @rule_memory.add_layout(layout_identifier, extra_filter_args)
      end

      Pathlike = C::Maybe[C::Or[String, Nanoc::Identifier]]
      contract Symbol, C::KeywordArgs[path: C::Optional[Pathlike]] => nil
      def snapshot(snapshot_name, path: nil)
        @rule_memory.add_snapshot(snapshot_name, path && path.to_s)
        nil
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
nanoc-4.7.3 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.7.2 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.7.1 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.7.0 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.6.4 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.6.3 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.6.2 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.6.1 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.6.0 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.5.4 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.5.3 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.5.2 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.5.1 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.5.0 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.4.7 lib/nanoc/rule_dsl/recording_executor.rb
nanoc-4.4.6 lib/nanoc/rule_dsl/recording_executor.rb