Sha256: f5e0258711c51205bfa41081b45de68aadf9d308afc7f00642f2625a82fd25f3
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module Nanoc module RuleDSL class RecordingExecutor include Nanoc::Int::ContractsSupport contract Nanoc::Int::ItemRep => C::Any def initialize(rep) @action_sequence_builder = Nanoc::Int::ActionSequenceBuilder.new(rep) @any_layouts = false @last_snapshot = false @pre_snapshot = false end def filter(filter_name, filter_args = {}) @action_sequence_builder.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 any_layouts? @pre_snapshot = true @action_sequence_builder.add_snapshot(:pre, nil) end @action_sequence_builder.add_layout(layout_identifier, extra_filter_args) @any_layouts = true end Pathlike = C::Maybe[C::Or[String, Nanoc::Identifier]] contract Symbol, C::KeywordArgs[path: C::Optional[Pathlike]] => nil def snapshot(snapshot_name, path: nil) @action_sequence_builder.add_snapshot(snapshot_name, path && path.to_s) case snapshot_name when :last @last_snapshot = true when :pre @pre_snapshot = true end nil end contract C::None => Nanoc::Int::ActionSequence def action_sequence @action_sequence_builder.action_sequence end contract C::None => C::Bool def any_layouts? @any_layouts end contract C::None => C::Bool def last_snapshot? @last_snapshot end contract C::None => C::Bool def pre_snapshot? @pre_snapshot end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc-4.7.9 | lib/nanoc/rule_dsl/recording_executor.rb |
nanoc-4.7.8 | lib/nanoc/rule_dsl/recording_executor.rb |