nanoc-core 4.14.6 → 4.14.8

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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nanoc/core/action_sequence.rb +1 -1
  3. data/lib/nanoc/core/action_sequence_builder.rb +12 -4
  4. data/lib/nanoc/core/action_sequence_store.rb +8 -5
  5. data/lib/nanoc/core/assertions.rb +12 -2
  6. data/lib/nanoc/core/basic_outdatedness_checker.rb +26 -10
  7. data/lib/nanoc/core/binary_compiled_content_cache.rb +24 -10
  8. data/lib/nanoc/core/checksum_collection.rb +7 -2
  9. data/lib/nanoc/core/checksum_store.rb +26 -9
  10. data/lib/nanoc/core/checksummer.rb +63 -32
  11. data/lib/nanoc/core/code_snippet.rb +1 -1
  12. data/lib/nanoc/core/compilation_stages/build_reps.rb +7 -2
  13. data/lib/nanoc/core/compilation_stages/calculate_checksums.rb +2 -0
  14. data/lib/nanoc/core/compilation_stages/cleanup.rb +8 -2
  15. data/lib/nanoc/core/compilation_stages/compile_reps.rb +78 -36
  16. data/lib/nanoc/core/compilation_stages/determine_outdatedness.rb +2 -0
  17. data/lib/nanoc/core/compilation_stages/forget_outdated_dependencies.rb +5 -1
  18. data/lib/nanoc/core/compilation_stages/load_stores.rb +6 -1
  19. data/lib/nanoc/core/compilation_stages/postprocess.rb +2 -0
  20. data/lib/nanoc/core/compilation_stages/preprocess.rb +12 -3
  21. data/lib/nanoc/core/compilation_stages/prune.rb +6 -1
  22. data/lib/nanoc/core/compilation_stages/store_post_compilation_state.rb +2 -0
  23. data/lib/nanoc/core/compilation_stages/store_pre_compilation_state.rb +6 -1
  24. data/lib/nanoc/core/compiled_content_cache.rb +7 -2
  25. data/lib/nanoc/core/compiled_content_repo.rb +13 -5
  26. data/lib/nanoc/core/compiler.rb +12 -3
  27. data/lib/nanoc/core/compiler_loader.rb +13 -4
  28. data/lib/nanoc/core/config_loader.rb +14 -4
  29. data/lib/nanoc/core/configuration.rb +36 -15
  30. data/lib/nanoc/core/content.rb +5 -1
  31. data/lib/nanoc/core/context.rb +4 -5
  32. data/lib/nanoc/core/contracts_support.rb +26 -8
  33. data/lib/nanoc/core/core_ext/hash.rb +12 -2
  34. data/lib/nanoc/core/data_source.rb +22 -6
  35. data/lib/nanoc/core/dependency.rb +8 -2
  36. data/lib/nanoc/core/dependency_props.rb +27 -8
  37. data/lib/nanoc/core/dependency_store.rb +55 -22
  38. data/lib/nanoc/core/dependency_tracker.rb +20 -4
  39. data/lib/nanoc/core/directed_graph.rb +27 -64
  40. data/lib/nanoc/core/document.rb +4 -1
  41. data/lib/nanoc/core/errors.rb +45 -12
  42. data/lib/nanoc/core/executor.rb +26 -9
  43. data/lib/nanoc/core/feature.rb +2 -1
  44. data/lib/nanoc/core/filter.rb +27 -11
  45. data/lib/nanoc/core/identifiable_collection.rb +2 -1
  46. data/lib/nanoc/core/identifier.rb +23 -8
  47. data/lib/nanoc/core/in_memory_data_source.rb +3 -1
  48. data/lib/nanoc/core/item.rb +1 -1
  49. data/lib/nanoc/core/item_collection.rb +2 -2
  50. data/lib/nanoc/core/item_rep.rb +1 -1
  51. data/lib/nanoc/core/item_rep_builder.rb +14 -5
  52. data/lib/nanoc/core/item_rep_router.rb +27 -13
  53. data/lib/nanoc/core/item_rep_writer.rb +28 -5
  54. data/lib/nanoc/core/layout.rb +1 -1
  55. data/lib/nanoc/core/layout_collection.rb +2 -2
  56. data/lib/nanoc/core/mutable_document_view_mixin.rb +3 -6
  57. data/lib/nanoc/core/outdatedness_checker.rb +170 -95
  58. data/lib/nanoc/core/outdatedness_reasons.rb +45 -16
  59. data/lib/nanoc/core/outdatedness_rules/attributes_modified.rb +24 -10
  60. data/lib/nanoc/core/outdatedness_rules/item_added.rb +9 -4
  61. data/lib/nanoc/core/outdatedness_rules/layout_added.rb +9 -4
  62. data/lib/nanoc/core/outdatedness_rules/not_written.rb +7 -2
  63. data/lib/nanoc/core/outdatedness_rules/rules_modified.rb +14 -6
  64. data/lib/nanoc/core/outdatedness_rules/uses_always_outdated_filter.rb +1 -1
  65. data/lib/nanoc/core/outdatedness_store.rb +7 -1
  66. data/lib/nanoc/core/pattern.rb +4 -1
  67. data/lib/nanoc/core/prefixed_data_source.rb +6 -2
  68. data/lib/nanoc/core/processing_actions/filter.rb +2 -0
  69. data/lib/nanoc/core/processing_actions/layout.rb +2 -0
  70. data/lib/nanoc/core/processing_actions/snapshot.rb +12 -3
  71. data/lib/nanoc/core/pruner.rb +11 -3
  72. data/lib/nanoc/core/regexp_pattern.rb +1 -1
  73. data/lib/nanoc/core/site.rb +10 -4
  74. data/lib/nanoc/core/site_loader.rb +25 -17
  75. data/lib/nanoc/core/store.rb +33 -6
  76. data/lib/nanoc/core/string_pattern.rb +1 -1
  77. data/lib/nanoc/core/textual_compiled_content_cache.rb +60 -5
  78. data/lib/nanoc/core/textual_content.rb +4 -1
  79. data/lib/nanoc/core/version.rb +1 -1
  80. data/lib/nanoc/core/view_context_for_compilation.rb +6 -2
  81. data/lib/nanoc/core/views/basic_item_rep_collection_view.rb +11 -4
  82. data/lib/nanoc/core/views/basic_item_rep_view.rb +9 -2
  83. data/lib/nanoc/core/views/basic_item_view.rb +17 -9
  84. data/lib/nanoc/core/views/compilation_item_rep_view.rb +12 -4
  85. data/lib/nanoc/core/views/compilation_item_view.rb +3 -1
  86. data/lib/nanoc/core/views/identifiable_collection_view.rb +17 -5
  87. data/lib/nanoc/core/views/mutable_item_collection_view.rb +5 -2
  88. data/lib/nanoc/core/views/mutable_layout_collection_view.rb +5 -2
  89. data/lib/nanoc/core/views/post_compile_item_view.rb +3 -1
  90. data/lib/nanoc/core.rb +4 -4
  91. metadata +3 -9
  92. data/lib/nanoc/core/compilation_phases/abstract.rb +0 -48
  93. data/lib/nanoc/core/compilation_phases/cache.rb +0 -28
  94. data/lib/nanoc/core/compilation_phases/mark_done.rb +0 -23
  95. data/lib/nanoc/core/compilation_phases/notify.rb +0 -22
  96. data/lib/nanoc/core/compilation_phases/recalculate.rb +0 -59
  97. data/lib/nanoc/core/compilation_phases/write.rb +0 -31
