Class: Nanoc::Core::CompilationStages::CompileReps

Inherits:
Nanoc::Core::CompilationStage show all
Includes:
Assertions::Mixin, Nanoc::Core::ContractsSupport
Defined in:
lib/nanoc/core/compilation_stages/compile_reps.rb

Instance Method Summary collapse

Methods included from Assertions::Mixin

#assert

Methods included from Nanoc::Core::ContractsSupport

enabled?, included, setup_once, warn_about_performance

Methods inherited from Nanoc::Core::CompilationStage

#call

Constructor Details

#initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:) ⇒ CompileReps

Returns a new instance of CompileReps.



10
11
12
13
14
15
16
17
# File 'lib/nanoc/core/compilation_stages/compile_reps.rb', line 10

def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
  @reps = reps
  @outdatedness_store = outdatedness_store
  @dependency_store = dependency_store
  @action_sequences = action_sequences
  @compilation_context = compilation_context
  @compiled_content_cache = compiled_content_cache
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/nanoc/core/compilation_stages/compile_reps.rb', line 19

def run
  outdated_reps = @reps.select { |r| @outdatedness_store.include?(r) }
  selector = Nanoc::Core::ItemRepSelector.new(outdated_reps)
  run_phase_stack do |phase_stack|
    selector.each do |rep|
      handle_errors_while(rep) do
        compile_rep(rep, phase_stack: phase_stack, is_outdated: @outdatedness_store.include?(rep))
      end
    end
  end

  assert Nanoc::Core::Assertions::AllItemRepsHaveCompiledContent.new(
    compiled_content_cache: @compiled_content_cache,
    item_reps: @reps,
  )
ensure
  @outdatedness_store.store
  @compiled_content_cache.prune(items: @reps.map(&:item).uniq)
  @compiled_content_cache.store
end