Class: Nanoc::Core::CompilationPhases::Recalculate
- Includes:
- Nanoc::Core::ContractsSupport
- Defined in:
- lib/nanoc/core/compilation_phases/recalculate.rb
Overview
Provides functionality for (re)calculating the content of an item rep, without caching or outdatedness checking.
Instance Method Summary collapse
-
#initialize(action_sequences:, dependency_store:, compilation_context:) ⇒ Recalculate
constructor
A new instance of Recalculate.
- #pending_action_sequence_for(rep:) ⇒ Object
-
#run(rep, is_outdated:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Methods included from Nanoc::Core::ContractsSupport
enabled?, included, setup_once, warn_about_performance
Methods inherited from Abstract
Constructor Details
#initialize(action_sequences:, dependency_store:, compilation_context:) ⇒ Recalculate
Returns a new instance of Recalculate.
11 12 13 14 15 16 17 |
# File 'lib/nanoc/core/compilation_phases/recalculate.rb', line 11 def initialize(action_sequences:, dependency_store:, compilation_context:) super(wrapped: nil) @action_sequences = action_sequences @dependency_store = dependency_store @compilation_context = compilation_context end |
Instance Method Details
#pending_action_sequence_for(rep:) ⇒ Object
55 56 57 58 |
# File 'lib/nanoc/core/compilation_phases/recalculate.rb', line 55 def pending_action_sequence_for(rep:) @_pending_action_sequences ||= {} @_pending_action_sequences[rep] ||= @action_sequences[rep].to_a end |
#run(rep, is_outdated:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/nanoc/core/compilation_phases/recalculate.rb', line 20 def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument dependency_tracker = Nanoc::Core::DependencyTracker.new(@dependency_store) dependency_tracker.enter(rep.item) executor = Nanoc::Core::Executor.new(rep, @compilation_context, dependency_tracker) # Set initial content, if not already present compiled_content_store = @compilation_context.compiled_content_store unless compiled_content_store.get_current(rep) compiled_content_store.set_current(rep, rep.item.content) end actions = pending_action_sequence_for(rep:) until actions.empty? action = actions.first case action when Nanoc::Core::ProcessingActions::Filter executor.filter(action.filter_name, action.params) when Nanoc::Core::ProcessingActions::Layout executor.layout(action.layout_identifier, action.params) when Nanoc::Core::ProcessingActions::Snapshot action.snapshot_names.each do |snapshot_name| executor.snapshot(snapshot_name) end else raise Nanoc::Core::Errors::InternalInconsistency, "unknown action #{action.inspect}" end actions.shift end ensure dependency_tracker.exit end |