nanoc3 3.2.0a1 → 3.2.0a2

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 (58) hide show
  1. data/ChangeLog +2 -2
  2. data/NEWS.md +14 -0
  3. data/README.md +20 -12
  4. data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
  5. data/lib/nanoc3/base/compilation/checksum_store.rb +130 -0
  6. data/lib/nanoc3/base/compilation/checksummer.rb +68 -0
  7. data/lib/nanoc3/base/compilation/compiled_content_cache.rb +57 -0
  8. data/lib/nanoc3/base/{compiler.rb → compilation/compiler.rb} +255 -55
  9. data/lib/nanoc3/base/{compiler_dsl.rb → compilation/compiler_dsl.rb} +11 -6
  10. data/lib/nanoc3/base/{dependency_tracker.rb → compilation/dependency_tracker.rb} +62 -92
  11. data/lib/nanoc3/base/{filter.rb → compilation/filter.rb} +0 -0
  12. data/lib/nanoc3/base/compilation/item_rep_proxy.rb +87 -0
  13. data/lib/nanoc3/base/compilation/outdatedness_checker.rb +86 -0
  14. data/lib/nanoc3/base/compilation/outdatedness_reasons.rb +43 -0
  15. data/lib/nanoc3/base/{rule.rb → compilation/rule.rb} +8 -2
  16. data/lib/nanoc3/base/{rule_context.rb → compilation/rule_context.rb} +17 -14
  17. data/lib/nanoc3/base/directed_graph.rb +8 -0
  18. data/lib/nanoc3/base/errors.rb +9 -17
  19. data/lib/nanoc3/base/plugin_registry.rb +1 -1
  20. data/lib/nanoc3/base/result_data/item_rep.rb +447 -0
  21. data/lib/nanoc3/base/{code_snippet.rb → source_data/code_snippet.rb} +7 -22
  22. data/lib/nanoc3/base/{data_source.rb → source_data/data_source.rb} +0 -0
  23. data/lib/nanoc3/base/{item.rb → source_data/item.rb} +20 -30
  24. data/lib/nanoc3/base/{layout.rb → source_data/layout.rb} +7 -26
  25. data/lib/nanoc3/base/source_data/site.rb +314 -0
  26. data/lib/nanoc3/base/store.rb +126 -0
  27. data/lib/nanoc3/base.rb +26 -15
  28. data/lib/nanoc3/cli/base.rb +2 -1
  29. data/lib/nanoc3/cli/commands/compile.rb +116 -48
  30. data/lib/nanoc3/cli/commands/create_item.rb +0 -1
  31. data/lib/nanoc3/cli/commands/create_layout.rb +0 -1
  32. data/lib/nanoc3/cli/commands/create_site.rb +11 -1
  33. data/lib/nanoc3/cli/commands/debug.rb +11 -6
  34. data/lib/nanoc3/cli/commands/info.rb +1 -2
  35. data/lib/nanoc3/cli/commands/update.rb +0 -1
  36. data/lib/nanoc3/cli/commands/watch.rb +27 -32
  37. data/lib/nanoc3/cli/logger.rb +2 -2
  38. data/lib/nanoc3/data_sources/filesystem.rb +1 -6
  39. data/lib/nanoc3/extra/auto_compiler.rb +2 -3
  40. data/lib/nanoc3/extra/deployers/rsync.rb +1 -0
  41. data/lib/nanoc3/extra/validators/links.rb +45 -26
  42. data/lib/nanoc3/filters/asciidoc.rb +58 -0
  43. data/lib/nanoc3/filters/colorize_syntax.rb +47 -9
  44. data/lib/nanoc3/filters/less.rb +6 -0
  45. data/lib/nanoc3/filters/sass.rb +8 -5
  46. data/lib/nanoc3/filters.rb +2 -0
  47. data/lib/nanoc3/helpers/blogging.rb +8 -0
  48. data/lib/nanoc3/helpers/html_escape.rb +37 -7
  49. data/lib/nanoc3/helpers/link_to.rb +15 -4
  50. data/lib/nanoc3/helpers/rendering.rb +6 -2
  51. data/lib/nanoc3/tasks/clean.rb +0 -4
  52. data/lib/nanoc3.rb +1 -1
  53. data/nanoc3.gemspec +42 -0
  54. metadata +35 -19
  55. data/lib/nanoc3/base/checksummer.rb +0 -40
  56. data/lib/nanoc3/base/compiled_content_cache.rb +0 -86
  57. data/lib/nanoc3/base/item_rep.rb +0 -537
  58. data/lib/nanoc3/base/site.rb +0 -490
