nanoc 4.3.8 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/NEWS.md +6 -0
  4. data/lib/nanoc/base.rb +4 -16
  5. data/lib/nanoc/base/compilation/compiler.rb +6 -8
  6. data/lib/nanoc/base/compilation/outdatedness_checker.rb +30 -4
  7. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +6 -2
  8. data/lib/nanoc/base/entities.rb +5 -2
  9. data/lib/nanoc/base/entities/code_snippet.rb +2 -0
  10. data/lib/nanoc/base/{context.rb → entities/context.rb} +2 -0
  11. data/lib/nanoc/base/{directed_graph.rb → entities/directed_graph.rb} +0 -0
  12. data/lib/nanoc/base/entities/document.rb +21 -4
  13. data/lib/nanoc/base/entities/{rule_memory_action.rb → processing_action.rb} +3 -3
  14. data/lib/nanoc/base/entities/processing_actions.rb +3 -0
  15. data/lib/nanoc/base/entities/{rule_memory_actions → processing_actions}/filter.rb +2 -2
  16. data/lib/nanoc/base/entities/{rule_memory_actions → processing_actions}/layout.rb +2 -2
  17. data/lib/nanoc/base/entities/{rule_memory_actions → processing_actions}/snapshot.rb +2 -2
  18. data/lib/nanoc/base/entities/rule_memory.rb +8 -8
  19. data/lib/nanoc/base/feature.rb +1 -2
  20. data/lib/nanoc/base/repos.rb +1 -0
  21. data/lib/nanoc/base/repos/checksum_store.rb +21 -7
  22. data/lib/nanoc/base/repos/config_loader.rb +1 -5
  23. data/lib/nanoc/base/repos/data_source.rb +14 -6
  24. data/lib/nanoc/base/{compilation → repos}/item_rep_repo.rb +0 -0
  25. data/lib/nanoc/base/services.rb +3 -0
  26. data/lib/nanoc/base/{checksummer.rb → services/checksummer.rb} +20 -4
  27. data/lib/nanoc/base/{compilation → services}/dependency_tracker.rb +9 -4
  28. data/lib/nanoc/base/{compilation → services}/filter.rb +0 -0
  29. data/lib/nanoc/cli/cleaning_stream.rb +2 -0
  30. data/lib/nanoc/cli/commands/nanoc.rb +2 -4
  31. data/lib/nanoc/cli/commands/view.rb +3 -1
  32. data/lib/nanoc/data_sources/filesystem.rb +15 -6
  33. data/lib/nanoc/extra.rb +3 -0
  34. data/lib/nanoc/version.rb +1 -1
  35. data/test/base/test_context.rb +1 -1
  36. data/test/base/test_data_source.rb +22 -0
  37. data/test/base/test_dependency_tracker.rb +53 -29
  38. data/test/base/test_directed_graph.rb +1 -1
  39. data/test/base/test_outdatedness_checker.rb +30 -3
  40. metadata +13 -13
  41. data/lib/nanoc/base/entities/rule_memory_actions.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8471fc905ae1f77b95c08da9253b6f4dcf20c85c
4
- data.tar.gz: a944c679e283c221ec1c3f67270ceee7805f472a
3
+ metadata.gz: 25161ec9b45e6f1a49b7eb87b64eeff9a6640b8f
4
+ data.tar.gz: d4b23a01bbdfc6846fbcf5b1c128c0fcba5b06b3
5
5
  SHA512:
6
- metadata.gz: 6e5e7d17725da1b15847d97fdead9b4f734c9b0865060124a84e8c8a5e0a832267ebe4575a781daa959657b36cf55b81b2e0b6a49f9e3afd8ba77d0438d4c1af
7
- data.tar.gz: 648f66ee103dcf20b6b91f974528b4ce17cdc3f7c2c64de3df45e6377d306e3724f3874689e5706edf515022ec89caa8862901a1373d8b61c2a7bb71696492c0
6
+ metadata.gz: fd3b4caa69b4e48ae48bfb35f2553a1ff6e88eb722a7056f268aa7138984b7e6114f6cfa40328bd41bf8803b8788fb27a491b5195e00b9bd09876d9af05a6c65
7
+ data.tar.gz: 868162e517d1711878df3d9027617e55b96be2040e36c14497fcea3a8f8f057c4e69ab7aac0b1947a5c513a002e0d378cd612ad263842b5d53986d95e2be91eb
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- nanoc (4.3.8)
12
+ nanoc (4.4.0)
13
13
  cri (~> 2.3)
14
14
  hamster (~> 3.0)
