Sha256: 4726a1eb8a14116fc7494e94b1379effeb090eefe8ed297ab250275550f7bf66

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Nanoc
  module Int
    class RecordingExecutor
      attr_reader :rule_memory

      def initialize
        @rule_memory = []
      end

      def filter(rep, filter_name, filter_args = {})
        @rule_memory << [:filter, filter_name, filter_args]
      end

      def layout(rep, layout_identifier, extra_filter_args = nil)
        if extra_filter_args
          @rule_memory << [:layout, layout_identifier, extra_filter_args]
        else
          @rule_memory << [:layout, layout_identifier]
        end
      end

      def snapshot(rep, snapshot_name, params = {})
        @rule_memory << [:snapshot, snapshot_name, params]

        # Count
        existing = Set.new
        names = @rule_memory.select { |r| r[0] == :snapshot }.map { |r| r[1] }
        names.each do |n|
          if existing.include?(n)
            raise Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, snapshot_name)
          end
          existing << n
        end
      end

      def record_write(rep, path)
        @rule_memory << [:write, path]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.0.0b4 lib/nanoc/base/services/recording_executor.rb