@@ -25,7 +25,8 @@ module Nanoc
25
25
  raise NotImplementedError
26
26
  end
27
27
 
28
- # Calls the given block once for each object, passing that object as a parameter.
28
+ # Calls the given block once for each object, passing that object as a
29
+ # parameter.
29
30
  #
30
31
  # @yieldparam [#identifier] object
31
32
  #
@@ -81,7 +82,11 @@ module Nanoc
81
82
  unless Nanoc::Core::Feature.enabled?(Nanoc::Core::Feature::WHERE)
82
83
  raise(
83
84
  Nanoc::Core::TrivialError,
84
- '#where is experimental, and not yet available unless the corresponding feature flag is turned on. Set the `NANOC_FEATURES` environment variable to `where` to enable its usage. (Alternatively, set the environment variable to `all` to turn on all feature flags.)',
85
+ '#where is experimental, and not yet available unless the ' \
86
+ 'corresponding feature flag is turned on. Set the ' \
87
+ '`NANOC_FEATURES` environment variable to `where` to enable ' \
88
+ 'its usage. (Alternatively, set the environment variable to ' \
89
+ '`all` to turn on all feature flags.)',
85
90
  )
86
91
  end
87
92
 
@@ -151,9 +156,13 @@ module Nanoc
151
156
  end
