nanoc 4.7.4 → 4.7.5

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +19 -29
  4. data/NEWS.md +11 -0
  5. data/lib/nanoc/base/entities/identifiable_collection.rb +21 -0
  6. data/lib/nanoc/base/services/compilation_context.rb +54 -0
  7. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +27 -0
  8. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +4 -6
  9. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +14 -0
  10. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +22 -0
  11. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -0
  12. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +14 -0
  13. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +33 -0
  14. data/lib/nanoc/base/services/compiler/stages.rb +6 -0
  15. data/lib/nanoc/base/services/compiler.rb +85 -142
  16. data/lib/nanoc/base/services/compiler_loader.rb +0 -11
  17. data/lib/nanoc/base/services/outdatedness_checker.rb +19 -40
  18. data/lib/nanoc/base/services.rb +1 -0
  19. data/lib/nanoc/base/views/identifiable_collection_view.rb +1 -2
  20. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +2 -2
  21. data/lib/nanoc/cli/commands/show-data.rb +14 -12
  22. data/lib/nanoc/version.rb +1 -1
  23. data/spec/nanoc/base/compiler_spec.rb +0 -5
  24. data/spec/nanoc/base/entities/identifiable_collection_spec.rb +34 -0
  25. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +1 -1
  26. data/spec/nanoc/base/services/executor_spec.rb +1 -1
  27. data/spec/nanoc/base/services/outdatedness_checker_spec.rb +21 -8
  28. data/spec/nanoc/base/services/outdatedness_rules_spec.rb +6 -9
  29. data/spec/nanoc/cli/commands/show_data_spec.rb +147 -0
  30. data/spec/nanoc/integration/outdatedness_integration_spec.rb +14 -14
  31. data/spec/nanoc/integration/partial_recompilation_spec.rb +4 -4
  32. data/spec/nanoc/regressions/gh_1145_spec.rb +16 -0
  33. data/spec/nanoc/regressions/gh_970b_spec.rb +3 -3
  34. data/spec/spec_helper.rb +1 -1
  35. metadata +10 -3
  36. data/test/base/test_outdatedness_checker.rb +0 -491
@@ -1,77 +1,5 @@
1
1
  module Nanoc::Int
2
- # Responsible for compiling a site’s item representations.
3
- #
4
- # The compilation process makes use of notifications (see
5
- # {Nanoc::Int::NotificationCenter}) to track dependencies between items,
6
- # layouts, etc. The following notifications are used:
7
- #
8
- # * `compilation_started` — indicates that the compiler has started
9
- # compiling this item representation. Has one argument: the item
10
- # representation itself. Only one item can be compiled at a given moment;
11
- # therefore, it is not possible to get two consecutive
12
- # `compilation_started` notifications without also getting a
13
- # `compilation_ended` notification in between them.
14
- #
15
- # * `compilation_ended` — indicates that the compiler has finished compiling
16
- # this item representation (either successfully or with failure). Has one
17
- # argument: the item representation itself.
18
- #
19
- # @api private
20
2
  class Compiler
21
- # Provides common functionality for accesing “context” of an item that is being compiled.
22
- class CompilationContext
23
- attr_reader :site
24
- attr_reader :compiled_content_cache
25
- attr_reader :snapshot_repo
26
-
27
- def initialize(action_provider:, reps:, site:, compiled_content_cache:, snapshot_repo:)
28
- @action_provider = action_provider
29
- @reps = reps
30
- @site = site
31
- @compiled_content_cache = compiled_content_cache
32
- @snapshot_repo = snapshot_repo
33
- end
34
-
35
- def filter_name_and_args_for_layout(layout)
36
- mem = @action_provider.action_sequence_for(layout)
37
- if mem.nil? || mem.size != 1 || !mem[0].is_a?(Nanoc::Int::ProcessingActions::Filter)
38
- raise Nanoc::Int::Errors::UndefinedFilterForLayout.new(layout)
39
- end
40
- [mem[0].filter_name, mem[0].params]
41
- end
42
-
43
- def create_view_context(dependency_tracker)
44
- Nanoc::ViewContext.new(
45
- reps: @reps,
46
- items: @site.items,
47
- dependency_tracker: dependency_tracker,
48
- compilation_context: self,
49
- snapshot_repo: @snapshot_repo,
50
- )
51
- end
52
-
53
- def assigns_for(rep, dependency_tracker)
54
- last_content = @snapshot_repo.get(rep, :last)
55
- content_or_filename_assigns =
56
- if last_content.binary?
57
- { filename: last_content.filename }
58
- else
59
- { content: last_content.string }
60
- end
61
-
62
- view_context = create_view_context(dependency_tracker)
63
-
64
- content_or_filename_assigns.merge(
65
- item: Nanoc::ItemWithRepsView.new(rep.item, view_context),
66
- rep: Nanoc::ItemRepView.new(rep, view_context),
67
- item_rep: Nanoc::ItemRepView.new(rep, view_context),
68
- items: Nanoc::ItemCollectionWithRepsView.new(@site.items, view_context),
69
- layouts: Nanoc::LayoutCollectionView.new(@site.layouts, view_context),
70
- config: Nanoc::ConfigView.new(@site.config, view_context),
71
- )
72
- end
73
- end
74
-
75
3
  include Nanoc::Int::ContractsSupport