15
15
  parallel (~> 1.9)
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.4.0 (2015-11-19)
4
+
5
+ Features:
6
+
7
+ * Added support for Nanoc environments (#859)
8
+
3
9
  ## 4.3.8 (2016-11-18)
4
10
 
5
11
  Enhancements:
data/lib/nanoc/base.rb CHANGED
@@ -1,28 +1,16 @@
1
- module Nanoc
2
- autoload 'Error', 'nanoc/base/error'
3
- autoload 'Filter', 'nanoc/base/compilation/filter'
4
- end
5
-
6
1
  # @api private
7
2
  module Nanoc::Int
8
- # Load helper classes
9
- autoload 'Context', 'nanoc/base/context'
10
- autoload 'Checksummer', 'nanoc/base/checksummer'
11
- autoload 'DirectedGraph', 'nanoc/base/directed_graph'
12
- autoload 'Errors', 'nanoc/base/errors'
13
- autoload 'Memoization', 'nanoc/base/memoization'
14
- autoload 'PluginRegistry', 'nanoc/base/plugin_registry'
15
-
16
- # Load compilation classes
17
3
  autoload 'Compiler', 'nanoc/base/compilation/compiler'
18
- autoload 'DependencyTracker', 'nanoc/base/compilation/dependency_tracker'
19
- autoload 'ItemRepRepo', 'nanoc/base/compilation/item_rep_repo'
20
4
  autoload 'OutdatednessChecker', 'nanoc/base/compilation/outdatedness_checker'
21
5
  autoload 'OutdatednessReasons', 'nanoc/base/compilation/outdatedness_reasons'
22
6
  end
23
7
 
24
8
  require_relative 'base/core_ext'
25
9
  require_relative 'base/contracts_support'
10
+ require_relative 'base/memoization'
11
+ require_relative 'base/plugin_registry'
12
+ require_relative 'base/error'
13
+ require_relative 'base/errors'
26
14
 
27
15
  require_relative 'base/entities'
28
16
  require_relative 'base/feature'
@@ -118,9 +118,7 @@ module Nanoc::Int
118
118
  # Calculate checksums
119
119
  objects_to_checksum =
120
120
  site.items.to_a + site.layouts.to_a + site.code_snippets + [site.config]
121
- objects_to_checksum.each do |obj|
122
- checksum_store[obj] = Nanoc::Int::Checksummer.calc(obj)
123
- end
121
+ objects_to_checksum.each { |obj| checksum_store.add(obj) }
124
122
 
125
123
  # Store
126
124
  stores.each(&:store)
@@ -172,7 +170,7 @@ module Nanoc::Int
172
170
  # @api private
173
171
  def filter_name_and_args_for_layout(layout)
174
172
  mem = action_provider.memory_for(layout)
175
- if mem.nil? || mem.size != 1 || !mem[0].is_a?(Nanoc::Int::RuleMemoryActions::Filter)
173
+ if mem.nil? || mem.size != 1 || !mem[0].is_a?(Nanoc::Int::ProcessingActions::Filter)
176
174
  # FIXME: Provide a nicer error message
177
175
  raise Nanoc::Int::Errors::Generic, "No rule memory found for #{layout.identifier}"
178
176
  end
@@ -246,7 +244,7 @@ module Nanoc::Int
246
244
 
247
245
  @fibers.delete(rep)
248
246
  ensure
249
- dependency_tracker.exit(rep.item)
247
+ dependency_tracker.exit
250
248
  end
251
249
  end
252
250
 
@@ -278,11 +276,11 @@ module Nanoc::Int
278
276
 
279
277
  action_provider.memory_for(rep).each do |action|
280
278
  case action
281
- when Nanoc::Int::RuleMemoryActions::Filter
279
+ when Nanoc::Int::ProcessingActions::Filter
282
280
  executor.filter(rep, action.filter_name, action.params)
283
- when Nanoc::Int::RuleMemoryActions::Layout
281
+ when Nanoc::Int::ProcessingActions::Layout
284
282
  executor.layout(rep, action.layout_identifier, action.params)
285
- when Nanoc::Int::RuleMemoryActions::Snapshot
283
+ when Nanoc::Int::ProcessingActions::Snapshot
286
284
  executor.snapshot(rep, action.snapshot_name, final: action.final?, path: action.path)
287
285
  else
288
286
  raise "Internal inconsistency: unknown action #{action.inspect}"
@@ -5,6 +5,8 @@ module Nanoc::Int
5
5
  class OutdatednessChecker
6
6
  extend Nanoc::Int::Memoization
7
7
 
8
+ include Nanoc::Int::ContractsSupport
9
+
8
10
  attr_reader :checksum_store
9
11
  attr_reader :dependency_store
10
12
  attr_reader :rule_memory_store
@@ -31,6 +33,7 @@ module Nanoc::Int
31
33
  @objects_outdated_due_to_dependencies = {}
32
34
  end
33
35
 
36
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Bool
34
37
  # Checks whether the given object is outdated and therefore needs to be
35
38
  # recompiled.
36
39
  #
@@ -42,6 +45,7 @@ module Nanoc::Int
42
45
  !outdatedness_reason_for(obj).nil?
43
46
  end
44
47
 
48
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Maybe[Reasons::Generic]
45
49
  # Calculates the reason why the given object is outdated.
46
50
  #
47
51
  # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
@@ -60,6 +64,7 @@ module Nanoc::Int
60
64
 
61
65
  private
62
66
 
67
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Bool
63
68
  # Checks whether the given object is outdated and therefore needs to be
64
69
  # recompiled. This method does not take dependencies into account; use
65
70
  # {#outdated?} if you want to include dependencies in the outdatedness
@@ -73,6 +78,7 @@ module Nanoc::Int
73
78
  !basic_outdatedness_reason_for(obj).nil?
74
79
  end
75
80
 
81
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Maybe[Reasons::Generic]
76
82
  # Calculates the reason why the given object is outdated. This method does
77
83
  # not take dependencies into account; use {#outdatedness_reason_for?} if
78
84
  # you want to include dependencies in the outdatedness check.
@@ -91,7 +97,8 @@ module Nanoc::Int
91
97
 
92
98
  # Outdated if checksums are missing or different
93
99
  return Reasons::NotEnoughData unless checksums_available?(obj.item)
94
- return Reasons::SourceModified unless checksums_identical?(obj.item)
100
+ return Reasons::ContentModified unless content_checksums_identical?(obj.item)
101
+ return Reasons::AttributesModified unless attributes_checksums_identical?(obj.item)
95
102
 
96
103
  # Outdated if compiled file doesn't exist (yet)
97
104
  return Reasons::NotWritten if obj.raw_path && !File.file?(obj.raw_path)
@@ -107,7 +114,7 @@ module Nanoc::Int
107
114
  # Not outdated
108
115
  nil
109
116
  when Nanoc::Int::Item
110
- @reps[obj].find { |rep| basic_outdatedness_reason_for(rep) }
117
+ @reps[obj].lazy.map { |rep| basic_outdatedness_reason_for(rep) }.find { |s| s }
111
118
  when Nanoc::Int::Layout
112
119
  # Outdated if rules outdated
113
120
  return Reasons::RulesModified if
@@ -115,7 +122,8 @@ module Nanoc::Int
115
122
 
116
123
  # Outdated if checksums are missing or different
117
124
  return Reasons::NotEnoughData unless checksums_available?(obj)
118
- return Reasons::SourceModified unless checksums_identical?(obj)
125
+ return Reasons::ContentModified unless content_checksums_identical?(obj)
126
+ return Reasons::AttributesModified unless attributes_checksums_identical?(obj)
119
127
 
120
128
  # Not outdated
121
129
  nil
@@ -125,6 +133,7 @@ module Nanoc::Int
125
133
  end
126
134
  memoize :basic_outdatedness_reason_for
127
135
 
136
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout], Hamster::Set => C::Bool
128
137
  # Checks whether the given object is outdated due to dependencies.
129
138
  #
130
139
  # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
@@ -162,6 +171,7 @@ module Nanoc::Int
162
171
  is_outdated
163
172
  end
164
173
 
174
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] => C::Bool
165
175
  # @param [Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The layout or item
166
176
  # representation to check the rule memory for
167
177
  #
@@ -172,6 +182,7 @@ module Nanoc::Int
172
182
  end
173
183
  memoize :rule_memory_differs_for
174
184
 
185
+ contract C::Any => String
175
186
  # @param obj The object to create a checksum for
176
187
  #