152
157
  when Regexp
153
158
  # Can only be a pattern match
154
- object_from_pattern_match = @objects.find { |i| i.identifier.to_s =~ arg }
159
+ object_from_pattern_match = @objects.find do |i|
160
+ i.identifier.to_s =~ arg
161
+ end
155
162
  else
156
- raise ArgumentError, "Unexpected argument #{arg.class} to []: Can only pass strings, identfiers, and regular expressions"
163
+ raise ArgumentError,
164
+ "Unexpected argument #{arg.class} to []: Can only pass " \
165
+ 'strings, identfiers, and regular expressions'
157
166
  end
158
167
 
159
168
  unless object_from_exact_match
@@ -172,7 +181,10 @@ module Nanoc
172
181
  [arg]
173
182
  end
174
183
 
175
- @context.dependency_tracker.bounce(_unwrap, raw_content: prop_attribute)
184
+ @context.dependency_tracker.bounce(
185
+ _unwrap,
186
+ raw_content: prop_attribute,
187
+ )
176
188
  end
177
189
 
178
190
  object = object_from_exact_match || object_from_pattern_match
@@ -16,7 +16,8 @@ module Nanoc
16
16
  #
17
17
  # @param [Hash] attributes A hash containing this item's attributes.
18
18
  #
19
- # @param [Nanoc::Core::Identifier, String] identifier This item's identifier.
19
+ # @param [Nanoc::Core::Identifier, String] identifier This item's
20
+ # identifier.
20
21
  #
21
22
  # @param [Boolean] binary Whether or not this item is binary
22
23
  #
@@ -26,7 +27,9 @@ module Nanoc
26
27
  # @return [self]
27
28
  def create(content, attributes, identifier, binary: false, filename: nil)
28
29
  content = Nanoc::Core::Content.create(content, binary:, filename:)
29
- @objects = @objects.add(Nanoc::Core::Item.new(content, attributes, identifier))
30
+ @objects = @objects.add(
31
+ Nanoc::Core::Item.new(content, attributes, identifier),
32
+ )
30
33
  self
31
34
  end
32
35
  end
@@ -14,11 +14,14 @@ module Nanoc
14
14
  #
15
15
  # @param [Hash] attributes A hash containing this layout's attributes.
16
16
  #
17
- # @param [Nanoc::Core::Identifier, String] identifier This layout's identifier.
17
+ # @param [Nanoc::Core::Identifier, String] identifier This layout's
18
+ # identifier.
18
19
  #
19
20
  # @return [self]
20
21
  def create(content, attributes, identifier)
21
- @objects = @objects.add(Nanoc::Core::Layout.new(content, attributes, identifier))
22
+ @objects = @objects.add(
23
+ Nanoc::Core::Layout.new(content, attributes, identifier),
24
+ )
22
25
  self
23
26
  end
24
27
  end
@@ -4,7 +4,9 @@ module Nanoc
4
4
  module Core
5
5
  class PostCompileItemView < Nanoc::Core::CompilationItemView
6
6
  def reps
