nanoc 4.11.12 → 4.11.13

Sign up to get free protection for your applications and to get access to all the features.
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,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- # Yields item reps to compile.
6
- #
7
- # @api private
8
- class ItemRepSelector
9
- def initialize(reps)
10
- @reps = reps
11
- end
12
-
13
- class MicroGraph
14
- def initialize(reps)
15
- @reps = Set.new(reps)
16
- @stack = []
17
- end
18
-
19
- def next
20
- if @stack.any?
21
- @stack.last
22
- elsif @reps.any?
23
- @reps.each { |rep| break rep }.tap do |rep|
24
- @reps.delete(rep)
25
- @stack.push(rep)
26
- end
27
- else
28
- nil
29
- end
30
- end
31
-
32
- def mark_ok
33
- @stack.pop
34
- end
35
-
36
- def mark_failed(dep)
37
- if @stack.include?(dep)
38
- raise Nanoc::Int::Errors::DependencyCycle.new(@stack + [dep])
39
- end
40
-
41
- @reps.delete(dep)
42
- @stack.push(dep)
43
- end
44
- end
45
-
46
- def each
47
- mg = MicroGraph.new(@reps)
48
-
49
- loop do
50
- rep = mg.next
51
- break if rep.nil?
52
-
53
- begin
54
- yield(rep)
55
- mg.mark_ok
56
- rescue => e
57
- actual_error = e.is_a?(Nanoc::Int::Errors::CompilationError) ? e.unwrap : e
58
-
59
- if actual_error.is_a?(Nanoc::Int::Errors::UnmetDependency)
60
- mg.mark_failed(actual_error.rep)
61
- else
62
- raise(e)
63
- end
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
@@ -1,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- # @api private
6
- class ItemRepWriter
7
- include Nanoc::Core::ContractsSupport
8
- include Nanoc::Core::Assertions::Mixin
9
-
10
- TMP_TEXT_ITEMS_DIR = 'text_items'
11
-
12
- def write_all(item_rep, compiled_content_store)
13
- written_paths = Set.new
14
-
15
- item_rep.snapshot_defs.map(&:name).each do |snapshot_name|
16
- write(item_rep, compiled_content_store, snapshot_name, written_paths)
17
- end
18
- end
19
-
20
- def write(item_rep, compiled_content_store, snapshot_name, written_paths)
21
- item_rep.raw_paths.fetch(snapshot_name, []).each do |raw_path|
22
- write_single(item_rep, compiled_content_store, snapshot_name, raw_path, written_paths)
23
- end
24
- end
25
-
26
- def write_single(item_rep, compiled_content_store, snapshot_name, raw_path, written_paths)
27
- assert Nanoc::Core::Assertions::PathIsAbsolute.new(path: raw_path)
28
-
29
- # Don’t write twice
30
- # TODO: test written_paths behavior
31
- return if written_paths.include?(raw_path)
32
-
33
- written_paths << raw_path
34
-
35
- # Create parent directory
36
- FileUtils.mkdir_p(File.dirname(raw_path))
37
-
38
- # Check if file will be created
39
- is_created = !File.file?(raw_path)
40
-
41
- # Notify
42
- Nanoc::Core::NotificationCenter.post(
43
- :rep_write_started, item_rep, raw_path
44
- )
45
-
46
- content = compiled_content_store.get(item_rep, snapshot_name)
47
- if content.binary?
48
- temp_path = content.filename
49
- else
50
- temp_path = temp_filename
51
- File.write(temp_path, content.string)
52
- end
53
-
54
- # Check whether content was modified
55
- is_modified = is_created || !FileUtils.identical?(raw_path, temp_path)
56
-
57
- # Notify ready for diff generation
58
- if !is_created && is_modified && !content.binary?
59
- Nanoc::Core::NotificationCenter.post(
60
- :rep_ready_for_diff, raw_path, File.read(raw_path), content.string
61
- )
62
- end
63
-
64
- # Write
65
- if is_modified
66
- begin
67
- FileUtils.ln(temp_path, raw_path, force: true)
68
- rescue Errno::EXDEV, Errno::EACCES
69
- FileUtils.cp(temp_path, raw_path)
70
- end
71
- end
72
-
73
- item_rep.modified = is_modified
74
-
75
- # Notify
76
- Nanoc::Core::NotificationCenter.post(
77
- :rep_write_ended, item_rep, content.binary?, raw_path, is_created, is_modified
78
- )
79
- end
80
-
81
- def temp_filename
82
- Nanoc::Core::TempFilenameFactory.instance.create(TMP_TEXT_ITEMS_DIR)
83
- end
84
- end
85
- end
86
- end
@@ -1,222 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- # Responsible for determining whether an item or a layout is outdated.
6
- #
7
- # @api private
8
- class OutdatednessChecker
9
- class Basic
10
- DDMemoize.activate(self)
11
-
12
- include Nanoc::Core::ContractsSupport
13
-
14
- Rules = Nanoc::Int::OutdatednessRules
15
-
16
- RULES_FOR_ITEM_REP =
17
- [
18
- Rules::RulesModified,
19
- Rules::ContentModified,
20
- Rules::AttributesModified,
21
- Rules::NotWritten,
22
- Rules::CodeSnippetsModified,
23
- Rules::UsesAlwaysOutdatedFilter,
24
- ].freeze
25
-
26
- RULES_FOR_LAYOUT =
27
- [
28
- Rules::RulesModified,
29
- Rules::ContentModified,
30
- Rules::AttributesModified,
31
- Rules::UsesAlwaysOutdatedFilter,
32
- ].freeze
33
-
34
- RULES_FOR_CONFIG =
35
- [
36
- Rules::AttributesModified,
37
- ].freeze
38
-
39
- RULES_FOR_ITEM_COLLECTION =
40
- [
41
- Rules::ItemCollectionExtended,
42
- ].freeze
43
-
44
- RULES_FOR_LAYOUT_COLLECTION =
45
- [
46
- Rules::LayoutCollectionExtended,
47
- ].freeze
48
-
49
- C_OBJ_MAYBE_REP = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep, Nanoc::Core::Configuration, Nanoc::Core::Layout, Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection]
50
-
51
- contract C::KeywordArgs[outdatedness_checker: OutdatednessChecker, reps: Nanoc::Core::ItemRepRepo] => C::Any
52
- def initialize(outdatedness_checker:, reps:)
53
- @outdatedness_checker = outdatedness_checker
54
- @reps = reps
55
- end
56
-
57
- contract C_OBJ_MAYBE_REP => C::Maybe[Nanoc::Core::OutdatednessStatus]
58
- memoized def outdatedness_status_for(obj)
59
- case obj
60
- when Nanoc::Core::ItemRep
61
- apply_rules(RULES_FOR_ITEM_REP, obj)
62
- when Nanoc::Core::Item
63
- apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
64
- when Nanoc::Core::Layout
65
- apply_rules(RULES_FOR_LAYOUT, obj)
66
- when Nanoc::Core::Configuration
67
- apply_rules(RULES_FOR_CONFIG, obj)
68
- when Nanoc::Core::ItemCollection
69
- apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
70
- when Nanoc::Core::LayoutCollection
71
- apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
72
- else
73
- raise Nanoc::Int::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
74
- end
75
- end
76
-
77
- private
78
-
79
- contract C::ArrayOf[Class], C_OBJ_MAYBE_REP, Nanoc::Core::OutdatednessStatus => C::Maybe[Nanoc::Core::OutdatednessStatus]
80
- def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
81
- rules.inject(status) do |acc, rule|
82
- if !acc.useful_to_apply?(rule)
83
- acc
84
- else
85
- reason = rule.instance.call(obj, @outdatedness_checker)
86
- if reason
87
- acc.update(reason)
88
- else
89
- acc
90
- end
91
- end
92
- end
93
- end
94
-
95
- contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] => C::Maybe[Nanoc::Core::OutdatednessStatus]
96
- def apply_rules_multi(rules, objs)
97
- objs.inject(Nanoc::Core::OutdatednessStatus.new) { |acc, elem| apply_rules(rules, elem, acc) }
98
- end
99
- end
100
-
101
- DDMemoize.activate(self)
102
-
103
- include Nanoc::Core::ContractsSupport
104
-
105
- attr_reader :checksum_store
106
- attr_reader :checksums
107
- attr_reader :dependency_store
108
- attr_reader :action_sequence_store
109
- attr_reader :action_sequences
110
- attr_reader :site
111
-
112
- Reasons = Nanoc::Core::OutdatednessReasons
113
-
114
- C_OBJ = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep, Nanoc::Core::Configuration, Nanoc::Core::Layout, Nanoc::Core::ItemCollection]
115
- C_ITEM_OR_REP = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep]
116
- C_ACTION_SEQUENCES = C::HashOf[C_OBJ => Nanoc::Core::ActionSequence]
117
-
118
- contract C::KeywordArgs[site: Nanoc::Core::Site, checksum_store: Nanoc::Core::ChecksumStore, checksums: Nanoc::Core::ChecksumCollection, dependency_store: Nanoc::Core::DependencyStore, action_sequence_store: Nanoc::Core::ActionSequenceStore, action_sequences: C_ACTION_SEQUENCES, reps: Nanoc::Core::ItemRepRepo] => C::Any
119
- def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
120
- @site = site
121
- @checksum_store = checksum_store
122
- @checksums = checksums
123
- @dependency_store = dependency_store
124
- @action_sequence_store = action_sequence_store
125
- @action_sequences = action_sequences
126
- @reps = reps
127
-
128
- @objects_outdated_due_to_dependencies = {}
129
- end
130
-
131
- def action_sequence_for(rep)
132
- @action_sequences.fetch(rep)
133
- end
134
-
135
- contract C_OBJ => C::Bool
136
- def outdated?(obj)
137
- outdatedness_reasons_for(obj).any?
138
- end
139
-
140
- contract C_OBJ => C::IterOf[Reasons::Generic]
141
- def outdatedness_reasons_for(obj)
142
- reasons = basic.outdatedness_status_for(obj).reasons
143
- if reasons.any?
144
- reasons
145
- elsif outdated_due_to_dependencies?(obj)
146
- [Reasons::DependenciesOutdated]
147
- else
148
- []
149
- end
150
- end
151
-
152
- private
153
-
154
- contract C::None => Basic
155
- def basic
156
- @_basic ||= Basic.new(outdatedness_checker: self, reps: @reps)
157
- end
158
-
159
- contract C_OBJ, Hamster::Set => C::Bool
160
- def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
161
- # Convert from rep to item if necessary
162
- obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
163
-
164
- # Only items can have dependencies
165
- return false unless obj.is_a?(Nanoc::Core::Item)
166
-
167
- # Get from cache
168
- if @objects_outdated_due_to_dependencies.key?(obj)
169
- return @objects_outdated_due_to_dependencies[obj]
170
- end
171
-
172
- # Check processed
173
- # Don’t return true; the false will be or’ed into a true if there
174
- # really is a dependency that is causing outdatedness.
175
- return false if processed.include?(obj)
176
-
177
- # Calculate
178
- is_outdated = dependency_store.dependencies_causing_outdatedness_of(obj).any? do |dep|
179
- dependency_causes_outdatedness?(dep) ||
180
- (dep.props.compiled_content? &&
181
- outdated_due_to_dependencies?(dep.from, processed.merge([obj])))
182
- end
183
-
184
- # Cache
185
- @objects_outdated_due_to_dependencies[obj] = is_outdated
186
-
187
- # Done
188
- is_outdated
189
- end
190
-
191
- contract Nanoc::Core::Dependency => C::Bool
192
- def dependency_causes_outdatedness?(dependency)
193
- return true if dependency.from.nil?
194
-
195
- status = basic.outdatedness_status_for(dependency.from)
196
-
197
- active = status.props.active & dependency.props.active
198
- active.delete(:attributes) if attributes_unaffected?(status, dependency)
199
- active.delete(:raw_content) if raw_content_unaffected?(status, dependency)
200
-
201
- active.any?
202
- end
203
-
204
- def attributes_unaffected?(status, dependency)
205
- reason = status.reasons.find { |r| r.is_a?(Nanoc::Core::OutdatednessReasons::AttributesModified) }
206
- reason && dependency.props.attributes.is_a?(Enumerable) && (dependency.props.attributes & reason.attributes).empty?
207
- end
208
-
209
- def raw_content_unaffected?(status, dependency)
210
- reason = status.reasons.find { |r| r.is_a?(Nanoc::Core::OutdatednessReasons::DocumentCollectionExtended) }
211
- if reason.nil?
212
- false
213
- elsif !dependency.props.raw_content.is_a?(Enumerable)
214
- false
215
- else
216
- patterns = dependency.props.raw_content.map { |r| Nanoc::Core::Pattern.from(r) }
217
- patterns.none? { |pat| reason.objects.any? { |obj| pat.match?(obj.identifier) } }
218
- end
219
- end
220
- end
221
- end
222
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- # @api private
6
- module OutdatednessRules
7
- end
8
- end
9
- end
10
-
11
- require_relative 'outdatedness_rules/attributes_modified'
12
- require_relative 'outdatedness_rules/code_snippets_modified'
13
- require_relative 'outdatedness_rules/content_modified'
14
- require_relative 'outdatedness_rules/not_written'
15
- require_relative 'outdatedness_rules/rules_modified'
16
- require_relative 'outdatedness_rules/uses_always_outdated_filter'
17
- require_relative 'outdatedness_rules/item_collection_extended'
18
- require_relative 'outdatedness_rules/layout_collection_extended'
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class AttributesModified < Nanoc::Core::OutdatednessRule
7
- include Nanoc::Core::ContractsSupport
8
-
9
- affects_props :attributes, :compiled_content
10
-
11
- contract C::Or[Nanoc::Core::ItemRep, Nanoc::Core::Item, Nanoc::Core::Configuration, Nanoc::Core::Layout], C::Named['Nanoc::Int::OutdatednessChecker'] => C::Maybe[Nanoc::Core::OutdatednessReasons::Generic]
12
- def apply(obj, outdatedness_checker)
13
- case obj
14
- when Nanoc::Core::ItemRep
15
- apply(obj.item, outdatedness_checker)
16
- when Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration
17
- if outdatedness_checker.checksum_store[obj] == outdatedness_checker.checksums.checksum_for(obj)
18
- return nil
19
- end
20
-
21
- old_checksums = outdatedness_checker.checksum_store.attributes_checksum_for(obj)
22
- unless old_checksums
23
- return Nanoc::Core::OutdatednessReasons::AttributesModified.new(true)
24
- end
25
-
26
- new_checksums = outdatedness_checker.checksums.attributes_checksum_for(obj)
27
-
28
- attributes = Set.new(old_checksums.keys) + Set.new(new_checksums.keys)
29
- changed_attributes = attributes.reject { |a| old_checksums[a] == new_checksums[a] }
30
-
31
- if changed_attributes.any?
32
- Nanoc::Core::OutdatednessReasons::AttributesModified.new(changed_attributes)
33
- end
34
- else
35
- raise ArgumentError
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- module OutdatednessRules
6
- class CodeSnippetsModified < Nanoc::Core::OutdatednessRule
7
- DDMemoize.activate(self)
8
-
9
- include Nanoc::Core::ContractsSupport
10
-
11
- affects_props :raw_content, :attributes, :compiled_content, :path
12
-
13
- def apply(_obj, outdatedness_checker)
14
- if any_snippets_modified?(outdatedness_checker)
15
- Nanoc::Core::OutdatednessReasons::CodeSnippetsModified
16
- end
17
- end
18
-
19
- private
20
-
21
- memoized def any_snippets_modified?(outdatedness_checker)
22
- outdatedness_checker.site.code_snippets.any? do |cs|
23
- ch_old = outdatedness_checker.checksum_store[cs]
24
- ch_new = outdatedness_checker.checksums.checksum_for(cs)
25
- ch_old != ch_new
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end