nanoc 4.11.0 → 4.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +6 -0
  3. data/lib/nanoc.rb +4 -7
  4. data/lib/nanoc/base.rb +3 -3
  5. data/lib/nanoc/base/assertions.rb +1 -1
  6. data/lib/nanoc/base/entities.rb +2 -20
  7. data/lib/nanoc/base/entities/action_sequence.rb +60 -64
  8. data/lib/nanoc/base/entities/checksum_collection.rb +23 -21
  9. data/lib/nanoc/base/entities/dependency.rb +24 -22
  10. data/lib/nanoc/base/entities/outdatedness_reasons.rb +74 -72
  11. data/lib/nanoc/base/entities/outdatedness_status.rb +19 -17
  12. data/lib/nanoc/base/entities/props.rb +119 -117
  13. data/lib/nanoc/base/entities/site.rb +46 -50
  14. data/lib/nanoc/base/errors.rb +183 -198
  15. data/lib/nanoc/base/repos.rb +4 -2
  16. data/lib/nanoc/base/repos/action_sequence_store.rb +44 -42
  17. data/lib/nanoc/base/repos/aggregate_data_source.rb +24 -22
  18. data/lib/nanoc/base/repos/checksum_store.rb +51 -49
  19. data/lib/nanoc/base/repos/compiled_content_cache.rb +47 -45
  20. data/lib/nanoc/base/repos/compiled_content_store.rb +76 -0
  21. data/lib/nanoc/base/repos/config_loader.rb +74 -72
  22. data/lib/nanoc/base/repos/dependency_store.rb +174 -172
  23. data/lib/nanoc/base/repos/in_mem_data_source.rb +17 -15
  24. data/lib/nanoc/base/repos/item_rep_repo.rb +26 -24
  25. data/lib/nanoc/base/repos/outdatedness_store.rb +50 -48
  26. data/lib/nanoc/base/repos/prefixed_data_source.rb +21 -19
  27. data/lib/nanoc/base/repos/site_loader.rb +75 -73
  28. data/lib/nanoc/base/repos/store.rb +93 -91
  29. data/lib/nanoc/base/services.rb +7 -3
  30. data/lib/nanoc/base/services/action_provider.rb +23 -21
  31. data/lib/nanoc/base/services/action_sequence_builder.rb +42 -34
  32. data/lib/nanoc/base/services/compilation_context.rb +49 -47
  33. data/lib/nanoc/base/services/compiler.rb +177 -170
  34. data/lib/nanoc/base/services/compiler/phases.rb +8 -1
  35. data/lib/nanoc/base/services/compiler/phases/abstract.rb +44 -38
  36. data/lib/nanoc/base/services/compiler/phases/cache.rb +34 -28
  37. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +17 -11
  38. data/lib/nanoc/base/services/compiler/phases/notify.rb +21 -0
  39. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +37 -31
  40. data/lib/nanoc/base/services/compiler/phases/resume.rb +47 -48
  41. data/lib/nanoc/base/services/compiler/phases/write.rb +65 -59
  42. data/lib/nanoc/base/services/compiler/stage.rb +27 -8
  43. data/lib/nanoc/base/services/compiler/stages.rb +7 -1
  44. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +25 -19
  45. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +34 -28
  46. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +33 -27
  47. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +79 -69
  48. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +46 -40
  49. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +15 -9
  50. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +28 -22
  51. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -10
  52. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +25 -19
  53. data/lib/nanoc/base/services/compiler/stages/prune.rb +23 -17
  54. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +15 -9
  55. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +26 -20
  56. data/lib/nanoc/base/services/compiler_loader.rb +26 -24
  57. data/lib/nanoc/base/services/dependency_tracker.rb +47 -45
  58. data/lib/nanoc/base/services/executor.rb +16 -15
  59. data/lib/nanoc/base/services/filter.rb +37 -5
  60. data/lib/nanoc/base/services/instrumentor.rb +12 -10
  61. data/lib/nanoc/base/services/item_rep_builder.rb +21 -19
  62. data/lib/nanoc/base/services/item_rep_router.rb +72 -70
  63. data/lib/nanoc/base/services/item_rep_selector.rb +48 -46
  64. data/lib/nanoc/base/services/item_rep_writer.rb +58 -53
  65. data/lib/nanoc/base/services/outdatedness_checker.rb +181 -179
  66. data/lib/nanoc/base/services/outdatedness_rule.rb +23 -21
  67. data/lib/nanoc/base/services/outdatedness_rules.rb +5 -3
  68. data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +28 -24
  69. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +20 -16
  70. data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +13 -9
  71. data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +12 -8
  72. data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +12 -8
  73. data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +10 -6
  74. data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +39 -35
  75. data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +19 -15
  76. data/lib/nanoc/base/services/pruner.rb +2 -2
  77. data/lib/nanoc/base/views.rb +7 -0
  78. data/lib/nanoc/base/views/basic_item_view.rb +1 -1
  79. data/lib/nanoc/base/views/compilation_item_rep_view.rb +2 -2
  80. data/lib/nanoc/base/views/identifiable_collection_view.rb +2 -2
  81. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +1 -1
  82. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +5 -5
  83. data/lib/nanoc/base/views/mutable_item_collection_view.rb +3 -3
  84. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +2 -2
  85. data/lib/nanoc/base/views/view_context_for_compilation.rb +6 -6
  86. data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +2 -2
  87. data/lib/nanoc/base/views/view_context_for_shell.rb +2 -2
  88. data/lib/nanoc/checking/check.rb +1 -1
  89. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +24 -7
  90. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +79 -15
  91. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +4 -7
  92. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +15 -24
  93. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +22 -18
  94. data/lib/nanoc/cli/commands/create-site.rb +2 -7
  95. data/lib/nanoc/cli/commands/shell.rb +1 -1
  96. data/lib/nanoc/cli/commands/show-data.rb +9 -9
  97. data/lib/nanoc/cli/logger.rb +1 -1
  98. data/lib/nanoc/data_sources/filesystem.rb +8 -8
  99. data/lib/nanoc/filters/erb.rb +1 -1
  100. data/lib/nanoc/filters/erubi.rb +1 -1
  101. data/lib/nanoc/filters/erubis.rb +1 -1
  102. data/lib/nanoc/filters/haml.rb +1 -1
  103. data/lib/nanoc/filters/sass.rb +1 -1
  104. data/lib/nanoc/filters/slim.rb +1 -1
  105. data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
  106. data/lib/nanoc/helpers/capturing.rb +9 -8
  107. data/lib/nanoc/helpers/filtering.rb +2 -2
  108. data/lib/nanoc/helpers/rendering.rb +1 -1
  109. data/lib/nanoc/rule_dsl.rb +10 -0
  110. data/lib/nanoc/rule_dsl/action_provider.rb +3 -3
  111. data/lib/nanoc/rule_dsl/action_recorder.rb +3 -3
  112. data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +7 -7
  113. data/lib/nanoc/rule_dsl/compilation_rule.rb +2 -2
  114. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +9 -9
  115. data/lib/nanoc/rule_dsl/compiler_dsl.rb +4 -4
  116. data/lib/nanoc/rule_dsl/routing_rule.rb +3 -3
  117. data/lib/nanoc/rule_dsl/rule.rb +5 -5
  118. data/lib/nanoc/rule_dsl/rule_context.rb +3 -3
  119. data/lib/nanoc/rule_dsl/rules_collection.rb +4 -4
  120. data/lib/nanoc/spec.rb +15 -15
  121. data/lib/nanoc/version.rb +1 -1
  122. metadata +10 -111
  123. data/lib/nanoc/base/contracts_support.rb +0 -130
  124. data/lib/nanoc/base/core_ext.rb +0 -5
  125. data/lib/nanoc/base/core_ext/array.rb +0 -50
  126. data/lib/nanoc/base/core_ext/hash.rb +0 -54
  127. data/lib/nanoc/base/core_ext/string.rb +0 -16
  128. data/lib/nanoc/base/entities/code_snippet.rb +0 -53
  129. data/lib/nanoc/base/entities/configuration-schema.json +0 -122
  130. data/lib/nanoc/base/entities/configuration.rb +0 -206
  131. data/lib/nanoc/base/entities/content.rb +0 -112
  132. data/lib/nanoc/base/entities/context.rb +0 -70
  133. data/lib/nanoc/base/entities/directed_graph.rb +0 -195
  134. data/lib/nanoc/base/entities/document.rb +0 -125
  135. data/lib/nanoc/base/entities/identifiable_collection.rb +0 -141
  136. data/lib/nanoc/base/entities/identifier.rb +0 -222
  137. data/lib/nanoc/base/entities/item.rb +0 -10
  138. data/lib/nanoc/base/entities/item_collection.rb +0 -14
  139. data/lib/nanoc/base/entities/item_rep.rb +0 -91
  140. data/lib/nanoc/base/entities/layout.rb +0 -10
  141. data/lib/nanoc/base/entities/layout_collection.rb +0 -14
  142. data/lib/nanoc/base/entities/lazy_value.rb +0 -43
  143. data/lib/nanoc/base/entities/pattern.rb +0 -85
  144. data/lib/nanoc/base/entities/processing_action.rb +0 -21
  145. data/lib/nanoc/base/entities/processing_actions.rb +0 -5
  146. data/lib/nanoc/base/entities/processing_actions/filter.rb +0 -36
  147. data/lib/nanoc/base/entities/processing_actions/layout.rb +0 -36
  148. data/lib/nanoc/base/entities/processing_actions/snapshot.rb +0 -46
  149. data/lib/nanoc/base/entities/snapshot_def.rb +0 -22
  150. data/lib/nanoc/base/repos/data_source.rb +0 -168
  151. data/lib/nanoc/base/repos/snapshot_repo.rb +0 -67
  152. data/lib/nanoc/base/services/checksummer.rb +0 -274
  153. data/lib/nanoc/base/services/notification_center.rb +0 -87
  154. data/lib/nanoc/base/services/temp_filename_factory.rb +0 -52