7
- Nanoc::Core::PostCompileItemRepCollectionView.new(@context.reps[_unwrap], @context)
7
+ Nanoc::Core::PostCompileItemRepCollectionView.new(
8
+ @context.reps[_unwrap], @context
9
+ )
8
10
  end
9
11
 
10
12
  # @deprecated Use {#modified_reps} instead
data/lib/nanoc/core.rb CHANGED
@@ -72,10 +72,10 @@ end
72
72
 
73
73
  loader = Zeitwerk::Loader.new
74
74
  loader.inflector = inflector_class.new
75
- loader.push_dir(__dir__ + '/..')
76
- loader.push_dir(__dir__ + '/core/views', namespace: Nanoc::Core)
77
- loader.ignore(__dir__ + '/../nanoc-core.rb')
78
- loader.ignore(__dir__ + '/core/core_ext')
75
+ loader.push_dir("#{__dir__}/..")
76
+ loader.push_dir("#{__dir__}/core/views", namespace: Nanoc::Core)
77
+ loader.ignore("#{__dir__}/../nanoc-core.rb")
78
+ loader.ignore("#{__dir__}/core/core_ext")
79
79
  loader.setup
80
80
  loader.eager_load
81
81
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.14.6
4
+ version: 4.14.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -174,12 +174,6 @@ files:
174
174
  - lib/nanoc/core/checksummer.rb
175
175
  - lib/nanoc/core/code_snippet.rb
176
176
  - lib/nanoc/core/compilation_context.rb
177
- - lib/nanoc/core/compilation_phases/abstract.rb
178
- - lib/nanoc/core/compilation_phases/cache.rb
179
- - lib/nanoc/core/compilation_phases/mark_done.rb
180
- - lib/nanoc/core/compilation_phases/notify.rb
181
- - lib/nanoc/core/compilation_phases/recalculate.rb
182
- - lib/nanoc/core/compilation_phases/write.rb
183
177
  - lib/nanoc/core/compilation_stage.rb
184
178
  - lib/nanoc/core/compilation_stages/build_reps.rb
185
179
  - lib/nanoc/core/compilation_stages/calculate_checksums.rb
@@ -303,7 +297,7 @@ licenses:
303
297
  - MIT
304
298
  metadata:
305
299
  rubygems_mfa_required: 'true'
306
- source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.6/nanoc-core
300
+ source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.8/nanoc-core
307
301
  rdoc_options: []
308
302
  require_paths:
309
303
  - lib
@@ -318,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
312
  - !ruby/object:Gem::Version
319
313
  version: '0'
320
314
  requirements: []
321
- rubygems_version: 4.0.3
315
+ rubygems_version: 4.0.16
322
316
  specification_version: 4
323
317
  summary: Core of Nanoc
