nanoc 4.11.12 → 4.11.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +7 -1
  3. data/bin/nanoc +1 -1
  4. data/lib/nanoc.rb +2 -27
  5. data/lib/nanoc/base.rb +3 -6
  6. data/lib/nanoc/base/errors.rb +6 -104
  7. data/lib/nanoc/checking/check.rb +4 -4
  8. data/lib/nanoc/checking/checks/external_links.rb +1 -1
  9. data/lib/nanoc/checking/checks/stale.rb +1 -1
  10. data/lib/nanoc/checking/runner.rb +2 -2
  11. data/lib/nanoc/data_sources/filesystem/tools.rb +4 -4
  12. data/lib/nanoc/extra.rb +1 -1
  13. data/lib/nanoc/helpers/blogging.rb +8 -8
  14. data/lib/nanoc/helpers/capturing.rb +1 -1
  15. data/lib/nanoc/helpers/link_to.rb +1 -1
  16. data/lib/nanoc/orig_cli.rb +20 -0
  17. data/lib/nanoc/{cli → orig_cli}/commands/check.rb +3 -3
  18. data/lib/nanoc/{cli → orig_cli}/commands/deploy.rb +8 -8
  19. data/lib/nanoc/{cli → orig_cli}/commands/show-rules.rb +3 -3
  20. data/lib/nanoc/rule_dsl/action_provider.rb +5 -5
  21. data/lib/nanoc/rule_dsl/action_recorder.rb +4 -4
  22. data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
  23. data/lib/nanoc/rule_dsl/compiler_dsl.rb +1 -1
  24. data/lib/nanoc/rule_dsl/rule_context.rb +6 -6
  25. data/lib/nanoc/version.rb +1 -1
  26. metadata +13 -152
  27. data/lib/nanoc/base/error.rb +0 -7
  28. data/lib/nanoc/base/feature.rb +0 -104
  29. data/lib/nanoc/base/repos.rb +0 -4
  30. data/lib/nanoc/base/repos/config_loader.rb +0 -95
  31. data/lib/nanoc/base/repos/site_loader.rb +0 -102
  32. data/lib/nanoc/base/services.rb +0 -23
  33. data/lib/nanoc/base/services/compiler.rb +0 -214
  34. data/lib/nanoc/base/services/compiler/phases.rb +0 -19
  35. data/lib/nanoc/base/services/compiler/phases/abstract.rb +0 -50
  36. data/lib/nanoc/base/services/compiler/phases/cache.rb +0 -45
  37. data/lib/nanoc/base/services/compiler/phases/mark_done.rb +0 -25
  38. data/lib/nanoc/base/services/compiler/phases/notify.rb +0 -21
  39. data/lib/nanoc/base/services/compiler/phases/recalculate.rb +0 -51
  40. data/lib/nanoc/base/services/compiler/phases/resume.rb +0 -54
  41. data/lib/nanoc/base/services/compiler/phases/write.rb +0 -86
  42. data/lib/nanoc/base/services/compiler/stages.rb +0 -23
  43. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +0 -38
  44. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +0 -44
  45. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +0 -45
  46. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +0 -98
  47. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +0 -51
  48. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +0 -22
  49. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +0 -37
  50. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +0 -23
  51. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +0 -34
  52. data/lib/nanoc/base/services/compiler/stages/prune.rb +0 -32
  53. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +0 -22
  54. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +0 -34
  55. data/lib/nanoc/base/services/compiler_loader.rb +0 -48
  56. data/lib/nanoc/base/services/executor.rb +0 -134
  57. data/lib/nanoc/base/services/filter.rb +0 -267
  58. data/lib/nanoc/base/services/item_rep_builder.rb +0 -54
  59. data/lib/nanoc/base/services/item_rep_selector.rb +0 -69
  60. data/lib/nanoc/base/services/item_rep_writer.rb +0 -86
  61. data/lib/nanoc/base/services/outdatedness_checker.rb +0 -222
  62. data/lib/nanoc/base/services/outdatedness_rules.rb +0 -18
  63. data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +0 -41
  64. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +0 -31
  65. data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +0 -21
  66. data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +0 -20
  67. data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +0 -20
  68. data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +0 -17
  69. data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +0 -45
  70. data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +0 -26
  71. data/lib/nanoc/base/services/pruner.rb +0 -123
  72. data/lib/nanoc/base/views.rb +0 -40
  73. data/lib/nanoc/base/views/basic_item_rep_collection_view.rb +0 -86
  74. data/lib/nanoc/base/views/basic_item_rep_view.rb +0 -81
  75. data/lib/nanoc/base/views/basic_item_view.rb +0 -52
  76. data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +0 -10
  77. data/lib/nanoc/base/views/compilation_item_rep_view.rb +0 -49
  78. data/lib/nanoc/base/views/compilation_item_view.rb +0 -45
  79. data/lib/nanoc/base/views/config_view.rb +0 -68
  80. data/lib/nanoc/base/views/identifiable_collection_view.rb +0 -109
  81. data/lib/nanoc/base/views/item_collection_with_reps_view.rb +0 -10
  82. data/lib/nanoc/base/views/item_collection_without_reps_view.rb +0 -10
  83. data/lib/nanoc/base/views/layout_collection_view.rb +0 -10
  84. data/lib/nanoc/base/views/layout_view.rb +0 -7
  85. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +0 -88
  86. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +0 -58
  87. data/lib/nanoc/base/views/mutable_config_view.rb +0 -14
  88. data/lib/nanoc/base/views/mutable_identifiable_collection_view.rb +0 -17
  89. data/lib/nanoc/base/views/mutable_item_collection_view.rb +0 -32
  90. data/lib/nanoc/base/views/mutable_item_view.rb +0 -7
  91. data/lib/nanoc/base/views/mutable_layout_collection_view.rb +0 -24
  92. data/lib/nanoc/base/views/mutable_layout_view.rb +0 -7
  93. data/lib/nanoc/base/views/post_compile_item_collection_view.rb +0 -10
  94. data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +0 -10
  95. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +0 -31
  96. data/lib/nanoc/base/views/post_compile_item_view.rb +0 -18
  97. data/lib/nanoc/base/views/view.rb +0 -41
  98. data/lib/nanoc/cli.rb +0 -241
  99. data/lib/nanoc/cli/ansi_string_colorizer.rb +0 -28
  100. data/lib/nanoc/cli/cleaning_stream.rb +0 -160
  101. data/lib/nanoc/cli/command_runner.rb +0 -72
  102. data/lib/nanoc/cli/commands/compile.rb +0 -57
  103. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +0 -58
  104. data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +0 -50
  105. data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +0 -100
  106. data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +0 -101
  107. data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +0 -76
  108. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +0 -170
  109. data/lib/nanoc/cli/commands/create-site.rb +0 -257
  110. data/lib/nanoc/cli/commands/nanoc.rb +0 -42
  111. data/lib/nanoc/cli/commands/prune.rb +0 -49
  112. data/lib/nanoc/cli/commands/shell.rb +0 -57
  113. data/lib/nanoc/cli/commands/show-data.rb +0 -185
  114. data/lib/nanoc/cli/commands/show-plugins.rb +0 -89
  115. data/lib/nanoc/cli/commands/view.rb +0 -68
  116. data/lib/nanoc/cli/error_handler.rb +0 -365
  117. data/lib/nanoc/cli/logger.rb +0 -75
  118. data/lib/nanoc/cli/stack_trace_writer.rb +0 -50
  119. data/lib/nanoc/cli/stream_cleaners.rb +0 -10
  120. data/lib/nanoc/cli/stream_cleaners/abstract.rb +0 -21
  121. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -13
  122. data/lib/nanoc/cli/stream_cleaners/utf8.rb +0 -17
  123. data/lib/nanoc/cli/transform.rb +0 -16
  124. data/lib/nanoc/spec.rb +0 -240
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class Cleanup < Nanoc::Core::CompilationStage
8
- def initialize(output_dirs)
9
- @output_dirs = output_dirs
10
- end
11
-
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
18
-
19
- private
20
-
21
- def cleanup_temps(dir)
22
- Nanoc::Core::TempFilenameFactory.instance.cleanup(dir)
23
- end
24
-
25
- def cleanup_unused_stores
26
- used_paths = @output_dirs.map { |d| Nanoc::Core::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
32
-
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
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class CompileReps < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
- include Nanoc::Core::Assertions::Mixin
10
-
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
19
-
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::Core::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
39
- end
40
-
41
- private
42
-
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
48
-
49
- def compile_rep(rep, phase_stack:, is_outdated:)
50
- phase_stack.call(rep, is_outdated: is_outdated)
51
- end
52
-
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
60
-
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
- )
67
-
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
- )
73
-
74
- resume_phase = Nanoc::Int::Compiler::Phases::Resume.new(
75
- wrapped: cache_phase,
76
- )
77
-
78
- write_phase = Nanoc::Int::Compiler::Phases::Write.new(
79
- compiled_content_store: @compilation_context.compiled_content_store,
80
- wrapped: resume_phase,
81
- )
82
-
83
- mark_done_phase = Nanoc::Int::Compiler::Phases::MarkDone.new(
84
- wrapped: write_phase,
85
- outdatedness_store: @outdatedness_store,
86
- )
87
-
88
- notify_phrase = Nanoc::Int::Compiler::Phases::Notify.new(
89
- wrapped: mark_done_phase,
90
- )
91
-
92
- notify_phrase
93
- end
94
- end
95
- end
96
- end
97
- end
98
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class DetermineOutdatedness < Nanoc::Core::CompilationStage
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
49
- end
50
- end
51
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class ForgetOutdatedDependencies < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(dependency_store:)
11
- @dependency_store = dependency_store
12
- end
13
-
14
- contract C::IterOf[Nanoc::Core::Item] => C::Any
15
- def run(outdated_items)
16
- outdated_items.each { |i| @dependency_store.forget_dependencies_for(i) }
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class LoadStores < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(checksum_store:, compiled_content_cache:, dependency_store:, action_sequence_store:, outdatedness_store:)
11
- @checksum_store = checksum_store
12
- @compiled_content_cache = compiled_content_cache
13
- @dependency_store = dependency_store
14
- @action_sequence_store = action_sequence_store
15
- @outdatedness_store = outdatedness_store
16
- end
17
-
18
- contract C::None => C::Any
19
- def run
20
- load_store(@checksum_store)
21
- load_store(@compiled_content_cache)
22
- load_store(@dependency_store)
23
- load_store(@action_sequence_store)
24
- load_store(@outdatedness_store)
25
- end
26
-
27
- contract Nanoc::Core::Store => C::Any
28
- def load_store(store)
29
- Nanoc::Core::Instrumentor.call(:store_loaded, store.class) do
30
- store.load
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class Postprocess < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(action_provider:, site:)
11
- @action_provider = action_provider
12
- @site = site
13
- end
14
-
15
- contract Nanoc::Int::Compiler => C::Any
16
- def run(compiler)
17
- @action_provider.postprocess(@site, compiler)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class Preprocess < Nanoc::Core::CompilationStage
8
- def initialize(action_provider:, site:, dependency_store:, checksum_store:)
9
- @action_provider = action_provider
10
- @site = site
11
- @dependency_store = dependency_store
12
- @checksum_store = checksum_store
13
- end
14
-
15
- def run
16
- return if @site.preprocessed?
17
-
18
- if @action_provider.need_preprocessing?
19
- @site.data_source = Nanoc::Core::InMemoryDataSource.new(@site.items, @site.layouts, @site.data_source)
20
- @action_provider.preprocess(@site)
21
-
22
- @dependency_store.items = @site.items
23
- @dependency_store.layouts = @site.layouts
24
- @checksum_store.objects = @site.items.to_a + @site.layouts.to_a + @site.code_snippets + [@site.config]
25
- end
26
-
27
- @site.mark_as_preprocessed
28
- @site.freeze
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class Prune < Nanoc::Core::CompilationStage
8
- def initialize(config:, reps:)
9
- @config = config
10
- @reps = reps
11
- end
12
-
13
- def run
14
- if @config[:prune][:auto_prune]
15
- Nanoc::Pruner.new(@config, @reps, exclude: prune_config_exclude).run
16
- end
17
- end
18
-
19
- private
20
-
21
- def prune_config
22
- @config[:prune] || {}
23
- end
24
-
25
- def prune_config_exclude
26
- prune_config[:exclude] || {}
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class StorePostCompilationState < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(dependency_store:)
11
- @dependency_store = dependency_store
12
- end
13
-
14
- contract C::None => C::Any
15
- def run
16
- @dependency_store.store
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- module Stages
7
- class StorePreCompilationState < Nanoc::Core::CompilationStage
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(reps:, layouts:, checksum_store:, action_sequence_store:, action_sequences:)
11
- @reps = reps
12
- @layouts = layouts
13
- @checksum_store = checksum_store
14
- @action_sequence_store = action_sequence_store
15
- @action_sequences = action_sequences
16
- end
17
-
18
- contract Nanoc::Core::ChecksumCollection => C::Any
19
- def run(checksums)
20
- # Calculate action sequence
21
- (@reps.to_a + @layouts.to_a).each do |obj|
22
- @action_sequence_store[obj] = @action_sequences[obj].serialize
23
- end
24
- @action_sequence_store.store
25
-
26
- # Set checksums
27
- @checksum_store.checksums = checksums.to_h
28
- @checksum_store.store
29
- end
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- # @api private
6
- class CompilerLoader
7
- def load(site, action_provider: nil)
8
- action_sequence_store = Nanoc::Core::ActionSequenceStore.new(config: site.config)
9
-
10
- dependency_store =
11
- Nanoc::Core::DependencyStore.new(site.items, site.layouts, site.config)
12
-
13
- objects = site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]
14
-
15
- checksum_store =
16
- Nanoc::Core::ChecksumStore.new(config: site.config, objects: objects)
17
-
18
- action_provider ||= Nanoc::Core::ActionProvider.named(site.config.action_provider).for(site)
19
-
20
- outdatedness_store =
21
- Nanoc::Core::OutdatednessStore.new(config: site.config)
22
-
23
- compiled_content_cache =
24
- compiled_content_cache_class.new(config: site.config)
25
-
26
- params = {
27
- compiled_content_cache: compiled_content_cache,
28
- checksum_store: checksum_store,
29
- action_sequence_store: action_sequence_store,
30
- dependency_store: dependency_store,
31
- action_provider: action_provider,
32
- outdatedness_store: outdatedness_store,
33
- }
34
-
35
- Nanoc::Int::Compiler.new(site, params)
36
- end
37
-
38
- def compiled_content_cache_class
39
- feature_name = Nanoc::Feature::BINARY_COMPILED_CONTENT_CACHE
40
- if Nanoc::Feature.enabled?(feature_name)
41
- Nanoc::Core::CompiledContentCache
42
- else
43
- Nanoc::Core::TextualCompiledContentCache
44
- end
45
- end
46
- end
47
- end
48
- end