@@ -1,13 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Nanoc::Int::Compiler::Stage
4
- def call(*args)
5
- Nanoc::Int::Instrumentor.call(:stage_ran, self.class) do
6
- run(*args)
7
- end
8
- end
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ class Stage
7
+ def call(*args)
8
+ notify(:stage_started)
9
+ res = Nanoc::Int::Instrumentor.call(:stage_ran, self.class) do
10
+ run(*args)
11
+ end
12
+ notify(:stage_ended)
13
+ res
14
+ rescue
15
+ notify(:stage_aborted)
16
+ raise
17
+ end
18
+
19
+ def run(*)
20
+ raise NotImplementedError
21
+ end
9
22
 
10
- def run(*)
11
- raise NotImplementedError
23
+ private
24
+
25
+ def notify(sym)
26
+ name = self.class.to_s.sub(/^.*::/, '')
27
+ Nanoc::Core::NotificationCenter.post(sym, name)
28
+ end
29
+ end
30
+ end
12
31
  end
13
32
  end
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ end
8
+ end
9
+ end
4
10
  end
5
11
 
6
12
  require_relative 'stage'
@@ -1,29 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
4
- class BuildReps < Nanoc::Int::Compiler::Stage
5
- def initialize(site:, action_provider:)
6
- @site = site
7
- @action_provider = action_provider
8
- end
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ class BuildReps < Nanoc::Int::Compiler::Stage
8
+ def initialize(site:, action_provider:)
9
+ @site = site
10
+ @action_provider = action_provider
11
+ end
9
12
 