324
318
  test_files: []
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- class Abstract
7
- include Nanoc::Core::ContractsSupport
8
-
9
- def initialize(wrapped:)
10
- @wrapped = wrapped
11
- end
12
-
13
- def start
14
- @wrapped&.start
15
- end
16
-
17
- def stop
18
- @wrapped&.stop
19
- end
20
-
21
- def call(rep, is_outdated:)
22
- notify(:phase_started, rep)
23
- run(rep, is_outdated:) do
24
- notify(:phase_yielded, rep)
25
- @wrapped.call(rep, is_outdated:)
26
- notify(:phase_resumed, rep)
27
- end
28
- notify(:phase_ended, rep)
29
- rescue
30
- notify(:phase_aborted, rep)
31
- raise
32
- end
33
-
34
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
35
- def run(_rep, is_outdated:)
36
- raise NotImplementedError
37
- end
38
-
39
- private
40
-
41
- def notify(sym, rep)
42
- name = self.class.to_s.sub(/^.*::/, '')
43
- Nanoc::Core::NotificationCenter.post(sym, name, rep)
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- # Stores the compiled content in the cache once available.
7
- class Cache < Abstract
8
- include Nanoc::Core::ContractsSupport
9
-
10
- def initialize(wrapped:, compiled_content_cache:, compiled_content_repo:)
11
- super(wrapped:)
12
-
13
- @compiled_content_cache = compiled_content_cache
14
- @compiled_content_repo = compiled_content_repo
15
- end
16
-
17
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
18
- def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
19
- return if rep.compiled?
20
-
21
- yield
22
- @compiled_content_cache[rep] = @compiled_content_repo.get_all(rep)
23
- rep.compiled = true
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- class MarkDone < Abstract
7
- include Nanoc::Core::ContractsSupport
8
-
9
- def initialize(wrapped:, outdatedness_store:)
10
- super(wrapped:)
11
-
12
- @outdatedness_store = outdatedness_store
13
- end
14
-
15
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
16
- def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
17
- yield
18
- @outdatedness_store.remove(rep)
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- # Provides functionality for notifying start and end of compilation.
7
- class Notify < Abstract
8
- include Nanoc::Core::ContractsSupport
9
-
10
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
11
- def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
12
- Nanoc::Core::NotificationCenter.post(:compilation_started, rep)
13
- yield
14
- Nanoc::Core::NotificationCenter.post(:compilation_ended, rep)
15
- rescue Nanoc::Core::Errors::UnmetDependency
16
- Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep)
17
- raise
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- # Provides functionality for (re)calculating the content of an item rep, without caching or
7
- # outdatedness checking.
8
- class Recalculate < Abstract
9
- include Nanoc::Core::ContractsSupport
10
-
11
- def initialize(action_sequences:, dependency_store:, compilation_context:)
12
- super(wrapped: nil)
13
-
14
- @action_sequences = action_sequences
15
- @dependency_store = dependency_store
16
- @compilation_context = compilation_context
17
- end
18
-
19
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
20
- def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
21
- dependency_tracker = Nanoc::Core::DependencyTracker.new(@dependency_store, root: rep.item)
22
-
23
- executor = Nanoc::Core::Executor.new(rep, @compilation_context, dependency_tracker)
24
-
25
- # Set initial content, if not already present
26
- compiled_content_repo = @compilation_context.compiled_content_repo
27
- unless compiled_content_repo.get_current(rep)
28
- compiled_content_repo.set_current(rep, rep.item.content)
29
- end
30
-
31
- actions = pending_action_sequence_for(rep:)
32
- until actions.empty?
33
- action = actions.first
34
-
35
- case action
36
- when Nanoc::Core::ProcessingActions::Filter
37
- executor.filter(action.filter_name, action.params)
38
- when Nanoc::Core::ProcessingActions::Layout
39
- executor.layout(action.layout_identifier, action.params)
40
- when Nanoc::Core::ProcessingActions::Snapshot
41
- action.snapshot_names.each do |snapshot_name|
42
- executor.snapshot(snapshot_name)
43
- end
44
- else
45
- raise Nanoc::Core::Errors::InternalInconsistency, "unknown action #{action.inspect}"
46
- end
47
-
48
- actions.shift
49
- end
50
- end
51
-
52
- def pending_action_sequence_for(rep:)
53
- @_pending_action_sequences ||= {}
54
- @_pending_action_sequences[rep] ||= @action_sequences[rep].to_a
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- class Write < Abstract
7
- include Nanoc::Core::ContractsSupport
8
-
9
- def initialize(compiled_content_repo:, wrapped:)
10
- super(wrapped:)
11
-
12
- @compiled_content_repo = compiled_content_repo
13
-
14
- @writer = Nanoc::Core::ItemRepWriter.new
15
- end
16
-
17
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
18
- def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
19
- yield
20
-
21
- # Caution: Notification must be posted before enqueueing the rep,
22
- # or we risk a race condition where the :rep_write_ended
23
- # notification happens before the :rep_write_enqueued one.
24
- Nanoc::Core::NotificationCenter.post(:rep_write_enqueued, rep)
25
-
26
- @writer.write_all(rep, @compiled_content_repo)
27
- end
28
- end
29
- end
30
- end
31
- end