@@ -0,0 +1,447 @@
1
+ # encoding: utf-8
2
+
3
+ module Nanoc3
4
+
5
+ # A single representation (rep) of an item ({Nanoc3::Item}). An item can
6
+ # have multiple representations. A representation has its own output file.
7
+ # A single item can therefore have multiple output files, each run through
8
+ # a different set of filters with a different layout.
9
+ class ItemRep
10
+
11
+ # Contains all deprecated methods. Mixed into {Nanoc3::ItemRep}.
12
+ module Deprecated
13
+
14
+ # @deprecated Modify the {#raw_paths} attribute instead
15
+ def raw_path=(raw_path)
16
+ raw_paths[:last] = raw_path
17
+ end
18
+
19
+ # @deprecated Modify the {#paths} attribute instead
20
+ def path=(path)
21
+ paths[:last] = path
22
+ end
23
+
24
+ # @deprecated Use {Nanoc3::ItemRep#compiled_content} instead.
25
+ def content_at_snapshot(snapshot=:pre)
26
+ compiled_content(:snapshot => snapshot)
27
+ end
28
+
29
+ # @deprecated
30
+ def created
31
+ raise NotImplementedError, "Nanoc3::ItemRep#created is no longer implemented"
32
+ end
33
+
34
+ # @deprecated
35
+ def created?
36
+ raise NotImplementedError, "Nanoc3::ItemRep#created? is no longer implemented"
37
+ end
38
+
39
+ # @deprecated
40
+ def modified
41
+ raise NotImplementedError, "Nanoc3::ItemRep#modified is no longer implemented"
42
+ end
43
+
44
+ # @deprecated
45
+ def modified?
46
+ raise NotImplementedError, "Nanoc3::ItemRep#modified? is no longer implemented"
47
+ end
48
+
49
+ # @deprecated
50
+ def written
51
+ raise NotImplementedError, "Nanoc3::ItemRep#written is no longer implemented"
52
+ end
53
+
54
+ # @deprecated
55
+ def written?
56
+ raise NotImplementedError, "Nanoc3::ItemRep#written? is no longer implemented"
57
+ end
58
+
59
+ end
60
+
61
+ # Contains all private methods. Mixed into {Nanoc3::ItemRep}.
62
+ module Private
63
+
64
+ # @return [Hash] A hash containing the assigns that will be used in the
65
+ # next filter or layout operation. The keys (symbols) will be made
66
+ # available during the next operation.
67
+ attr_accessor :assigns
68
+
69
+ # @return [Boolean] true if this representation has already been
70
+ # compiled during the current or last compilation session; false
71
+ # otherwise
72
+ #
73
+ # @api private
74
+ attr_accessor :compiled
75
+ alias_method :compiled?, :compiled
76
+
77
+ # @return [Hash<Symbol,String>] A hash containing the raw paths (paths
78
+ # including the path to the output directory and the filename) for all
79
+ # snapshots. The keys correspond with the snapshot names, and the
80
+ # values with the path.
81
+ #
82
+ # @api private
83
+ attr_accessor :raw_paths
84
+
85
+ # @return [Hash<Symbol,String>] A hash containing the paths for all
86
+ # snapshots. The keys correspond with the snapshot names, and the
87
+ # values with the path.
88
+ #
89
+ # @api private
90
+ attr_accessor :paths
91
+
92
+ # @return [Hash<Symbol,String>] A hash containing the paths to the
93
+ # temporary _files_ that filters write binary content to. This is only
94
+ # used when the item representation is binary. The keys correspond
95
+ # with the snapshot names, and the values with the filename. When
96
+ # writing the item representation, the file corresponding with the
97
+ # requested snapshot (usually `:last`) will be copied from
98
+ # `filenames[snapshot]` to `raw_paths[snapshot]`.
99
+ #
100
+ # @api private
101
+ attr_reader :temporary_filenames
102
+
103
+ # @return [Hash<Symbol,String>] A hash containing the content at all
104
+ # snapshots. The keys correspond with the snapshot names, and the
105
+ # values with the content.
106
+ #
107
+ # @api private
108
+ attr_accessor :content
109
+
110
+ # Writes the item rep's compiled content to the rep's output file.
111
+ #
112
+ # This method will send two notifications: one before writing the item
113
+ # representation, and one after. These notifications can be used for
114
+ # generating diffs, for example.
115
+ #
116
+ # @api private
117
+ #
118
+ # @param [String, nil] raw_path The raw path to write the compiled rep
119
+ # to. If nil, the default raw path will be used.
120
+ #
121
+ # @return [void]
122
+ def write(snapshot=:last)
123
+ # Get raw path
124
+ raw_path = self.raw_path(:snapshot => snapshot)
125
+ return if raw_path.nil?
126
+
127
+ # Create parent directory
128
+ FileUtils.mkdir_p(File.dirname(raw_path))
129
+
130
+ # Check if file will be created
131
+ is_created = !File.file?(raw_path)
132
+
133
+ # Calculate characteristics of old content
134
+ if File.file?(raw_path)
135
+ hash_old = Nanoc3::Checksummer.checksum_for_file(raw_path)
136
+ size_old = File.size(raw_path)
137
+ end
138
+
139
+ # Notify
140
+ Nanoc3::NotificationCenter.post(:will_write_rep, self, snapshot)
141
+
142
+ if self.binary?
143
+ # Calculate characteristics of new content
144
+ size_new = File.size(temporary_filenames[:last])
145
+ hash_new = Nanoc3::Checksummer.checksum_for_file(temporary_filenames[:last]) if size_old == size_new
146
+
147
+ # Check whether content was modified
148
+ is_modified = (size_old != size_new || hash_old != hash_new)
149
+
150
+ # Copy
151
+ if is_modified
152
+ FileUtils.cp(temporary_filenames[:last], raw_path)
153
+ end
154
+ else
155
+ # Check whether content was modified
156
+ is_modified = (!File.file?(raw_path) || File.read(raw_path) != @content[:last])
157
+
158
+ # Write
159
+ if is_modified
160
+ File.open(raw_path, 'w') { |io| io.write(@content[:last]) }
161
+ end
162
+ end
163
+
164
+ # Notify
165
+ Nanoc3::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
166
+ end
167
+
168
+ # Resets the compilation progress for this item representation. This is
169
+ # necessary when an unmet dependency is detected during compilation.
170
+ #
171
+ # @api private
172
+ #
173
+ # @return [void]
174
+ def forget_progress
175
+ initialize_content
176
+ end
177
+
178
+ # Returns the type of this object. Will always return `:item_rep`,
179
+ # because this is an item rep. For layouts, this method returns
180
+ # `:layout`.
181
+ #
182
+ # @api private
183
+ #
184
+ # @return [Symbol] :item_rep
185
+ def type
186
+ :item_rep
187
+ end
188
+
189
+ end
190
+
191
+ include Deprecated
192
+ include Private
193
+
194
+ # @return [Nanoc3::Item] The item to which this rep belongs
195
+ attr_reader :item
196
+
197
+ # @return [Symbol] The representation's unique name
198
+ attr_reader :name
199
+
200
+ # @return [Boolean] true if this rep is currently binary; false otherwise
201
+ attr_reader :binary
202
+ alias_method :binary?, :binary
203
+
204
+ # Creates a new item representation for the given item.
205
+ #
206
+ # @param [Nanoc3::Item] item The item to which the new representation will
207
+ # belong.
208
+ #
209
+ # @param [Symbol] name The unique name for the new item representation.
210
+ def initialize(item, name)
211
+ # Set primary attributes
212
+ @item = item
213
+ @name = name
214
+
215
+ # Set binary
216
+ @binary = @item.binary?
217
+
218
+ # Set default attributes
219
+ @raw_paths = {}
220
+ @paths = {}
221
+ @assigns = {}
222
+ initialize_content
223
+
224
+ # Reset flags
225
+ @compiled = false
226
+ end
227
+
228
+ # Returns the compiled content from a given snapshot.
229
+ #
230
+ # @option params [String] :snapshot The name of the snapshot from which to
231
+ # fetch the compiled content. By default, the returned compiled content
232
+ # will be the content compiled right before the first layout call (if
233
+ # any).
234
+ #
235
+ # @return [String] The compiled content at the given snapshot (or the
236
+ # default snapshot if no snapshot is specified)
237
+ def compiled_content(params={})
238
+ # Notify
239
+ Nanoc3::NotificationCenter.post(:visit_started, self.item)
240
+ Nanoc3::NotificationCenter.post(:visit_ended, self.item)
241
+
242
+ # Require compilation
243
+ raise Nanoc3::Errors::UnmetDependency.new(self) if !compiled? && !params[:force]
244
+
245
+ # Get name of last pre-layout snapshot
246
+ snapshot_name = params[:snapshot]
247
+ if @content[:pre]
248
+ snapshot_name ||= :pre
249
+ else
250
+ snapshot_name ||= :last
251
+ end
252
+
253
+ # Check presence of snapshot
254
+ if @content[snapshot_name].nil?
255
+ warn(('-' * 78 + "\nWARNING: The “#{self.item.identifier}” item (rep “#{self.name}”) does not have the requested snapshot named #{snapshot_name.inspect}.\n\n* Make sure that you are requesting the correct snapshot.\n* It is not possible to request the compiled content of a binary item representation; if this item is marked as binary even though you believe it should be textual, you may need to add the extension of this item to the site configuration’s `text_extensions` array.\n" + '-' * 78).make_compatible_with_env)
256
+ end
257
+
258
+ # Get content
259
+ @content[snapshot_name]
260
+ end
261
+
262
+ # Checks whether content exists at a given snapshot.
263
+ #
264
+ # @return [Boolean] True if content exists for the snapshot with the
265
+ # given name, false otherwise
266
+ def has_snapshot?(snapshot_name)
267
+ !@content[snapshot_name].nil?
268
+ end
269
+
270
+ # Returns the item rep’s raw path. It includes the path to the output
271
+ # directory and the full filename.
272
+ #
273
+ # @option params [Symbol] :snapshot (:last) The snapshot for which the
274
+ # path should be returned
275
+ #
276
+ # @return [String] The item rep’s path
277
+ def raw_path(params={})
278
+ snapshot_name = params[:snapshot] || :last
279
+ @raw_paths[snapshot_name]
280
+ end
281
+
282
+ # Returns the item rep’s path, as used when being linked to. It starts
283
+ # with a slash and it is relative to the output directory. It does not
284
+ # include the path to the output directory. It will not include the
285
+ # filename if the filename is an index filename.
286
+ #
287
+ # @option params [Symbol] :snapshot (:last) The snapshot for which the
288
+ # path should be returned
289
+ #
290
+ # @return [String] The item rep’s path
291
+ def path(params={})
292
+ snapshot_name = params[:snapshot] || :last
293
+ @paths[snapshot_name]
294
+ end
295
+
296
+ # Runs the item content through the given filter with the given arguments.
297
+ # This method will replace the content of the `:last` snapshot with the
298
+ # filtered content of the last snapshot.
299
+ #
300
+ # This method is supposed to be called only in a compilation rule block
301
+ # (see {Nanoc3::CompilerDSL#compile}).
302
+ #
303
+ # @see Nanoc3::ItemRepProxy#filter
304
+ #
305
+ # @param [Symbol] filter_name The name of the filter to run the item
306
+ # representations' content through
307
+ #
308
+ # @param [Hash] filter_args The filter arguments that should be passed to
309
+ # the filter's #run method
310
+ #
311
+ # @return [void]
312
+ def filter(filter_name, filter_args={})
313
+ # Get filter class
314
+ klass = filter_named(filter_name)
315
+ raise Nanoc3::Errors::UnknownFilter.new(filter_name) if klass.nil?
316
+
317
+ # Check whether filter can be applied
318
+ if klass.from_binary? && !self.binary?
319
+ raise Nanoc3::Errors::CannotUseBinaryFilter.new(self, klass)
320
+ elsif !klass.from_binary? && self.binary?
321
+ raise Nanoc3::Errors::CannotUseTextualFilter.new(self, klass)
322
+ end
323
+
324
+ # Notify start
325
+ Nanoc3::NotificationCenter.post(:filtering_started, self, filter_name)
326
+
327
+ # Create filter
328
+ filter = klass.new(assigns)
329
+
330
+ # Run filter
331
+ source = self.binary? ? temporary_filenames[:last] : @content[:last]
332
+ result = filter.run(source, filter_args)
333
+ if klass.to_binary?
334
+ temporary_filenames[:last] = filter.output_filename
335
+ else
336
+ @content[:last] = result
337
+ end
338
+ @binary = klass.to_binary?
339
+
340
+ # Check whether file was written
341
+ if self.binary? && !File.file?(filter.output_filename)
342
+ raise RuntimeError,
343
+ "The #{filter_name.inspect} filter did not write anything to the required output file, #{filter.output_filename}."
344
+ end
345
+
346
+ # Create snapshot
347
+ snapshot(@content[:post] ? :post : :pre, :final => false) unless self.binary?
348
+ ensure
349
+ # Notify end
350
+ Nanoc3::NotificationCenter.post(:filtering_ended, self, filter_name)
351
+ end
352
+
353
+ # Lays out the item using the given layout. This method will replace the
354
+ # content of the `:last` snapshot with the laid out content of the last
355
+ # snapshot.
356
+ #
357
+ # This method is supposed to be called only in a compilation rule block
358
+ # (see {Nanoc3::CompilerDSL#compile}).
359
+ #
360
+ # @see Nanoc3::ItemRepProxy#layout
361
+ #
362
+ # @param [Nanoc3::Layout] layout The layout to use
363
+ #
364
+ # @param [Symbol] filter_name The name of the filter to layout the item
365
+ # representations' content with
366
+ #
367
+ # @param [Hash] filter_args The filter arguments that should be passed to
368
+ # the filter's #run method
369
+ #
370
+ # @return [void]
371
+ def layout(layout, filter_name, filter_args)
372
+ # Check whether item can be laid out
373
+ raise Nanoc3::Errors::CannotLayoutBinaryItem.new(self) if self.binary?
374
+
375
+ # Create "pre" snapshot
376
+ if @content[:post].nil?
377
+ snapshot(:pre, :final => true)
378
+ end
379
+
380
+ # Create filter
381
+ klass = filter_named(filter_name)
382
+ raise Nanoc3::Errors::UnknownFilter.new(filter_name) if klass.nil?
383
+ filter = klass.new(assigns.merge({ :layout => layout }))
384
+
385
+ # Visit
386
+ Nanoc3::NotificationCenter.post(:visit_started, layout)
387
+ Nanoc3::NotificationCenter.post(:visit_ended, layout)
388
+
389
+ # Notify start
390
+ Nanoc3::NotificationCenter.post(:processing_started, layout)
391
+ Nanoc3::NotificationCenter.post(:filtering_started, self, filter_name)
392
+
393
+ # Layout
394
+ @content[:last] = filter.run(layout.raw_content, filter_args)
395
+
396
+ # Create "post" snapshot
397
+ snapshot(:post, :final => false)
398
+ ensure
399
+ # Notify end
400
+ Nanoc3::NotificationCenter.post(:filtering_ended, self, filter_name)
401
+ Nanoc3::NotificationCenter.post(:processing_ended, layout)
402
+ end
403
+
404
+ # Creates a snapshot of the current compiled item content.
405
+ #
406
+ # @param [Symbol] snapshot_name The name of the snapshot to create
407
+ #
408
+ # @option params [Boolean] :final (true) True if this is the final time
409
+ # the snapshot will be updated; false if it is a non-final moving
410
+ # snapshot (such as `:pre`, `:post` or `:last`)
411
+ #
412
+ # @return [void]
413
+ def snapshot(snapshot_name, params={})
414
+ # Parse params
415
+ params[:final] = true if !params.has_key?(:final)
416
+
417
+ # Create snapshot
418
+ @content[snapshot_name] = @content[:last] unless self.binary?
419
+
420
+ # Write
421
+ write(snapshot_name) if params[:final]
422
+ end
423
+
424
+ def inspect
425
+ "<#{self.class}:0x#{self.object_id.to_s(16)} name=#{self.name} binary=#{self.binary?} raw_path=#{self.raw_path} item.identifier=#{self.item.identifier}>"
426
+ end
427
+
428
+ private
429
+
430
+ def initialize_content
431
+ # Initialize content and filenames
432
+ if self.binary?
433
+ @temporary_filenames = { :last => @item.raw_filename }
434
+ @content = {}
435
+ else
436
+ @content = { :last => @item.raw_content }
437
+ @temporary_filenames = {}
438
+ end
439
+ end
440
+
441
+ def filter_named(name)
442
+ Nanoc3::Filter.named(name)
443
+ end
444
+
445
+ end
446
+
447
+ end
@@ -5,11 +5,6 @@ module Nanoc3
5
5
  # Nanoc3::CodeSnippet represent a piece of custom code of a nanoc site.