10
- def run
11
- reps = Nanoc::Int::ItemRepRepo.new
13
+ def run
14
+ reps = Nanoc::Int::ItemRepRepo.new
12
15
 
13
- builder = Nanoc::Int::ItemRepBuilder.new(
14
- @site, @action_provider, reps
15
- )
16
+ builder = Nanoc::Int::ItemRepBuilder.new(
17
+ @site, @action_provider, reps
18
+ )
16
19
 
17
- action_sequences = builder.run
20
+ action_sequences = builder.run
18
21
 
19
- @site.layouts.each do |layout|
20
- action_sequences[layout] = @action_provider.action_sequence_for(layout)
21
- end
22
+ @site.layouts.each do |layout|
23
+ action_sequences[layout] = @action_provider.action_sequence_for(layout)
24
+ end
22
25
 
23
- {
24
- reps: reps,
25
- action_sequences: action_sequences,
26
- }
26
+ {
27
+ reps: reps,
28
+ action_sequences: action_sequences,
29
+ }
30
+ end
31
+ end
32
+ end
27
33
  end
28
34
  end
29
35
  end
@@ -1,38 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
4
- class CalculateChecksums < Nanoc::Int::Compiler::Stage
5
- def initialize(items:, layouts:, code_snippets:, config:)
6
- @items = items
7
- @layouts = layouts
8
- @code_snippets = code_snippets
9
- @config = config
10
- end
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ class CalculateChecksums < Nanoc::Int::Compiler::Stage
8
+ def initialize(items:, layouts:, code_snippets:, config:)
9
+ @items = items
10
+ @layouts = layouts
11
+ @code_snippets = code_snippets
12
+ @config = config
13
+ end
11
14
 