76
4
 
77
5
  # @api private
@@ -92,9 +20,6 @@ module Nanoc::Int
92
20
  # @api private
93
21
  attr_reader :dependency_store
94
22
 
95
- # @api private
96
- attr_reader :outdatedness_checker
97
-
98
23
  # @api private
99
24
  attr_reader :reps
100
25
 
@@ -104,14 +29,13 @@ module Nanoc::Int
104
29
  # @api private
105
30
  attr_reader :snapshot_repo
106
31
 
107
- def initialize(site, compiled_content_cache:, checksum_store:, action_sequence_store:, action_provider:, dependency_store:, outdatedness_checker:, reps:, outdatedness_store:)
32
+ def initialize(site, compiled_content_cache:, checksum_store:, action_sequence_store:, action_provider:, dependency_store:, reps:, outdatedness_store:)
108
33
  @site = site
109
34
 
110
35
  @compiled_content_cache = compiled_content_cache
111
36
  @checksum_store = checksum_store
112
37
  @action_sequence_store = action_sequence_store
113
38
  @dependency_store = dependency_store
114
- @outdatedness_checker = outdatedness_checker
115
39
  @reps = reps
116
40
  @action_provider = action_provider
117
41
  @outdatedness_store = outdatedness_store
@@ -120,55 +44,34 @@ module Nanoc::Int
120
44
  @snapshot_repo = Nanoc::Int::SnapshotRepo.new
121
45
  end
122
46
 
123
- def run_all
124
- time_stage(:preprocess) { preprocess_stage.run }
125
- time_stage(:build_reps) { build_reps }
126
- time_stage(:prune) { prune_stage.run }
127
- time_stage(:load_stores) { load_stores }
128
- time_stage(:determine_outdatedness) { determine_outdatedness }
129
- time_stage(:forget_dependencies_if_needed) { forget_dependencies_if_needed }
130
- time_stage(:store) { store }
131
- time_stage(:compile_reps) { compile_reps_stage.run }
132
- time_stage(:store_output_state) { store_output_state }
133
- time_stage(:postprocess) { @action_provider.postprocess(@site, @reps) }
134
- ensure
135
- time_stage(:cleanup) { cleanup_stage.run }
136
- end
137
-
138
- def load_stores
139
- stores.each(&:load)
140
- end
141
-
142
- # TODO: rename to store_preprocessed_state
143
- def store
144
- # Calculate action sequence
145
- (@reps.to_a + @site.layouts.to_a).each do |obj|
146
- action_sequence_store[obj] = action_provider.action_sequence_for(obj).serialize
147
- end
148
-
149
- # Calculate checksums
150
- objects_to_checksum =
151
- site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]
152
- objects_to_checksum.each { |obj| checksum_store.add(obj) }
153
-
154
- # Store
155
- checksum_store.store
156
- action_sequence_store.store
157
- end
158
-
159
- def store_output_state
160
- @dependency_store.store
47
+ def create_outdatedness_checker
48
+ Nanoc::Int::OutdatednessChecker.new(
49
+ site: @site,
50
+ checksum_store: @checksum_store,
51
+ dependency_store: @dependency_store,
52
+ action_sequence_store: @action_sequence_store,
53
+ action_sequences: @action_sequences,
54
+ reps: reps,
55
+ )
161
56
  end
162
57
 