6
6
  class CodeSnippet
7
7
 
8
- # The {Nanoc3::Site} this code snippet belongs to.
9
- #
10
- # @return [Nanoc3::Site]
11
- attr_accessor :site
12
-
13
8
  # A string containing the actual code in this code snippet.
14
9
  #
15
10
  # @return [String]
@@ -20,13 +15,6 @@ module Nanoc3
20
15
  # @return [String]
21
16
  attr_reader :filename
22
17
 
23
- # @return [String] The checksum of this code snippet that was in effect
24
- # during the previous site compilation
25
- attr_accessor :old_checksum
26
-
27
- # @return [String] The current, up-to-date checksum of this code snippet
28
- attr_reader :new_checksum
29
-
30
18
  # Creates a new code snippet.
31
19
  #
32
20
  # @param [String] data The raw source code which will be executed before
@@ -40,18 +28,14 @@ module Nanoc3
40
28
  #
41
29
  # @option params [Time, nil] :mtime (nil) The time when this code snippet
42
30
  # was last modified
43
- #
44
- # @option params [String, nil] :checksum (nil) The current, up-to-date
45
- # checksum of this code snippet
46
31
  def initialize(data, filename, params=nil)
47
- # Get mtime and checksum
32
+ # Parse params
48
33
  params ||= {}
