lib/nanoc/base/services/compiler.rb in nanoc-4.7.7 vs lib/nanoc/base/services/compiler.rb in nanoc-4.7.8

- old
+ new

@@ -49,29 +49,38 @@ site: @site, checksum_store: @checksum_store, dependency_store: @dependency_store, action_sequence_store: @action_sequence_store, action_sequences: @action_sequences, + checksums: @checksums, reps: reps, ) end def run_all - run_stage(preprocess_stage) - @action_sequences = run_stage(build_reps_stage) + prepare + + run_stage(forget_outdated_dependencies_stage, @outdated_items) + run_stage(store_pre_compilation_state_stage(@action_sequences), @checksums) run_stage(prune_stage) - run_stage(load_stores_stage) - outdated_items = run_stage(determine_outdatedness_stage) - run_stage(forget_outdated_dependencies_stage, outdated_items) - run_stage(store_pre_compilation_state_stage) - run_stage(compile_reps_stage) + run_stage(compile_reps_stage(@action_sequences)) run_stage(store_post_compilation_state_stage) run_stage(postprocess_stage) ensure run_stage(cleanup_stage) end + def prepare + # FIXME: State is ugly + + run_stage(preprocess_stage) + @action_sequences = run_stage(build_reps_stage) + run_stage(load_stores_stage) + @checksums = run_stage(calculate_checksums_stage) + @outdated_items = run_stage(determine_outdatedness_stage) + end + def compilation_context @_compilation_context ||= Nanoc::Int::CompilationContext.new( action_provider: action_provider, reps: @reps, site: @site, @@ -88,10 +97,15 @@ # TODO: remove def build_reps @action_sequences = build_reps_stage.run end + # TODO: remove + def calculate_checksums + @checksums = run_stage(calculate_checksums_stage) + end + private def run_stage(stage, *args) Nanoc::Int::NotificationCenter.post(:stage_started, stage.class) stage.run(*args) @@ -131,35 +145,41 @@ action_sequence_store: action_sequence_store, outdatedness_store: @outdatedness_store, ) end + def calculate_checksums_stage + @_calculate_checksums_stage ||= Stages::CalculateChecksums.new( + items: @site.items, + layouts: @site.layouts, + code_snippets: @site.code_snippets, + config: @site.config, + ) + end + def determine_outdatedness_stage @_determine_outdatedness_stage ||= Stages::DetermineOutdatedness.new( reps: reps, outdatedness_checker: create_outdatedness_checker, outdatedness_store: outdatedness_store, ) end - def store_pre_compilation_state_stage + def store_pre_compilation_state_stage(action_sequences) @_store_pre_compilation_state_stage ||= Stages::StorePreCompilationState.new( reps: @reps, layouts: site.layouts, - items: site.items, - code_snippets: site.code_snippets, - config: site.config, checksum_store: checksum_store, action_sequence_store: action_sequence_store, - action_sequences: @action_sequences, + action_sequences: action_sequences, ) end - def compile_reps_stage + def compile_reps_stage(action_sequences) @_compile_reps_stage ||= Stages::CompileReps.new( outdatedness_store: @outdatedness_store, dependency_store: @dependency_store, - action_sequences: @action_sequences, + action_sequences: action_sequences, compilation_context: compilation_context, compiled_content_cache: compiled_content_cache, ) end