163
- def build_reps
164
- builder = Nanoc::Int::ItemRepBuilder.new(
165
- site, action_provider, @reps
166
- )
167
- @action_sequences = builder.run
58
+ def run_all
59
+ run_stage(preprocess_stage)
60
+ @action_sequences = run_stage(build_reps_stage)
61
+ run_stage(prune_stage)
62
+ run_stage(load_stores_stage)
63
+ outdated_items = run_stage(determine_outdatedness_stage)
64
+ run_stage(forget_outdated_dependencies_stage, outdated_items)
65
+ run_stage(store_pre_compilation_state_stage)
66
+ run_stage(compile_reps_stage)
67
+ run_stage(store_post_compilation_state_stage)
68
+ run_stage(postprocess_stage)
69
+ ensure
70
+ run_stage(cleanup_stage)
168
71
  end
169
72
 
170
73
  def compilation_context
171
- @_compilation_context ||= CompilationContext.new(
74
+ @_compilation_context ||= Nanoc::Int::CompilationContext.new(
172
75
  action_provider: action_provider,
173
76
  reps: @reps,
174
77
  site: @site,
@@ -177,11 +80,22 @@ module Nanoc::Int
177
80
  )
178
81
  end
179
82
 
83
+ # TODO: remove
84
+ def load_stores
85
+ load_stores_stage.run
86
+ end
87
+
88
+ # TODO: remove
89
+ def build_reps
90
+ @action_sequences = build_reps_stage.run
91
+ end
92
+
180
93
  private
181
94
 
182
- def time_stage(name)
95
+ def run_stage(stage, *args)
96
+ name = stage.class.to_s
183
97
  Nanoc::Int::NotificationCenter.post(:stage_started, name)
184
- yield
98
+ stage.run(*args)
185
99
  ensure
186
100
  Nanoc::Int::NotificationCenter.post(:stage_ended, name)
187
101
  end
@@ -195,6 +109,14 @@ module Nanoc::Int
195
109
  )
196
110
  end
197
111
 
112
+ def build_reps_stage
113
+ @_build_reps_stage ||= Stages::BuildReps.new(
114
+ site: site,
115
+ action_provider: action_provider,
116
+ reps: @reps,
117
+ )
118
+ end
119
+
198
120
  def prune_stage
199
121
  @_prune_stage ||= Stages::Prune.new(
200
122
  config: site.config,
@@ -202,14 +124,37 @@ module Nanoc::Int
202
124
  )
203
125
  end
204
126
 
127
+ def load_stores_stage
128
+ @_load_stores_stage ||= Stages::LoadStores.new(
129
+ checksum_store: checksum_store,
130
+ compiled_content_cache: compiled_content_cache,
131
+ dependency_store: @dependency_store,
132
+ action_sequence_store: action_sequence_store,
133
+ outdatedness_store: @outdatedness_store,
134
+ )
135
+ end
136
+
205
137
  def determine_outdatedness_stage
206
138
  @_determine_outdatedness_stage ||= Stages::DetermineOutdatedness.new(
207
139
  reps: reps,
208
- outdatedness_checker: outdatedness_checker,
140
+ outdatedness_checker: create_outdatedness_checker,
209
141
  outdatedness_store: outdatedness_store,
210
142
  )
211
143
  end
212
144
 
145
+ def store_pre_compilation_state_stage
146
+ @_store_pre_compilation_state_stage ||= Stages::StorePreCompilationState.new(
147
+ reps: @reps,
148
+ layouts: site.layouts,
149
+ items: site.items,
150
+ code_snippets: site.code_snippets,
151
+ config: site.config,
152
+ checksum_store: checksum_store,
153
+ action_sequence_store: action_sequence_store,
154
+ action_sequences: @action_sequences,
155
+ )
156
+ end
157
+
213
158
  def compile_reps_stage
214
159
  @_compile_reps_stage ||= Stages::CompileReps.new(
215
160
  outdatedness_store: @outdatedness_store,
@@ -220,30 +165,28 @@ module Nanoc::Int
220
165
  )
221
166
  end
222
167
 
223
- def cleanup_stage
224
- @_cleanup_stage ||= Stages::Cleanup.new(site.config)
168
+ def store_post_compilation_state_stage
169
+ @_store_post_compilation_state_stage ||= Stages::StorePostCompilationState.new(
170
+ dependency_store: dependency_store,
171
+ )
225
172
  end
226
173
 