49
34
  params = { :mtime => params } if params.is_a?(Time)
50
- @new_checksum = params[:checksum]
51
- @mtime = params[:mtime]
52
35
 
53
36
  @data = data
54
37
  @filename = filename
38
+ @mtime = params[:mtime]
55
39
  end
56
40
 
57
41
  # Loads the code by executing it.
@@ -61,10 +45,11 @@ module Nanoc3
61
45
  eval(@data, TOPLEVEL_BINDING, @filename)
62
46
  end
63
47
 
64
- # @return [Boolean] true if the code snippet was modified since it was
65
- # last compiled, false otherwise
66
- def outdated?
67
- !self.old_checksum || !self.new_checksum || self.new_checksum != self.old_checksum
48
+ # Returns an object that can be used for uniquely identifying objects.
49
+ #
50
+ # @return [Object] An unique reference to this object
51
+ def reference
52
+ [ :code_snippet, filename ]
68
53
  end
69
54
 
70
55
  end
@@ -7,25 +7,25 @@ module Nanoc3
7
7
  # store the modification time to speed up compilation.
8
8
  class Item
9
9
 
10
- # @return [Nanoc3::Site] The site this item belongs to
11
- attr_accessor :site
12
-
13
10
  # @return [Hash] This item's attributes
14
11
  attr_accessor :attributes