177
188
  # @return [String] The digest
@@ -180,15 +191,17 @@ module Nanoc::Int
180
191
  end
181
192
  memoize :calc_checksum
182
193
 
194
+ contract C::Any => C::Bool
183
195
  # @param obj
184
196
  #
185
197
  # @return [Boolean] false if either the new or the old checksum for the
186
198
  # given object is not available, true if both checksums are available
187
199
  def checksums_available?(obj)
188
- checksum_store[obj] && calc_checksum(obj)
200
+ checksum_store[obj] && calc_checksum(obj) ? true : false
189
201
  end
190
202
  memoize :checksums_available?
191
203
 
204
+ contract C::Any => C::Bool
192
205
  # @param obj
193
206
  #
194
207
  # @return [Boolean] false if the old and new checksums for the given
@@ -198,6 +211,19 @@ module Nanoc::Int
198
211
  end
199
212
  memoize :checksums_identical?
200
213
 
214
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Bool
215
+ def content_checksums_identical?(obj)
216
+ checksum_store.content_checksum_for(obj) == Nanoc::Int::Checksummer.calc_for_content_of(obj)
217
+ end
218
+ memoize :content_checksums_identical?
219
+
220
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Bool
221
+ def attributes_checksums_identical?(obj)
222
+ checksum_store.attributes_checksum_for(obj) == Nanoc::Int::Checksummer.calc_for_attributes_of(obj)
223
+ end
224
+ memoize :attributes_checksums_identical?
225
+
226
+ contract C::Any => C::Bool
201
227
  # @param obj
202
228
  #
203
229
  # @return [Boolean] true if the old and new checksums for the given object
@@ -40,8 +40,12 @@ module Nanoc::Int
40
40
  'The rules file has been modified since the last time the site was compiled.',
41
41
  )
42
42
 