227
- def determine_outdatedness
228
- determine_outdatedness_stage.run(@action_sequences) do |outdated_items|
229
- @outdated_items = outdated_items
230
- end
174
+ def postprocess_stage
175
+ @_postprocess_stage ||= Stages::Postprocess.new(
176
+ action_provider: @action_provider,
177
+ site: @site,
178
+ reps: @reps,
179
+ )
231
180
  end
232
181
 
233
- def forget_dependencies_if_needed
234
- @outdated_items.each { |i| @dependency_store.forget_dependencies_for(i) }
182
+ def cleanup_stage
183
+ @_cleanup_stage ||= Stages::Cleanup.new(site.config)
235
184
  end
236
185
 
237
- # Returns all stores that can load/store data that can be used for
238
- # compilation.
239
- def stores
240
- [
241
- checksum_store,
242
- compiled_content_cache,
243
- @dependency_store,
244
- action_sequence_store,
245
- @outdatedness_store,
246
- ]
186
+ def forget_outdated_dependencies_stage
187
+ @_forget_outdated_dependencies_stage ||= Stages::ForgetOutdatedDependencies.new(
188
+ dependency_store: @dependency_store,
189
+ )
247
190
  end
248
191
  end
249
192
  end
@@ -19,16 +19,6 @@ module Nanoc::Int
19
19
  outdatedness_store =
20
20
  Nanoc::Int::OutdatednessStore.new(site: site, reps: item_rep_repo)
21
21
 
22
- outdatedness_checker =
23
- Nanoc::Int::OutdatednessChecker.new(
24
- site: site,
25
- checksum_store: checksum_store,
26
- dependency_store: dependency_store,
27
- action_sequence_store: action_sequence_store,
28
- action_provider: action_provider,
29
- reps: item_rep_repo,
30
- )
31
-
32
22
  compiled_content_cache =
33
23
  Nanoc::Int::CompiledContentCache.new(
34
24
  site: site,
@@ -40,7 +30,6 @@ module Nanoc::Int
40
30
  checksum_store: checksum_store,
41
31
  action_sequence_store: action_sequence_store,
42
32
  dependency_store: dependency_store,
43
- outdatedness_checker: outdatedness_checker,
44
33
  reps: item_rep_repo,
45
34
  action_provider: action_provider,
46
35
  outdatedness_store: outdatedness_store,
@@ -82,61 +82,46 @@ module Nanoc::Int
82
82
  attr_reader :checksum_store
83
83
  attr_reader :dependency_store
84
84
  attr_reader :action_sequence_store
85
- attr_reader :action_provider
85
+ attr_reader :action_sequences
86
86
  attr_reader :site
87
87
 
88
88
  Reasons = Nanoc::Int::OutdatednessReasons
89
89
 
90
90
  C_OBJ = C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout]
91
+ C_ACTION_SEQUENCES = C::HashOf[C_OBJ => Nanoc::Int::ActionSequence]
91
92
 