15
12
 
13
+ # A string that uniquely identifies an item in a site.
14
+ #
15
+ # Identifiers start and end with a slash. They are comparable to paths on
16
+ # the filesystem, with the difference that file system paths usually do
17
+ # not have a trailing slash. The item hierarchy (parent and children of
18
+ # items) is determined by the item identifier.
19
+ #
20
+ # The root page (the home page) has the identifier “/”, which means
21
+ # that it is the ancestor of all other items.
22
+ #
16
23
  # @return [String] This item's identifier
17
24
  attr_accessor :identifier
18
25
 
19
26
  # @return [Time] The time where this item was last modified
20
27
  attr_reader :mtime
21
28
 
22
- # @return [String] The checksum of this item that was in effect during the
23
- # previous site compilation
24
- attr_accessor :old_checksum
25
-
26
- # @return [String] The current, up-to-date checksum of this item
27
- attr_reader :new_checksum
28
-
29
29
  # @return [Array<Nanoc3::ItemRep>] This item’s list of item reps
30
30
  attr_reader :reps
31
31
 
@@ -44,11 +44,6 @@ module Nanoc3
44
44
  # @return [Array<Nanoc3::Item>] The child items of this item
45
45
  attr_accessor :children
46
46
 
47
- # @return [Boolean] Whether or not this item is outdated because of its
48
- # dependencies are outdated
49
- attr_accessor :outdated_due_to_dependencies
50
- alias_method :outdated_due_to_dependencies?, :outdated_due_to_dependencies
51
-
52
47
  # Creates a new item with the given content or filename, attributes and