12
- def run
13
- checksums = {}
15
+ def run
16
+ checksums = {}
14
17
 
15
- [@items, @layouts].each do |documents|
16
- documents.each do |document|
17
- checksums[[document.reference, :content]] =
18
- Nanoc::Int::Checksummer.calc_for_content_of(document)
19
- checksums[[document.reference, :each_attribute]] =
20
- Nanoc::Int::Checksummer.calc_for_each_attribute_of(document)
21
- end
22
- end
18
+ [@items, @layouts].each do |documents|
19
+ documents.each do |document|
20
+ checksums[[document.reference, :content]] =
21
+ Nanoc::Core::Checksummer.calc_for_content_of(document)
22
+ checksums[[document.reference, :each_attribute]] =
23
+ Nanoc::Core::Checksummer.calc_for_each_attribute_of(document)
24
+ end
25
+ end
23
26
 
24
- [@items, @layouts, @code_snippets].each do |objs|
25
- objs.each do |obj|
26
- checksums[obj.reference] = Nanoc::Int::Checksummer.calc(obj)
27
- end
28
- end
27
+ [@items, @layouts, @code_snippets].each do |objs|
28
+ objs.each do |obj|
29
+ checksums[obj.reference] = Nanoc::Core::Checksummer.calc(obj)
30
+ end
31
+ end
29
32
 
30
- checksums[@config.reference] =
31
- Nanoc::Int::Checksummer.calc(@config)
32
- checksums[[@config.reference, :each_attribute]] =
33
- Nanoc::Int::Checksummer.calc_for_each_attribute_of(@config)
33
+ checksums[@config.reference] =
34
+ Nanoc::Core::Checksummer.calc(@config)
35
+ checksums[[@config.reference, :each_attribute]] =
36
+ Nanoc::Core::Checksummer.calc_for_each_attribute_of(@config)
34
37
 
35
- Nanoc::Int::ChecksumCollection.new(checksums)
38
+ Nanoc::Int::ChecksumCollection.new(checksums)
39
+ end
40
+ end
41
+ end
36
42
  end
37
43
  end
38
44
  end