92
- # FIXME: Replace C::Any with proper types
93
- contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, dependency_store: Nanoc::Int::DependencyStore, action_sequence_store: Nanoc::Int::ActionSequenceStore, action_provider: C::Any, reps: Nanoc::Int::ItemRepRepo] => C::Any
94
- def initialize(site:, checksum_store:, dependency_store:, action_sequence_store:, action_provider:, reps:)
93
+ contract C::KeywordArgs[site: Nanoc::Int::Site, checksum_store: Nanoc::Int::ChecksumStore, dependency_store: Nanoc::Int::DependencyStore, action_sequence_store: Nanoc::Int::ActionSequenceStore, action_sequences: C_ACTION_SEQUENCES, reps: Nanoc::Int::ItemRepRepo] => C::Any
94
+ def initialize(site:, checksum_store:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
95
95
  @site = site
96
96
  @checksum_store = checksum_store
97
97
  @dependency_store = dependency_store
98
98
  @action_sequence_store = action_sequence_store
99
- @action_provider = action_provider
99
+ @action_sequences = action_sequences
100
100
  @reps = reps
101
101
 
102
102
  @objects_outdated_due_to_dependencies = {}
103
103
  end
104
104
 
105
105
  def action_sequence_for(rep)
106
- # TODO: Pass in action_sequences instead
107
- @action_provider.action_sequence_for(rep)
106
+ @action_sequences.fetch(rep)
108
107
  end
109
- memoize :action_sequence_for
110
-
111
- contract C_OBJ, C::Maybe[C::HashOf[C_OBJ => Nanoc::Int::ActionSequence]] => C::Bool
112
- # Checks whether the given object is outdated and therefore needs to be
113
- # recompiled.
114
- #
115
- # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
116
- # whose outdatedness should be checked.
117
- #
118
- # @return [Boolean] true if the object is outdated, false otherwise
119
- def outdated?(obj, _action_sequences = nil)
120
- # TODO: use action_sequences
121
- !outdatedness_reason_for(obj).nil?
108
+
109
+ contract C_OBJ => C::Bool
110
+ def outdated?(obj)
111
+ outdatedness_reasons_for(obj).any?
122
112
  end
123
113
 
124
- contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Maybe[Reasons::Generic]
125
- # Calculates the reason why the given object is outdated.
126
- #
127
- # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
128
- # whose outdatedness reason should be calculated.
129
- #
130
- # @return [Reasons::Generic, nil] The reason why the
131
- # given object is outdated, or nil if the object is not outdated.
132
- def outdatedness_reason_for(obj)
133
- reason = basic_outdatedness_reason_for(obj)
134
- if reason.nil? && outdated_due_to_dependencies?(obj)
135
- reason = Reasons::DependenciesOutdated
114
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::IterOf[Reasons::Generic]
115
+ def outdatedness_reasons_for(obj)
116
+ reasons = basic.outdatedness_status_for(obj).reasons
117
+ if reasons.any?
118
+ reasons
119
+ elsif outdated_due_to_dependencies?(obj)
120
+ [Reasons::DependenciesOutdated]
121
+ else
122
+ []
136
123
  end
137
- reason
138
124
  end
139
- memoize :outdatedness_reason_for
140
125
 
141
126
  private
142
127
 
@@ -145,12 +130,6 @@ module Nanoc::Int
145
130
  @_basic ||= Basic.new(outdatedness_checker: self, reps: @reps)
146
131
  end
147
132
 
148
- contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Maybe[Reasons::Generic]
149
- def basic_outdatedness_reason_for(obj)
150
- # FIXME: Stop using this; it is no longer accurate, as there can be >1 reasons
151
- basic.outdatedness_status_for(obj).reasons.first
152
- end
153
-
154
133
  contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout], Hamster::Set => C::Bool
155
134
  def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
156
135
  # Convert from rep to item if necessary
@@ -1,5 +1,6 @@
1
1
  require_relative 'services/action_provider'
2
2
  require_relative 'services/checksummer'
3
+ require_relative 'services/compilation_context'
3
4
  require_relative 'services/compiler'
4
5
  require_relative 'services/compiler_loader'
5
6
  require_relative 'services/dependency_tracker'
@@ -43,8 +43,7 @@ module Nanoc
43
43
  #
44
44
  # @return [Enumerable]
45
45
  def find_all(arg)
46
- pat = Nanoc::Int::Pattern.from(arg)
47
- select { |i| pat.match?(i.identifier) }
46
+ @objects.find_all(arg).map { |i| view_class.new(i, @context) }
48
47
  end
49
48
 
50
49
  # @overload [](string)
@@ -3,8 +3,8 @@ module Nanoc::CLI::Commands::CompileListeners
3
3
  attr_reader :telemetry
4
4
 
5
5
  # @see Listener#enable_for?
6
- def self.enable_for?(command_runner)
7
- command_runner.options.fetch(:verbose, false)
6
+ def self.enable_for?(_command_runner)
7
+ Nanoc::CLI.verbosity >= 1
8
8
  end
9
9
 
10
10
  # @param [Enumerable<Nanoc::Int::ItemRep>] reps
@@ -129,12 +129,7 @@ module Nanoc::CLI::Commands
129
129
  sorted_reps_with_prev(items) do |rep, prev|
130
130
  puts if prev
131
131
  puts "item #{rep.item.identifier}, rep #{rep.name}:"
132
- outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(rep)
133
- if outdatedness_reason
134
- puts " is outdated: #{outdatedness_reason.message}"
135
- else
136
- puts ' is not outdated'
137
- end
132
+ print_outdatedness_reasons_for(rep, compiler)
138
133
  end
139
134
  end
140
135
 
@@ -144,13 +139,20 @@ module Nanoc::CLI::Commands
144
139
  sorted_with_prev(layouts) do |layout, prev|
145
140
  puts if prev
146
141
  puts "layout #{layout.identifier}:"