53
48
  # identifier.
54
49
  #
@@ -69,18 +64,17 @@ module Nanoc3
69
64
  #
70
65
  # @option params [Symbol, nil] :binary (true) Whether or not this item is
71
66
  # binary
72
- #
73
- # @option params [String, nil] :checksum (nil) The current, up-to-date
74
- # checksum of this item
75
67
  def initialize(raw_content_or_raw_filename, attributes, identifier, params=nil)
76
- # Get mtime and checksum
68
+ # Parse params
77
69
  params ||= {}
78
70
  params = { :mtime => params } if params.is_a?(Time)
79
- @new_checksum = params[:checksum]
80
- @mtime = params[:mtime]
71
+ params[:binary] = false unless params.has_key?(:binary)
72
+
73
+ # Get mtime
74
+ @mtime = params[:mtime]
81
75
 
82
76
  # Get type and raw content or raw filename
83
- @is_binary = params.has_key?(:binary) ? params[:binary] : false
77
+ @is_binary = params[:binary]
84
78
  if @is_binary
85
79
  @raw_filename = raw_content_or_raw_filename
86
80
  else
@@ -186,17 +180,11 @@ module Nanoc3
186
180
  !!@is_binary
187
181
  end
188
182
 
189
- # Determines whether this item (or rather, its reps) is outdated and
190
- # should be recompiled (or rather, its reps should be recompiled).
191
- #
192
- # @return [Boolean] true if any reps are outdated; false otherwise.
193
- def outdated?
194
- @reps.any? { |r| r.outdated? }
195
- end
196
-
197
183
  # Returns the type of this object. Will always return `:item`, because