43
- SourceModified = Generic.new(
44
- 'The source file of this item has been modified since the last time the site was compiled.',
43
+ ContentModified = Generic.new(
44
+ 'The content of this item has been modified since the last time the site was compiled.',
45
+ )
46
+
47
+ AttributesModified = Generic.new(
48
+ 'The attributes of this item have been modified since the last time the site was compiled.',
45
49
  )
46
50
  end
47
51
  end
@@ -1,7 +1,10 @@
1
+ require_relative 'entities/context'
2
+ require_relative 'entities/directed_graph'
3
+
1
4
  require_relative 'entities/identifier'
2
5
  require_relative 'entities/content'
3
- require_relative 'entities/rule_memory_action'
4
- require_relative 'entities/rule_memory_actions'
6
+ require_relative 'entities/processing_action'
7
+ require_relative 'entities/processing_actions'
5
8
 
6
9
  require_relative 'entities/code_snippet'
7
10
  require_relative 'entities/configuration'
@@ -32,7 +32,9 @@ module Nanoc::Int
32
32
  #
33
33
  # @return [void]
34
34
  def load
35
+ # rubocop:disable Lint/Eval
35
36
  eval(@data, TOPLEVEL_BINDING, @filename)
37
+ # rubocop:enable Lint/Eval
36
38
  nil
37
39
  end
38
40
 
@@ -37,9 +37,11 @@ module Nanoc::Int
37
37
  # Returns a binding for this instance.
38
38
  #
39
39
  # @return [Binding] A binding for this instance
40
+ # rubocop:disable Style/AccessorMethodName
40
41
  def get_binding
41
42
  binding
42
43
  end
44
+ # rubocop:enable Style/AccessorMethodName
43
45
 
44
46
  def include(mod)
45
47
  metaclass = class << self; self; end
@@ -18,24 +18,41 @@ module Nanoc
18
18
  # @return [String, nil]
19
19
  attr_accessor :checksum_data
20
20
 
21
+ # @return [String, nil]
22
+ attr_accessor :content_checksum_data
23
+
24
+ # @return [String, nil]
25
+ attr_accessor :attributes_checksum_data
26
+
21
27
  c_content = C::Or[String, Nanoc::Int::Content]
22
28
  c_attributes = C::Or[Hash, Proc]
23
29
  c_identifier = C::Or[String, Nanoc::Identifier]
24
- c_checksum_data = C::Optional[C::Maybe[String]]
30
+ c_checksum_data = C::KeywordArgs[
31
+ checksum_data: C::Optional[C::Maybe[String]],
32
+ content_checksum_data: C::Optional[C::Maybe[String]],
33
+ attributes_checksum_data: C::Optional[C::Maybe[String]],
34
+ ]
25
35
 
26
- contract c_content, c_attributes, c_identifier, C::KeywordArgs[checksum_data: c_checksum_data] => C::Any
36
+ contract c_content, c_attributes, c_identifier, c_checksum_data => C::Any
27
37
  # @param [String, Nanoc::Int::Content] content
28
38
  #
29
39
  # @param [Hash, Proc] attributes
30
40
  #
31
41
  # @param [String, Nanoc::Identifier] identifier
32
42
  #
33
- # @param [String, nil] checksum_data Used to determine whether the document has changed
34
- def initialize(content, attributes, identifier, checksum_data: nil)
43
+ # @param [String, nil] checksum_data
44
+ #
45
+ # @param [String, nil] content_checksum_data
46
+ #
47
+ # @param [String, nil] attributes_checksum_data
48
+ def initialize(content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
35
49
  @content = Nanoc::Int::Content.create(content)
36
50
  @attributes = Nanoc::Int::LazyValue.new(attributes).map(&:__nanoc_symbolize_keys_recursively)
37
51
  @identifier = Nanoc::Identifier.from(identifier)
52
+
38
53
  @checksum_data = checksum_data
54
+ @content_checksum_data = content_checksum_data
55
+ @attributes_checksum_data = attributes_checksum_data
39
56
  end
40
57
 
41
58
  contract C::None => self
@@ -1,11 +1,11 @@
1
1
  module Nanoc::Int
2
- class RuleMemoryAction
2
+ class ProcessingAction
3
3
  def serialize
4
- raise NotImplementedError.new('Nanoc::RuleMemoryAction subclasses must implement #serialize and #to_s')
4
+ raise NotImplementedError.new('Nanoc::ProcessingAction subclasses must implement #serialize and #to_s')
5
5
  end
6
6
 
7
7
  def to_s
8
- raise NotImplementedError.new('Nanoc::RuleMemoryAction subclasses must implement #serialize and #to_s')
8
+ raise NotImplementedError.new('Nanoc::ProcessingAction subclasses must implement #serialize and #to_s')
9
9
  end
10
10
 
11
11
  def inspect
@@ -0,0 +1,3 @@
1
+ require_relative 'processing_actions/filter'
2
+ require_relative 'processing_actions/layout'
3
+ require_relative 'processing_actions/snapshot'
@@ -1,5 +1,5 @@
1
- module Nanoc::Int::RuleMemoryActions
2
- class Filter < Nanoc::Int::RuleMemoryAction
1
+ module Nanoc::Int::ProcessingActions
2
+ class Filter < Nanoc::Int::ProcessingAction
3
3
  # filter :foo
4
4
  # filter :foo, params
5
5
 
@@ -1,5 +1,5 @@
1
- module Nanoc::Int::RuleMemoryActions
2
- class Layout < Nanoc::Int::RuleMemoryAction
1
+ module Nanoc::Int::ProcessingActions
2
+ class Layout < Nanoc::Int::ProcessingAction
3
3
  # layout '/foo.erb'
4
4
  # layout '/foo.erb', params
5
5
 
@@ -1,5 +1,5 @@
1
- module Nanoc::Int::RuleMemoryActions
2
- class Snapshot < Nanoc::Int::RuleMemoryAction
1
+ module Nanoc::Int::ProcessingActions
2
+ class Snapshot < Nanoc::Int::ProcessingAction
3
3
  # snapshot :before_layout
4
4
  # snapshot :before_layout, final: true
5
5
  # snapshot :before_layout, path: '/about.md'
@@ -13,38 +13,38 @@ module Nanoc::Int
13
13
  @actions.size
14
14
  end
15
15
 
16
- contract Numeric => C::Maybe[Nanoc::Int::RuleMemoryAction]
16
+ contract Numeric => C::Maybe[Nanoc::Int::ProcessingAction]
17
17
  def [](idx)
18
18
  @actions[idx]
19
19
  end
20
20
 
21
21
  contract Symbol, Hash => self
22
22
  def add_filter(filter_name, params)
23
- @actions << Nanoc::Int::RuleMemoryActions::Filter.new(filter_name, params)
23
+ @actions << Nanoc::Int::ProcessingActions::Filter.new(filter_name, params)
24
24
  self
25
25
  end
26
26
 
27
27
  contract String, C::Maybe[Hash] => self
28
28
  def add_layout(layout_identifier, params)
29
- @actions << Nanoc::Int::RuleMemoryActions::Layout.new(layout_identifier, params)
29
+ @actions << Nanoc::Int::ProcessingActions::Layout.new(layout_identifier, params)
30
30
  self
31
31
  end
32
32
 
33
33
  contract Symbol, C::Bool, C::Maybe[String] => self
34
34
  def add_snapshot(snapshot_name, final, path)
35
35
  will_add_snapshot(snapshot_name) if final
36
- @actions << Nanoc::Int::RuleMemoryActions::Snapshot.new(snapshot_name, final, path)
36
+ @actions << Nanoc::Int::ProcessingActions::Snapshot.new(snapshot_name, final, path)
37
37
  self
38
38
  end
39
39
 
40
- contract C::None => C::ArrayOf[Nanoc::Int::RuleMemoryAction]
40
+ contract C::None => C::ArrayOf[Nanoc::Int::ProcessingAction]
41
41
  def snapshot_actions
42
- @actions.select { |a| a.is_a?(Nanoc::Int::RuleMemoryActions::Snapshot) }
42
+ @actions.select { |a| a.is_a?(Nanoc::Int::ProcessingActions::Snapshot) }
43
43
  end
44
44
 
45
45
  contract C::None => C::Bool
46
46
  def any_layouts?
47
- @actions.any? { |a| a.is_a?(Nanoc::Int::RuleMemoryActions::Layout) }
47
+ @actions.any? { |a| a.is_a?(Nanoc::Int::ProcessingActions::Layout) }
48
48
  end
49
49
 
50
50
  # TODO: Add contract
@@ -52,7 +52,7 @@ module Nanoc::Int
52
52
  map(&:serialize)
53
53
  end
54
54
 
55
- contract C::Func[Nanoc::Int::RuleMemoryAction => C::Any] => self
55
+ contract C::Func[Nanoc::Int::ProcessingAction => C::Any] => self
56
56
  def each
57
57
  @actions.each { |a| yield(a) }
58
58
  self
@@ -89,5 +89,4 @@ module Nanoc
89
89
  end
90
90
  end
91
91
 
92
- Nanoc::Feature.define('profiler', version: '4.3')
93
- Nanoc::Feature.define('environments', version: '4.3')
92
+ Nanoc::Feature.define('profiler', version: '4.4')
@@ -5,5 +5,6 @@ require_relative 'repos/compiled_content_cache'
5
5
  require_relative 'repos/config_loader'
6
6
  require_relative 'repos/data_source'
7
7
  require_relative 'repos/dependency_store'
8
+ require_relative 'repos/item_rep_repo'
8
9
  require_relative 'repos/rule_memory_store'
9
10
  require_relative 'repos/site_loader'
@@ -4,6 +4,8 @@ module Nanoc::Int
4
4
  #
5
5
  # @api private
6
6
  class ChecksumStore < ::Nanoc::Int::Store
7
+ include Nanoc::Int::ContractsSupport
8
+
7
9
  # @param [Nanoc::Int::Site] site
8
10
  def initialize(site: nil)
9
11
  super(Nanoc::Int::Store.tmp_path_for(env_name: (site.config.env_name if site), store_name: 'checksums'), 1)
@@ -13,6 +15,7 @@ module Nanoc::Int
13
15
  @checksums = {}
14
16
  end
15
17
 
18
+ contract C::Any => C::Maybe[String]
16
19
  # Returns the old checksum for the given object. This makes sense for
17
20
  # items, layouts and code snippets.
18
21
  #
@@ -23,13 +26,24 @@ module Nanoc::Int
23
26
  @checksums[obj.reference]
24
27
  end
25
28
 
26
- # Sets the checksum for the given object.
27
- #
28
- # @param [#reference] obj The object for which to set the checksum
29
- #
30
- # @param [String] checksum The checksum
31
- def []=(obj, checksum)
32
- @checksums[obj.reference] = checksum
29
+ # Calculates and stores the checksum for the given object.
30
+ def add(obj)
31
+ if obj.is_a?(Nanoc::Int::Document)
32
+ @checksums[[obj.reference, :content]] = Nanoc::Int::Checksummer.calc_for_content_of(obj)
33
+ @checksums[[obj.reference, :attributes]] = Nanoc::Int::Checksummer.calc_for_attributes_of(obj)
34
+ end
35
+
36
+ @checksums[obj.reference] = Nanoc::Int::Checksummer.calc(obj)
37
+ end
38
+
39
+ contract C::Any => C::Maybe[String]
40
+ def content_checksum_for(obj)
41
+ @checksums[[obj.reference, :content]]
42
+ end
43
+
44
+ contract C::Any => C::Maybe[String]
45
+ def attributes_checksum_for(obj)
46
+ @checksums[[obj.reference, :attributes]]
33
47
  end
34
48
 
35
49
  protected
@@ -44,11 +44,7 @@ module Nanoc::Int
44
44
  ).with_defaults
45
45
 
46
46
  # Load environment
47
- if Nanoc::Feature.enabled?(Nanoc::Feature::ENVIRONMENTS)
48
- config.with_environment
49
- else
50
- config
51
- end
47
+ config.with_environment
52
48
  end
53
49
 
54
50
  # @api private
@@ -140,10 +140,14 @@ module Nanoc
140
140
  #
141
141
  # @param [Boolean] binary Whether or not this item is binary
142
142
  #
143
- # @param [String, nil] checksum_data Used to determine whether the item has changed
144
- def new_item(content, attributes, identifier, binary: false, checksum_data: nil)
143
+ # @param [String, nil] checksum_data
144
+ #
145
+ # @param [String, nil] content_checksum_data
146
+ #
147
+ # @param [String, nil] attributes_checksum_data
148
+ def new_item(content, attributes, identifier, binary: false, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
145
149
  content = Nanoc::Int::Content.create(content, binary: binary)
146
- Nanoc::Int::Item.new(content, attributes, identifier, checksum_data: checksum_data)
150
+ Nanoc::Int::Item.new(content, attributes, identifier, checksum_data: checksum_data, content_checksum_data: content_checksum_data, attributes_checksum_data: attributes_checksum_data)
147
151
  end
148
152
 
149
153
  # Creates a new in-memory layout instance. This is intended for use within
@@ -155,9 +159,13 @@ module Nanoc
155
159
  #
156
160
  # @param [String] identifier This layout's identifier.
157
161
  #
158
- # @param [String, nil] checksum_data Used to determine whether the layout has changed
159
- def new_layout(raw_content, attributes, identifier, checksum_data: nil)
160
- Nanoc::Int::Layout.new(raw_content, attributes, identifier, checksum_data: checksum_data)
162
+ # @param [String, nil] checksum_data
163
+ #
164
+ # @param [String, nil] content_checksum_data
165
+ #
166
+ # @param [String, nil] attributes_checksum_data
167
+ def new_layout(raw_content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
168
+ Nanoc::Int::Layout.new(raw_content, attributes, identifier, checksum_data: checksum_data, content_checksum_data: content_checksum_data, attributes_checksum_data: attributes_checksum_data)
161
169
  end
162
170
  end
163
171
  end
@@ -1,6 +1,9 @@
1
1
  require_relative 'services/action_provider'
2
+ require_relative 'services/checksummer'
2
3
  require_relative 'services/compiler_loader'
4
+ require_relative 'services/dependency_tracker'
3
5
  require_relative 'services/executor'
6
+ require_relative 'services/filter'
4
7
  require_relative 'services/item_rep_builder'
5
8
  require_relative 'services/item_rep_router'
6
9
  require_relative 'services/item_rep_selector'
@@ -44,6 +44,14 @@ module Nanoc::Int
44
44
  digest.to_s
45
45
  end
46
46
 
47
+ def calc_for_content_of(obj)
48
+ obj.content_checksum_data || obj.checksum_data || Nanoc::Int::Checksummer.calc(obj.content)
49
+ end
50
+
51
+ def calc_for_attributes_of(obj)
52
+ obj.attributes_checksum_data || obj.checksum_data || Nanoc::Int::Checksummer.calc(obj.attributes)
53
+ end
54
+
47
55
  private
48
56
 
49
57
  def update(obj, digest, visited = Hamster::Set.new)
@@ -181,11 +189,19 @@ module Nanoc::Int
181
189
  if obj.checksum_data
182
190
  digest.update('checksum_data=' + obj.checksum_data)
183
191
  else
184
- digest.update('content=')
185
- yield(obj.content)
192
+ if obj.content_checksum_data
193
+ digest.update('content_checksum_data=' + obj.content_checksum_data)
194
+ else
195
+ digest.update('content=')
196
+ yield(obj.content)
197
+ end
186
198
 
187
- digest.update(',attributes=')
188
- yield(obj.attributes)
199
+ if obj.attributes_checksum_data
200
+ digest.update(',attributes_checksum_data=' + obj.attributes_checksum_data)
201
+ else
202
+ digest.update(',attributes=')
203
+ yield(obj.attributes)
204
+ end
189
205
 
190
206
  digest.update(',identifier=')
191
207
  yield(obj.identifier)
@@ -2,12 +2,17 @@ module Nanoc::Int
2
2
  # @api private
3
3
  class DependencyTracker
4
4
  class Null
5
+ include Nanoc::Int::ContractsSupport
6
+
7
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
5
8
  def enter(_obj)
6
9
  end
7
10
 
8
- def exit(_obj)
11
+ contract C::None => C::Any
12
+ def exit
9
13
  end
10
14
 
15
+ contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
11
16
  def bounce(_obj)
12
17
  end
13
18
  end
@@ -29,15 +34,15 @@ module Nanoc::Int
29
34
  @stack.push(obj)
30
35
  end
31
36
 
32
- contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
33
- def exit(_obj)
37
+ contract C::None => C::Any
38
+ def exit
34
39
  @stack.pop
35
40
  end
36
41
 
37
42
  contract C::Or[Nanoc::Int::Item, Nanoc::Int::Layout] => C::Any
38
43
  def bounce(obj)
39
44
  enter(obj)
40
- exit(obj)
45
+ exit
41
46
  end
42
47
  end
43
48
  end
File without changes
@@ -138,9 +138,11 @@ module Nanoc::CLI
138
138
  end
139
139
 
140
140
  # @see ARGF.set_encoding
141
+ # rubocop:disable Style/AccessorMethodName
141
142
  def set_encoding(*args)
142
143
  @stream.set_encoding(*args)
143
144
  end
145
+ # rubocop:enable Style/AccessorMethodName
144
146
 
145
147
  protected
146
148
 
@@ -10,10 +10,8 @@ opt :d, :debug, 'enable debugging' do
10
10
  Nanoc::CLI.debug = true
11
11
  end
12
12
 
13
- if Nanoc::Feature.enabled?(Nanoc::Feature::ENVIRONMENTS)
14
- opt :e, :env, 'set environment', argument: :required do |value|
15
- ENV.store('NANOC_ENV', value)
16
- end
13
+ opt :e, :env, 'set environment', argument: :required do |value|
14
+ ENV.store('NANOC_ENV', value)
17
15
  end
18
16
 
19
17
  opt :h, :help, 'show the help message and quit' do |_value, cmd|
@@ -44,7 +44,9 @@ module Nanoc::CLI::Commands
44
44
  use Rack::ShowExceptions
45
45
  use Rack::Lint
46
46
  use Rack::Head
47
- use Adsf::Rack::IndexFileFinder, root: site.config[:output_dir]
47
+ use Adsf::Rack::IndexFileFinder,
48
+ root: site.config[:output_dir],
49
+ index_filenames: %w(index.html index.xhtml)
48
50
  run Rack::File.new(site.config[:output_dir])
49
51
  end.to_app
50
52
 
@@ -76,11 +76,12 @@ module Nanoc::DataSources
76
76
 
77
77
  class ProtoDocument
78
78
  attr_reader :attributes
79
- attr_reader :checksum_data
79
+ attr_reader :content_checksum_data
80
+ attr_reader :attributes_checksum_data
80
81
  attr_reader :is_binary
81
82
  alias binary? is_binary
82
83
 
83
- def initialize(is_binary:, content: nil, filename: nil, attributes:, checksum_data: nil)
84
+ def initialize(is_binary:, content: nil, filename: nil, attributes:, content_checksum_data: nil, attributes_checksum_data: nil)
84
85
  if content.nil? && filename.nil?
85
86
  raise ArgumentError, '#initialize needs at least content or filename'
86
87
  end
@@ -89,7 +90,8 @@ module Nanoc::DataSources
89
90
  @content = content
90
91
  @filename = filename
91
92
  @attributes = attributes
92
- @checksum_data = checksum_data
93
+ @content_checksum_data = content_checksum_data
94
+ @attributes_checksum_data = attributes_checksum_data
93
95
  end
94
96
 
95
97
  def content
@@ -125,7 +127,8 @@ module Nanoc::DataSources
125
127
  is_binary: false,
126
128
  content: parse_result.content,
127
129
  attributes: parse_result.attributes,
128
- checksum_data: "content=#{parse_result.content},meta=#{parse_result.attributes_data}",
130
+ content_checksum_data: parse_result.content,
131
+ attributes_checksum_data: parse_result.attributes_data,
129
132
  )
130
133
  end
131
134
  end
@@ -157,7 +160,13 @@ module Nanoc::DataSources
157
160
  attributes = attributes_for(proto_doc, content_filename, meta_filename)
158
161
  identifier = identifier_for(content_filename, meta_filename, dir_name)
159
162
 
160
- res << klass.new(content, attributes, identifier, checksum_data: proto_doc.checksum_data)
163
+ res << klass.new(
164
+ content,
165
+ attributes,
166
+ identifier,
167
+ content_checksum_data: proto_doc.content_checksum_data,
168
+ attributes_checksum_data: proto_doc.attributes_checksum_data,
169
+ )
161
170
  end
162
171
  end
163
172
 
@@ -358,7 +367,7 @@ module Nanoc::DataSources
358
367
  def parse_metadata(data, filename)
359
368
  begin
360
369
  meta = YAML.load(data) || {}
361
- rescue Exception => e
370
+ rescue => e
362
371
  raise "Could not parse YAML for #{filename}: #{e.message}"
363
372
  end
364
373
 
data/lib/nanoc/extra.rb CHANGED
@@ -12,6 +12,9 @@ module Nanoc::Extra
12
12
 
13
13
  # @deprecated
14
14
  Deployer = Nanoc::Deploying::Deployer
15
+
16
+ # @deprecated
17
+ Pruner = Nanoc::Pruner
15
18
  end
16
19
 
17
20
  require 'nanoc/extra/core_ext'
data/lib/nanoc/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nanoc
2
2
  # The current Nanoc version.
3
- VERSION = '4.3.8'.freeze
3
+ VERSION = '4.4.0'.freeze
4
4
  end
@@ -17,7 +17,7 @@ class Nanoc::Int::ContextTest < Nanoc::TestCase
17
17
 
18
18
  def test_example
19
19
  # Parse
20
- YARD.parse(LIB_DIR + '/nanoc/base/context.rb')
20
+ YARD.parse(LIB_DIR + '/nanoc/base/entities/context.rb')
21
21
 
22
22
  # Run
23
23
  assert_examples_correct 'Nanoc::Int::Context#initialize'
@@ -40,6 +40,17 @@ class Nanoc::DataSourceTest < Nanoc::TestCase
40
40
  assert_equal 'abcdef', item.checksum_data
41
41
  end
42
42
 
43
+ def test_new_item_with_checksums
44
+ data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
45
+
46
+ item = data_source.new_item('stuff', { title: 'Stuff!' }, '/asdf/', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
47
+ assert_equal 'stuff', item.content.string
48
+ assert_equal 'Stuff!', item.attributes[:title]
49
+ assert_equal Nanoc::Identifier.new('/asdf/'), item.identifier
50
+ assert_equal 'con-cs', item.content_checksum_data
51
+ assert_equal 'attr-cs', item.attributes_checksum_data
52
+ end
53
+
43
54
  def test_new_layout
44
55
  data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
45
56
 
@@ -49,4 +60,15 @@ class Nanoc::DataSourceTest < Nanoc::TestCase
49
60
  assert_equal Nanoc::Identifier.new('/asdf/'), layout.identifier
50
61
  assert_equal 'abcdef', layout.checksum_data
51
62
  end
63
+
64
+ def test_new_layout_with_checksums
65
+ data_source = Nanoc::DataSource.new(nil, nil, nil, nil)
66
+
67
+ layout = data_source.new_layout('stuff', { title: 'Stuff!' }, '/asdf/', content_checksum_data: 'con-cs', attributes_checksum_data: 'attr-cs')
68
+ assert_equal 'stuff', layout.content.string
69
+ assert_equal 'Stuff!', layout.attributes[:title]
70
+ assert_equal Nanoc::Identifier.new('/asdf/'), layout.identifier
71
+ assert_equal 'con-cs', layout.content_checksum_data
72
+ assert_equal 'attr-cs', layout.attributes_checksum_data
73
+ end
52
74
  end
@@ -1,7 +1,10 @@
1
1
  class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
2
2
  def test_initialize
3
3
  # Mock items
4
- items = [mock, mock]
4
+ items = [
5
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
6
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
7
+ ]
5
8
 
6
9
  # Create
7
10
  store = Nanoc::Int::DependencyStore.new(items)
@@ -13,7 +16,10 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
13
16
 
14
17
  def test_record_dependency
15
18
  # Mock items
16
- items = [mock, mock]
19
+ items = [
20
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
21
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
22
+ ]
17
23
 
18
24
  # Create
19
25
  store = Nanoc::Int::DependencyStore.new(items)
@@ -27,7 +33,10 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
27
33
 
28
34
  def test_record_dependency_no_self
29
35
  # Mock items
30
- items = [mock, mock]
36
+ items = [
37
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
38
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
39
+ ]
31
40
 
32
41
  # Create
33
42
  store = Nanoc::Int::DependencyStore.new(items)
@@ -42,7 +51,10 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
42
51
 
43
52
  def test_record_dependency_no_doubles
44
53
  # Mock items
45
- items = [mock, mock]
54
+ items = [
55
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
56
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
57
+ ]
46
58
 
47
59
  # Create
48
60
  store = Nanoc::Int::DependencyStore.new(items)
@@ -58,7 +70,11 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
58
70
 
59
71
  def test_objects_causing_outdatedness_of
60
72
  # Mock items
61
- items = [mock, mock, mock]
73
+ items = [
74
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
75
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
76
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
77
+ ]
62
78
 
63
79
  # Create
64
80
  store = Nanoc::Int::DependencyStore.new(items)
@@ -73,7 +89,11 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
73
89
 
74
90
  def test_objects_outdated_due_to
75
91
  # Mock items
76
- items = [mock, mock, mock]
92
+ items = [
93
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
94
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
95
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
96
+ ]
77
97
 
78
98
  # Create
79
99
  store = Nanoc::Int::DependencyStore.new(items)
@@ -88,12 +108,12 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
88
108
 
89
109
  def test_store_graph_and_load_graph_simple
90
110
  # Mock items
91
- items = [mock('0'), mock('1'), mock('2'), mock('3')]
92
- items.each { |i| i.stubs(:type).returns(:item) }
93
- items[0].stubs(:reference).returns([:item, '/aaa/'])
94
- items[1].stubs(:reference).returns([:item, '/bbb/'])
95
- items[2].stubs(:reference).returns([:item, '/ccc/'])
96
- items[3].stubs(:reference).returns([:item, '/ddd/'])
111
+ items = [
112
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
113
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
114
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
115
+ Nanoc::Int::Item.new('d', {}, '/d.md'),
116
+ ]
97
117
 
98
118
  # Create
99
119
  store = Nanoc::Int::DependencyStore.new(items)
@@ -122,12 +142,12 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
122
142
 
123
143
  def test_store_graph_and_load_graph_with_removed_items
124
144
  # Mock items
125
- items = [mock('0'), mock('1'), mock('2'), mock('3')]
126
- items.each { |i| i.stubs(:type).returns(:item) }
127
- items[0].stubs(:reference).returns([:item, '/aaa/'])
128
- items[1].stubs(:reference).returns([:item, '/bbb/'])
129
- items[2].stubs(:reference).returns([:item, '/ccc/'])
130
- items[3].stubs(:reference).returns([:item, '/ddd/'])
145
+ items = [
146
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
147
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
148
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
149
+ Nanoc::Int::Item.new('d', {}, '/d.md'),
150
+ ]
131
151
 
132
152
  # Create new and old lists
133
153
  old_items = [items[0], items[1], items[2], items[3]]
@@ -159,11 +179,11 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
159
179
 
160
180
  def test_store_graph_with_nils_in_dst
161
181
  # Mock items
162
- items = [mock('0'), mock('1'), mock('2')]
163
- items.each { |i| i.stubs(:type).returns(:item) }
164
- items[0].stubs(:reference).returns([:item, '/aaa/'])
165
- items[1].stubs(:reference).returns([:item, '/bbb/'])
166
- items[2].stubs(:reference).returns([:item, '/ccc/'])
182
+ items = [
183
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
184
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
185
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
186
+ ]
167
187
 
168
188
  # Create
169
189
  store = Nanoc::Int::DependencyStore.new(items)
@@ -189,11 +209,11 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
189
209
 
190
210
  def test_store_graph_with_nils_in_src
191
211
  # Mock items
192
- items = [mock('0'), mock('1'), mock('2')]
193
- items.each { |i| i.stubs(:type).returns(:item) }
194
- items[0].stubs(:reference).returns([:item, '/aaa/'])
195
- items[1].stubs(:reference).returns([:item, '/bbb/'])
196
- items[2].stubs(:reference).returns([:item, '/ccc/'])
212
+ items = [
213
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
214
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
215
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
216
+ ]
197
217
 
198
218
  # Create
199
219
  store = Nanoc::Int::DependencyStore.new(items)
@@ -219,7 +239,11 @@ class Nanoc::Int::DependencyTrackerTest < Nanoc::TestCase
219
239
 
220
240
  def test_forget_dependencies_for
221
241
  # Mock items
222
- items = [mock, mock, mock]
242
+ items = [
243
+ Nanoc::Int::Item.new('a', {}, '/a.md'),
244
+ Nanoc::Int::Item.new('b', {}, '/b.md'),
245
+ Nanoc::Int::Item.new('c', {}, '/c.md'),
246
+ ]
223
247
 
224
248
  # Create
225
249
  store = Nanoc::Int::DependencyStore.new(items)
@@ -279,7 +279,7 @@ class Nanoc::Int::DirectedGraphTest < Nanoc::TestCase
279
279
  end
280
280
 
281
281
  def test_example
282
- YARD.parse(LIB_DIR + '/nanoc/base/directed_graph.rb')
282
+ YARD.parse(LIB_DIR + '/nanoc/base/entities/directed_graph.rb')
283
283
  assert_examples_correct 'Nanoc::Int::DirectedGraph'
284
284
  end
285
285
  end
@@ -72,7 +72,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
72
72
  end
73
73
  end
74
74
 
75
- def test_outdated_if_item_checksum_is_different
75
+ def test_outdated_if_item_content_checksum_is_different
76
76
  # Compile once
77
77
  with_site(name: 'foo') do |site|
78
78
  File.open('content/index.html', 'w') { |io| io.write('o hello') }
@@ -83,7 +83,7 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
83
83
  site.compile
84
84
  end
85
85
 
86
- # Create new item
86
+ # Update item
87
87
  FileUtils.cd('foo') do
88
88
  File.open('content/new.html', 'w') { |io| io.write('o hello DIFFERENT!!!') }
89
89
  end
@@ -95,7 +95,34 @@ class Nanoc::Int::OutdatednessCheckerTest < Nanoc::TestCase
95
95
  site.compiler.load_stores
96
96
  outdatedness_checker = site.compiler.send :outdatedness_checker
97
97
  rep = site.compiler.reps[site.items.find { |i| i.identifier == '/new/' }][0]
98
- assert_equal ::Nanoc::Int::OutdatednessReasons::SourceModified, outdatedness_checker.outdatedness_reason_for(rep)
98
+ assert_equal ::Nanoc::Int::OutdatednessReasons::ContentModified, outdatedness_checker.outdatedness_reason_for(rep)
99
+ end
100
+ end
101
+
102
+ def test_outdated_if_item_attributes_checksum_is_different
103
+ # Compile once
104
+ with_site(name: 'foo') do |site|
105
+ File.open('content/index.html', 'w') { |io| io.write('o hello') }
106
+ File.open('content/new.html', 'w') { |io| io.write('o hello too') }
107
+ File.open('lib/stuff.rb', 'w') { |io| io.write('$foo = 123') }
108
+
109
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
110
+ site.compile
111
+ end
112
+
113
+ # Update item
114
+ FileUtils.cd('foo') do
115
+ File.open('content/new.html', 'w') { |io| io.write("---\ntitle: donkey\n---\no hello too") }
116
+ end
117
+
118
+ # Check
119
+ with_site(name: 'foo') do |site|
120
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
121
+ site.compiler.build_reps
122
+ site.compiler.load_stores
123
+ outdatedness_checker = site.compiler.send :outdatedness_checker
124
+ rep = site.compiler.reps[site.items.find { |i| i.identifier == '/new/' }][0]
125
+ assert_equal ::Nanoc::Int::OutdatednessReasons::AttributesModified, outdatedness_checker.outdatedness_reason_for(rep)
99
126
  end
100
127
  end
101
128
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.8
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2016-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -124,25 +124,21 @@ files:
124
124
  - bin/nanoc
125
125
  - lib/nanoc.rb
126
126
  - lib/nanoc/base.rb
127
- - lib/nanoc/base/checksummer.rb
128
127
  - lib/nanoc/base/compilation/compiler.rb
129
- - lib/nanoc/base/compilation/dependency_tracker.rb
130
- - lib/nanoc/base/compilation/filter.rb
131
- - lib/nanoc/base/compilation/item_rep_repo.rb
132
128
  - lib/nanoc/base/compilation/outdatedness_checker.rb
133
129
  - lib/nanoc/base/compilation/outdatedness_reasons.rb
134
- - lib/nanoc/base/context.rb
135
130
  - lib/nanoc/base/contracts_support.rb
136
131
  - lib/nanoc/base/core_ext.rb
137
132
  - lib/nanoc/base/core_ext/array.rb
138
133
  - lib/nanoc/base/core_ext/hash.rb
139
134
  - lib/nanoc/base/core_ext/pathname.rb
140
135
  - lib/nanoc/base/core_ext/string.rb
141
- - lib/nanoc/base/directed_graph.rb
142
136
  - lib/nanoc/base/entities.rb
143
137
  - lib/nanoc/base/entities/code_snippet.rb
144
138
  - lib/nanoc/base/entities/configuration.rb
145
139
  - lib/nanoc/base/entities/content.rb
140
+ - lib/nanoc/base/entities/context.rb
141
+ - lib/nanoc/base/entities/directed_graph.rb
146
142
  - lib/nanoc/base/entities/document.rb
147
143
  - lib/nanoc/base/entities/identifiable_collection.rb
148
144
  - lib/nanoc/base/entities/identifier.rb
@@ -151,12 +147,12 @@ files:
151
147
  - lib/nanoc/base/entities/layout.rb
152
148
  - lib/nanoc/base/entities/lazy_value.rb
153
149
  - lib/nanoc/base/entities/pattern.rb
150
+ - lib/nanoc/base/entities/processing_action.rb
151
+ - lib/nanoc/base/entities/processing_actions.rb
152
+ - lib/nanoc/base/entities/processing_actions/filter.rb
153
+ - lib/nanoc/base/entities/processing_actions/layout.rb
154
+ - lib/nanoc/base/entities/processing_actions/snapshot.rb
154
155
  - lib/nanoc/base/entities/rule_memory.rb
155
- - lib/nanoc/base/entities/rule_memory_action.rb
156
- - lib/nanoc/base/entities/rule_memory_actions.rb
157
- - lib/nanoc/base/entities/rule_memory_actions/filter.rb
158
- - lib/nanoc/base/entities/rule_memory_actions/layout.rb
159
- - lib/nanoc/base/entities/rule_memory_actions/snapshot.rb
160
156
  - lib/nanoc/base/entities/site.rb
161
157
  - lib/nanoc/base/entities/snapshot_def.rb
162
158
  - lib/nanoc/base/error.rb
@@ -170,13 +166,17 @@ files:
170
166
  - lib/nanoc/base/repos/config_loader.rb
171
167
  - lib/nanoc/base/repos/data_source.rb
172
168
  - lib/nanoc/base/repos/dependency_store.rb
169
+ - lib/nanoc/base/repos/item_rep_repo.rb
173
170
  - lib/nanoc/base/repos/rule_memory_store.rb
174
171
  - lib/nanoc/base/repos/site_loader.rb
175
172
  - lib/nanoc/base/repos/store.rb
176
173
  - lib/nanoc/base/services.rb
177
174
  - lib/nanoc/base/services/action_provider.rb
175
+ - lib/nanoc/base/services/checksummer.rb
178
176
  - lib/nanoc/base/services/compiler_loader.rb
177
+ - lib/nanoc/base/services/dependency_tracker.rb
179
178
  - lib/nanoc/base/services/executor.rb
179
+ - lib/nanoc/base/services/filter.rb
180
180
  - lib/nanoc/base/services/item_rep_builder.rb
181
181
  - lib/nanoc/base/services/item_rep_router.rb
182
182
  - lib/nanoc/base/services/item_rep_selector.rb
@@ -1,3 +0,0 @@
1
- require_relative 'rule_memory_actions/filter'
2
- require_relative 'rule_memory_actions/layout'
3
- require_relative 'rule_memory_actions/snapshot'