147
- outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(layout)
148
- if outdatedness_reason
149
- puts " is outdated: #{outdatedness_reason.message}"
150
- else
151
- puts ' is not outdated'
142
+ print_outdatedness_reasons_for(layout, compiler)
143
+ end
144
+ end
145
+
146
+ def print_outdatedness_reasons_for(obj, compiler)
147
+ outdatedness_checker = compiler.create_outdatedness_checker
148
+ reasons = outdatedness_checker.outdatedness_reasons_for(obj)
149
+ if reasons.any?
150
+ puts ' is outdated:'
151
+ reasons.each do |reason|
152
+ puts " - #{reason.message}"
152
153
  end
153
- puts
154
+ else
155
+ puts ' is not outdated'
154
156
  end
155
157
  end
156
158
  end
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.7.4'.freeze
3
+ VERSION = '4.7.5'.freeze
4
4
  end
@@ -7,7 +7,6 @@ describe Nanoc::Int::Compiler do
7
7
  action_sequence_store: action_sequence_store,
8
8
  action_provider: action_provider,
9
9
  dependency_store: dependency_store,
10
- outdatedness_checker: outdatedness_checker,
11
10
  reps: reps,
12
11
  outdatedness_store: outdatedness_store,
13
12
  )
@@ -19,7 +18,6 @@ describe Nanoc::Int::Compiler do
19
18
  let(:dependency_store) { Nanoc::Int::DependencyStore.new(items.to_a) }
20
19
  let(:reps) { Nanoc::Int::ItemRepRepo.new }
21
20
 
22
- let(:outdatedness_checker) { double(:outdatedness_checker) }
23
21
  let(:outdatedness_store) { Nanoc::Int::OutdatednessStore.new(site: site, reps: reps) }
24
22
  let(:action_provider) { double(:action_provider) }
25
23
 
@@ -65,9 +63,6 @@ describe Nanoc::Int::Compiler do
65
63
  rep.snapshot_defs << Nanoc::Int::SnapshotDef.new(:last, binary: false)
66
64
  end
67
65
 
68
- allow(outdatedness_checker).to receive(:outdated?).with(rep).and_return(true)
69
- allow(outdatedness_checker).to receive(:outdated?).with(other_rep).and_return(true)
70
-
71
66
  # FIXME: eww
72
67
  action_sequences = { rep => memory, other_rep => memory }
73
68
  compiler.instance_variable_set(:@action_sequences, action_sequences)
@@ -9,4 +9,38 @@ describe Nanoc::Int::IdentifiableCollection do
9
9
 
10
10
  it { is_expected.to be_a(described_class) }
11
11
  end
12
+
13
+ describe '#find_all' do
14
+ let(:objects) do
15
+ [
16
+ double(:identifiable, identifier: Nanoc::Identifier.new('/about.css')),
17
+ double(:identifiable, identifier: Nanoc::Identifier.new('/about.md')),
18
+ double(:identifiable, identifier: Nanoc::Identifier.new('/style.css')),
19
+ ]
20
+ end
21
+
22
+ let(:arg) { raise 'override me' }
23
+
24
+ subject { identifiable_collection.find_all(arg) }
25
+
26
+ context 'with string' do
27
+ let(:arg) { '/*.css' }
28
+
29
+ it 'contains objects' do
30
+ expect(subject.size).to eql(2)
31
+ expect(subject.find { |iv| iv.identifier == '/about.css' }).to eq(objects[0])
32
+ expect(subject.find { |iv| iv.identifier == '/style.css' }).to eq(objects[2])
33
+ end
34
+ end
35
+
36
+ context 'with regex' do
37
+ let(:arg) { %r{\.css\z} }
38
+
39
+ it 'contains objects' do
40
+ expect(subject.size).to eql(2)
41
+ expect(subject.find { |iv| iv.identifier == '/about.css' }).to eq(objects[0])
42
+ expect(subject.find { |iv| iv.identifier == '/style.css' }).to eq(objects[2])
43
+ end
44
+ end
45
+ end
12
46
  end
@@ -10,7 +10,7 @@ describe Nanoc::Int::Compiler::Stages::CompileReps do
10
10
  end
11
11
 
12
12
  let(:compilation_context) do