198
184
  # this is an item. For layouts, this method returns `:layout`.
199
185
  #
186
+ # @api private
187
+ #
200
188
  # @return [Symbol] :item
201
189
  def type
202
190
  :item
@@ -204,6 +192,8 @@ module Nanoc3
204
192
 
205
193
  # Returns an object that can be used for uniquely identifying objects.
206
194
  #
195
+ # @api private
196
+ #
207
197
  # @return [Object] An unique reference to this object
208
198
  def reference
209
199
  [ type, self.identifier ]
@@ -6,9 +6,6 @@ module Nanoc3
6
6
  # identifier and a modification time (to speed up compilation).
7
7
  class Layout
8
8
 
9
- # @return [Nanoc3::Site] The site this layout belongs to
10
- attr_accessor :site
11
-
12
9
  # @return [String] The raw content of this layout
13
10
  attr_reader :raw_content
14
11
 
@@ -22,18 +19,6 @@ module Nanoc3
22
19
  # @return [Time] The time where this layout was last modified
23
20
  attr_reader :mtime
24
21
 
25
- # @return [String] The checksum of this layout that was in effect during
26
- # the previous site compilation
27
- attr_accessor :old_checksum
28
-
29
- # @return [String] The current, up-to-date checksum of this layout
30
- attr_reader :new_checksum
31
-
32
- # @return [Boolean] Whether or not this layout is outdated because of its
33
- # dependencies are outdated
34
- attr_accessor :outdated_due_to_dependencies
35
- alias_method :outdated_due_to_dependencies?, :outdated_due_to_dependencies
36
-
37
22
  # Creates a new layout.
