class Nanoc::RuleDSL::ActionRecorder

Constants

MaybePathlike

Public Class Methods

new(item_rep) click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 9
def initialize(item_rep)
  @item_rep = item_rep

  @action_sequence_builder = Nanoc::Core::ActionSequenceBuilder.new

  @any_layouts = false
  @last_snapshot = false
  @pre_snapshot = false
  @snapshots_for_which_to_skip_routing_rule = Set.new
end

Public Instance Methods

action_sequence() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 67
def action_sequence
  @action_sequence_builder.action_sequence
end
any_layouts?() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 72
def any_layouts?
  @any_layouts
end
filter(filter_name, filter_args = {}) click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 24
def filter(filter_name, filter_args = {})
  @action_sequence_builder.add_filter(filter_name, filter_args)
end
inspect() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 20
def inspect
  "<#{self.class}>"
end
last_snapshot?() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 82
def last_snapshot?
  @last_snapshot
end
layout(layout_identifier, extra_filter_args = {}) click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 28
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 any_layouts?
    @pre_snapshot = true
    @action_sequence_builder.add_snapshot(:pre, nil, @item_rep)
  end

  @action_sequence_builder.add_layout(layout_identifier, extra_filter_args)
  @any_layouts = true
end
pre_snapshot?() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 87
def pre_snapshot?
  @pre_snapshot
end
snapshot(snapshot_name, path: Nanoc::Core::UNDEFINED) click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 44
def snapshot(snapshot_name, path: Nanoc::Core::UNDEFINED)
  unless Nanoc::Core::UNDEFINED.equal?(path)
    @snapshots_for_which_to_skip_routing_rule << snapshot_name
  end

  path =
    if Nanoc::Core::UNDEFINED.equal?(path) || path.nil?
      nil
    else
      path.to_s
    end

  @action_sequence_builder.add_snapshot(snapshot_name, path, @item_rep)
  case snapshot_name
  when :last
    @last_snapshot = true
  when :pre
    @pre_snapshot = true
  end
  nil
end
snapshots_for_which_to_skip_routing_rule() click to toggle source
# File lib/nanoc/rule_dsl/action_recorder.rb, line 77
def snapshots_for_which_to_skip_routing_rule
  @snapshots_for_which_to_skip_routing_rule
end