13
- Nanoc::Int::Compiler::CompilationContext.new(
13
+ Nanoc::Int::CompilationContext.new(
14
14
  action_provider: action_provider,
15
15
  reps: reps,
16
16
  site: site,
@@ -2,7 +2,7 @@ describe Nanoc::Int::Executor do
2
2
  let(:executor) { described_class.new(rep, compilation_context, dependency_tracker) }
3
3
 
4
4
  let(:compilation_context) do
5
- Nanoc::Int::Compiler::CompilationContext.new(
5
+ Nanoc::Int::CompilationContext.new(
6
6
  action_provider: action_provider,
7
7
  reps: reps,
8
8
  site: site,
@@ -5,7 +5,7 @@ describe Nanoc::Int::OutdatednessChecker do
5
5
  checksum_store: checksum_store,
6
6
  dependency_store: dependency_store,
7
7
  action_sequence_store: action_sequence_store,
8
- action_provider: action_provider,
8
+ action_sequences: action_sequences,
9
9
  reps: reps,
10
10
  )
11
11
  end
@@ -38,7 +38,9 @@ describe Nanoc::Int::OutdatednessChecker do
38
38
 
39
39
  let(:new_action_sequence_for_item_rep) { old_action_sequence_for_item_rep }
40
40
 
41
- let(:action_provider) { double(:action_provider) }
41
+ let(:action_sequences) do
42
+ { item_rep => new_action_sequence_for_item_rep }
43
+ end
42
44
 
43
45
  let(:reps) do
44
46
  Nanoc::Int::ItemRepRepo.new
@@ -52,12 +54,10 @@ describe Nanoc::Int::OutdatednessChecker do
52
54
  before do
53
55
  reps << item_rep
54
56
  action_sequence_store[item_rep] = old_action_sequence_for_item_rep.serialize
55
-
56
- allow(action_provider).to receive(:action_sequence_for).with(item_rep).and_return(new_action_sequence_for_item_rep)
57
57
  end
58
58
 
59
- describe '#basic_outdatedness_reason_for' do
60
- subject { outdatedness_checker.send(:basic_outdatedness_reason_for, obj) }
59
+ describe 'basic outdatedness reasons' do
60
+ subject { outdatedness_checker.send(:basic).outdatedness_status_for(obj).reasons.first }
61
61
 
62
62
  let(:checksum_store) { Nanoc::Int::ChecksumStore.new(objects: objects) }
63
63
 
@@ -131,6 +131,13 @@ describe Nanoc::Int::OutdatednessChecker do
131
131
 
132
132
  let(:new_action_sequence_for_other_item_rep) { old_action_sequence_for_other_item_rep }
133
133
 
134
+ let(:action_sequences) do
135
+ {
136
+ item_rep => new_action_sequence_for_item_rep,
137
+ other_item_rep => new_action_sequence_for_other_item_rep,
138
+ }
139
+ end
140
+
134
141
  before do
135
142
  reps << other_item_rep
136
143
  action_sequence_store[other_item_rep] = old_action_sequence_for_other_item_rep.serialize
@@ -138,7 +145,6 @@ describe Nanoc::Int::OutdatednessChecker do
138
145
  checksum_store.add(other_item)
139
146
  checksum_store.add(config)
140
147
 
141
- allow(action_provider).to receive(:action_sequence_for).with(other_item_rep).and_return(new_action_sequence_for_other_item_rep)
142
148
  allow(site).to receive(:code_snippets).and_return([])
143
149
  allow(site).to receive(:config).and_return(config)
144
150
  end
@@ -147,11 +153,18 @@ describe Nanoc::Int::OutdatednessChecker do
147
153
  let(:distant_item) { Nanoc::Int::Item.new('distant stuff', {}, '/distant.md') }
148
154
  let(:distant_item_rep) { Nanoc::Int::ItemRep.new(distant_item, :default) }
149
155
 
156
+ let(:action_sequences) do
157
+ {
158
+ item_rep => new_action_sequence_for_item_rep,
159
+ other_item_rep => new_action_sequence_for_other_item_rep,
160
+ distant_item_rep => new_action_sequence_for_other_item_rep,
161
+ }
162
+ end
163
+
150
164
  before do
151
165
  reps << distant_item_rep
152
166
  checksum_store.add(distant_item)
153
167
  action_sequence_store[distant_item_rep] = old_action_sequence_for_other_item_rep.serialize
154
- allow(action_provider).to receive(:action_sequence_for).with(distant_item_rep).and_return(new_action_sequence_for_other_item_rep)
155
168
  end
156
169
 
157
170
  context 'on attribute + attribute' do