38
23
  #
39
24
  # @param [String] raw_content The raw content of this layout.
@@ -48,14 +33,12 @@ module Nanoc3
48
33
  #
49
34
  # @option params [Time, nil] :mtime (nil) The time when this layout was
50
35
  # last modified
51
- #
52
- # @option params [String, nil] :checksum (nil) The current, up-to-date
53
- # checksum of this layout
54
36
  def initialize(raw_content, attributes, identifier, params=nil)
55
- # Get mtime and checksum
37
+ # Parse params
56
38
  params ||= {}
57
39
  params = { :mtime => params } if params.is_a?(Time)
58
- @new_checksum = params[:checksum]
40
+
41
+ # Get mtime
59
42
  @mtime = params[:mtime]
60
43
 
61
44
  @raw_content = raw_content
@@ -72,15 +55,11 @@ module Nanoc3
72
55
  @attributes[key]
73
56
  end
74
57
 
75
- # @return [Boolean] true if the layout was modified since the site was
76
- # last compiled, false otherwise
77
- def outdated?
78
- !self.old_checksum || !self.new_checksum || self.new_checksum != self.old_checksum
79
- end
80
-
81
58
  # Returns the type of this object. Will always return `:layout`, because
82
59
  # this is a layout. For items, this method returns `:item`.
83
60
  #
61
+ # @api private
62
+ #
84
63
  # @return [Symbol] :layout
85
64
  def type
86
65
  :layout
@@ -88,6 +67,8 @@ module Nanoc3
88
67
 
89
68
  # Returns an object that can be used for uniquely identifying objects.
90
69
  #
70
+ # @api private
71
+ #
91
72
  # @return [Object] An unique reference to this object
92
73
  def reference
93
74
  [ type, self.identifier ]