@@ -1,37 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
4
- class Cleanup < Nanoc::Int::Compiler::Stage
5
- def initialize(output_dirs)
6
- @output_dirs = output_dirs
7
- end
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ class Cleanup < Nanoc::Int::Compiler::Stage
8
+ def initialize(output_dirs)
9
+ @output_dirs = output_dirs
10
+ end
8
11
 
9
- def run
10
- cleanup_temps(Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
11
- cleanup_temps(Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR)
12
- cleanup_unused_stores
13
- cleanup_old_stores
14
- end
12
+ def run
13
+ cleanup_temps(Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
14
+ cleanup_temps(Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR)
15
+ cleanup_unused_stores
16
+ cleanup_old_stores
17
+ end
15
18
 
16
- private
19
+ private
17
20
 
18
- def cleanup_temps(dir)
19
- Nanoc::Int::TempFilenameFactory.instance.cleanup(dir)
20
- end
21
+ def cleanup_temps(dir)
22
+ Nanoc::Core::TempFilenameFactory.instance.cleanup(dir)
23
+ end
21
24
 
22
- def cleanup_unused_stores
23
- used_paths = @output_dirs.map { |d| Nanoc::Int::Store.tmp_path_prefix(d) }
24
- all_paths = Dir.glob('tmp/nanoc/*')
25
- (all_paths - used_paths).each do |obsolete_path|
26
- FileUtils.rm_rf(obsolete_path)
27
- end
28
- end
25
+ def cleanup_unused_stores
26
+ used_paths = @output_dirs.map { |d| Nanoc::Int::Store.tmp_path_prefix(d) }
27
+ all_paths = Dir.glob('tmp/nanoc/*')
28
+ (all_paths - used_paths).each do |obsolete_path|
29
+ FileUtils.rm_rf(obsolete_path)
30
+ end
31
+ end
29
32
 
30
- def cleanup_old_stores
31
- %w[checksums compiled_content dependencies outdatedness action_sequence].each do |fn|
32
- full_fn = File.join('tmp', fn)
33
- if File.file?(full_fn)
34
- FileUtils.rm_f(full_fn)
33
+ def cleanup_old_stores
34
+ %w[checksums compiled_content dependencies outdatedness action_sequence].each do |fn|
35
+ full_fn = File.join('tmp', fn)
36
+ if File.file?(full_fn)
37
+ FileUtils.rm_f(full_fn)
38
+ end
39
+ end
40
+ end
35
41
  end
36
42
  end
37
43
  end
@@ -1,88 +1,98 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
4
- class CompileReps < Nanoc::Int::Compiler::Stage
5
- include Nanoc::Int::ContractsSupport
6
- include Nanoc::Assertions::Mixin
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ class CompileReps < Nanoc::Int::Compiler::Stage
8
+ include Nanoc::Core::ContractsSupport
9
+ include Nanoc::Assertions::Mixin
7
10
 
8
- def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
9
- @reps = reps
10
- @outdatedness_store = outdatedness_store
11
- @dependency_store = dependency_store
12
- @action_sequences = action_sequences
13
- @compilation_context = compilation_context
14
- @compiled_content_cache = compiled_content_cache
15
- end
11
+ def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
12
+ @reps = reps
13
+ @outdatedness_store = outdatedness_store
14
+ @dependency_store = dependency_store
15
+ @action_sequences = action_sequences
16
+ @compilation_context = compilation_context
17
+ @compiled_content_cache = compiled_content_cache
18
+ end
16
19
 
17
- def run
18
- outdated_reps = @reps.select { |r| @outdatedness_store.include?(r) }
19
- selector = Nanoc::Int::ItemRepSelector.new(outdated_reps)
20
- run_phase_stack do |phase_stack|
21
- selector.each do |rep|
22
- handle_errors_while(rep) do
23
- compile_rep(rep, phase_stack: phase_stack, is_outdated: @outdatedness_store.include?(rep))
20
+ def run
21
+ outdated_reps = @reps.select { |r| @outdatedness_store.include?(r) }
22
+ selector = Nanoc::Int::ItemRepSelector.new(outdated_reps)
23
+ run_phase_stack do |phase_stack|
24
+ selector.each do |rep|
25
+ handle_errors_while(rep) do
26
+ compile_rep(rep, phase_stack: phase_stack, is_outdated: @outdatedness_store.include?(rep))
27
+ end
28
+ end
29
+ end
30
+
31
+ assert Nanoc::Assertions::AllItemRepsHaveCompiledContent.new(
32
+ compiled_content_cache: @compiled_content_cache,
33
+ item_reps: @reps,
34
+ )
35
+ ensure
36
+ @outdatedness_store.store
37
+ @compiled_content_cache.prune(items: @reps.map(&:item).uniq)
38
+ @compiled_content_cache.store
24
39
  end
25
- end
26
- end
27
40
 
28
- assert Nanoc::Assertions::AllItemRepsHaveCompiledContent.new(
29
- compiled_content_cache: @compiled_content_cache,
30
- item_reps: @reps,
31
- )
32
- ensure
33
- @outdatedness_store.store
34
- @compiled_content_cache.prune(items: @reps.map(&:item).uniq)
35
- @compiled_content_cache.store
36
- end
41
+ private
37
42
 
38
- private
43
+ def handle_errors_while(item_rep)
44
+ yield
45
+ rescue Exception => e # rubocop:disable Lint/RescueException
46
+ raise Nanoc::Int::Errors::CompilationError.new(e, item_rep)
47
+ end
39
48
 
40
- def handle_errors_while(item_rep)
41
- yield
42
- rescue Exception => e # rubocop:disable Lint/RescueException
43
- raise Nanoc::Int::Errors::CompilationError.new(e, item_rep)
44
- end
49
+ def compile_rep(rep, phase_stack:, is_outdated:)
50
+ phase_stack.call(rep, is_outdated: is_outdated)
51
+ end
45
52
 
46
- def compile_rep(rep, phase_stack:, is_outdated:)
47
- phase_stack.call(rep, is_outdated: is_outdated)
48
- end
53
+ def run_phase_stack
54
+ phase_stack = build_phase_stack
55
+ phase_stack.start
56
+ yield(phase_stack)
57
+ ensure
58
+ phase_stack.stop
59
+ end
49
60
 
50
- def run_phase_stack
51
- phase_stack = build_phase_stack
52
- phase_stack.start
53
- yield(phase_stack)
54
- ensure
55
- phase_stack.stop
56
- end
61
+ def build_phase_stack
62
+ recalculate_phase = Nanoc::Int::Compiler::Phases::Recalculate.new(
63
+ action_sequences: @action_sequences,
64
+ dependency_store: @dependency_store,
65
+ compilation_context: @compilation_context,
66
+ )
57
67
 
58
- def build_phase_stack
59
- recalculate_phase = Nanoc::Int::Compiler::Phases::Recalculate.new(
60
- action_sequences: @action_sequences,
61
- dependency_store: @dependency_store,
62
- compilation_context: @compilation_context,
63
- )
68
+ cache_phase = Nanoc::Int::Compiler::Phases::Cache.new(
69
+ compiled_content_cache: @compiled_content_cache,
70
+ compiled_content_store: @compilation_context.compiled_content_store,
71
+ wrapped: recalculate_phase,
72
+ )
64
73
 
65
- cache_phase = Nanoc::Int::Compiler::Phases::Cache.new(
66
- compiled_content_cache: @compiled_content_cache,
67
- snapshot_repo: @compilation_context.snapshot_repo,
68
- wrapped: recalculate_phase,
69
- )
74
+ resume_phase = Nanoc::Int::Compiler::Phases::Resume.new(
75
+ wrapped: cache_phase,
76
+ )
70
77
 
71
- resume_phase = Nanoc::Int::Compiler::Phases::Resume.new(
72
- wrapped: cache_phase,
73
- )
78
+ write_phase = Nanoc::Int::Compiler::Phases::Write.new(
79
+ compiled_content_store: @compilation_context.compiled_content_store,
80
+ wrapped: resume_phase,
81
+ )
74
82
 
75
- write_phase = Nanoc::Int::Compiler::Phases::Write.new(
76
- snapshot_repo: @compilation_context.snapshot_repo,
77
- wrapped: resume_phase,
78
- )
83
+ mark_done_phase = Nanoc::Int::Compiler::Phases::MarkDone.new(
84
+ wrapped: write_phase,
85
+ outdatedness_store: @outdatedness_store,
86
+ )
79
87
 
80
- mark_done_phase = Nanoc::Int::Compiler::Phases::MarkDone.new(
81
- wrapped: write_phase,
82
- outdatedness_store: @outdatedness_store,
83
- )
88
+ notify_phrase = Nanoc::Int::Compiler::Phases::Notify.new(
89
+ wrapped: mark_done_phase,
90
+ )
84
91
 
85
- mark_done_phase
92
+ notify_phrase
93
+ end
94
+ end
95
+ end
86
96
  end
87
97
  end
88
98
  end
@@ -1,45 +1,51 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Nanoc::Int::Compiler::Stages
4
- class DetermineOutdatedness < Nanoc::Int::Compiler::Stage
5
- include Nanoc::Int::ContractsSupport
6
-
7
- def initialize(reps:, outdatedness_checker:, outdatedness_store:)
8
- @reps = reps
9
- @outdatedness_checker = outdatedness_checker
10
- @outdatedness_store = outdatedness_store
11
- end
12
-
13
- contract C::None => C::Any
14
- def run
15
- outdated_items = select_outdated_items
16
- outdated_reps = reps_of_items(outdated_items)
17
-
18
- store_outdated_reps(outdated_reps)
19
-
20
- outdated_items
21
- end
22
-
23
- private
24
-
25
- def store_outdated_reps(reps)
26
- @outdatedness_store.clear
27
- reps.each { |r| @outdatedness_store.add(r) }
28
- end
29
-
30
- def select_outdated_items
31
- @reps
32
- .select { |r| outdated?(r) }
33
- .map(&:item)
34
- .uniq
35
- end
36
-
37
- def reps_of_items(items)
38
- Set.new(items.flat_map { |i| @reps[i] })
39
- end
40
-
41
- def outdated?(rep)
42
- @outdatedness_store.include?(rep) || @outdatedness_checker.outdated?(rep)
3
+ module Nanoc
4
+ module Int
5
+ class Compiler
6
+ module Stages
7
+ class DetermineOutdatedness < Nanoc::Int::Compiler::Stage
8
+ include Nanoc::Core::ContractsSupport
9
+
10
+ def initialize(reps:, outdatedness_checker:, outdatedness_store:)
11
+ @reps = reps
12
+ @outdatedness_checker = outdatedness_checker
13
+ @outdatedness_store = outdatedness_store
14
+ end
15
+
16
+ contract C::None => C::Any
17
+ def run
18
+ outdated_items = select_outdated_items
19
+ outdated_reps = reps_of_items(outdated_items)
20
+
21
+ store_outdated_reps(outdated_reps)
22
+
23
+ outdated_items
24
+ end
25
+
26
+ private
27
+
28
+ def store_outdated_reps(reps)
29
+ @outdatedness_store.clear
30
+ reps.each { |r| @outdatedness_store.add(r) }
31
+ end
32
+
33
+ def select_outdated_items
34
+ @reps
35
+ .select { |r| outdated?(r) }
36
+ .map(&:item)
37
+ .uniq
38
+ end
39
+
40
+ def reps_of_items(items)
41
+ Set.new(items.flat_map { |i| @reps[i] })
42
+ end
43
+
44
+ def outdated?(rep)
45
+ @outdatedness_store.include?(rep) || @outdatedness_checker.outdated?(rep)
46
+ end
47
+ end
48
+ end
43
49
  end
44
50
  end
45
51
  end