nanoc 4.0.0b3 → 4.0.0b4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +4 -2
  4. data/NEWS.md +10 -0
  5. data/TODO.md +15 -0
  6. data/lib/nanoc/base.rb +4 -27
  7. data/lib/nanoc/base/checksummer.rb +69 -19
  8. data/lib/nanoc/base/compilation/compiler.rb +14 -12
  9. data/lib/nanoc/base/compilation/compiler_dsl.rb +2 -0
  10. data/lib/nanoc/base/compilation/filter.rb +4 -2
  11. data/lib/nanoc/base/compilation/outdatedness_checker.rb +7 -7
  12. data/lib/nanoc/base/compilation/rule.rb +5 -6
  13. data/lib/nanoc/base/compilation/rule_context.rb +16 -34
  14. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
  15. data/lib/nanoc/base/compilation/rules_collection.rb +4 -10
  16. data/lib/nanoc/base/context.rb +2 -0
  17. data/lib/nanoc/base/core_ext/array.rb +0 -10
  18. data/lib/nanoc/base/core_ext/hash.rb +0 -10
  19. data/lib/nanoc/base/core_ext/pathname.rb +0 -9
  20. data/lib/nanoc/base/core_ext/string.rb +0 -10
  21. data/lib/nanoc/base/entities.rb +5 -0
  22. data/lib/nanoc/base/entities/content.rb +86 -0
  23. data/lib/nanoc/base/entities/document.rb +56 -0
  24. data/lib/nanoc/base/{source_data → entities}/identifier.rb +12 -1
  25. data/lib/nanoc/base/entities/layout.rb +8 -0
  26. data/lib/nanoc/base/{pattern.rb → entities/pattern.rb} +0 -0
  27. data/lib/nanoc/base/errors.rb +2 -1
  28. data/lib/nanoc/base/result_data/item_rep.rb +13 -278
  29. data/lib/nanoc/base/services.rb +5 -0
  30. data/lib/nanoc/base/services/executor.rb +141 -0
  31. data/lib/nanoc/base/services/item_rep_writer.rb +40 -0
  32. data/lib/nanoc/base/{notification_center.rb → services/notification_center.rb} +0 -0
  33. data/lib/nanoc/base/services/recording_executor.rb +41 -0
  34. data/lib/nanoc/base/{temp_filename_factory.rb → services/temp_filename_factory.rb} +0 -0
  35. data/lib/nanoc/base/source_data/code_snippet.rb +0 -6
  36. data/lib/nanoc/base/source_data/data_source.rb +4 -3
  37. data/lib/nanoc/base/source_data/item.rb +23 -213
  38. data/lib/nanoc/base/source_data/site.rb +0 -1
  39. data/lib/nanoc/base/views.rb +18 -0
  40. data/lib/nanoc/base/views/config.rb +1 -1
  41. data/lib/nanoc/base/views/item.rb +8 -73
  42. data/lib/nanoc/base/views/item_rep.rb +9 -0
  43. data/lib/nanoc/base/views/item_rep_collection.rb +17 -0
  44. data/lib/nanoc/base/views/layout.rb +1 -40
  45. data/lib/nanoc/base/views/mixins/document.rb +76 -0
  46. data/lib/nanoc/base/views/mixins/mutable_document.rb +22 -0
  47. data/lib/nanoc/base/views/mutable_identifiable_collection.rb +1 -1
  48. data/lib/nanoc/base/views/mutable_item.rb +1 -18
  49. data/lib/nanoc/base/views/mutable_item_collection.rb +6 -2
  50. data/lib/nanoc/base/views/mutable_layout.rb +1 -8
  51. data/lib/nanoc/cli/commands/compile.rb +1 -2
  52. data/lib/nanoc/cli/commands/create-site.rb +5 -5
  53. data/lib/nanoc/cli/commands/show-data.rb +11 -1
  54. data/lib/nanoc/data_sources/filesystem.rb +17 -10
  55. data/lib/nanoc/helpers/capturing.rb +1 -2
  56. data/lib/nanoc/helpers/filtering.rb +13 -1
  57. data/lib/nanoc/helpers/rendering.rb +4 -2
  58. data/lib/nanoc/version.rb +1 -1
  59. data/test/base/core_ext/array_spec.rb +0 -7
  60. data/test/base/core_ext/hash_spec.rb +0 -13
  61. data/test/base/core_ext/pathname_spec.rb +0 -33
  62. data/test/base/core_ext/string_spec.rb +0 -10
  63. data/test/base/test_compiler_dsl.rb +3 -3
  64. data/test/base/test_data_source.rb +2 -2
  65. data/test/base/test_item.rb +5 -129
  66. data/test/base/test_item_rep.rb +26 -558
  67. data/test/base/test_layout.rb +2 -26
  68. data/test/base/test_rule.rb +3 -3
  69. data/test/base/test_rule_context.rb +34 -15
  70. data/test/data_sources/test_filesystem.rb +2 -2
  71. data/test/data_sources/test_filesystem_unified.rb +39 -33
  72. data/test/extra/checking/checks/test_html.rb +0 -1
  73. data/test/extra/checking/checks/test_mixed_content.rb +3 -3
  74. data/test/extra/deployers/test_fog.rb +24 -24
  75. data/test/filters/test_less.rb +4 -4
  76. data/test/filters/test_sass.rb +10 -5
  77. data/test/filters/test_xsl.rb +6 -0
  78. data/test/helpers/test_capturing.rb +0 -1
  79. data/test/helpers/test_filtering.rb +5 -19
  80. data/test/helpers/test_tagging.rb +6 -6
  81. metadata +18 -11
  82. data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -109
  83. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -97
  84. data/lib/nanoc/base/source_data/layout.rb +0 -111
  85. data/test/base/checksummer_spec.rb +0 -256
  86. data/test/base/test_item_rep_recorder_proxy.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1916118f3f4affe429105d6b7cd243cef3ad7f79
4
- data.tar.gz: 6cb2a58542bc45f676a50b9dca5f681fb524752a
3
+ metadata.gz: c6a2272e514cd909fa601f4fea595a3827b82ae4
4
+ data.tar.gz: d2817ebcf5353f903262f858b7ce2b7dbcd995e6
5
5
  SHA512:
6
- metadata.gz: 199276b80c83ae39093ba9169360b2ae345e80fb1aa1891d8b7fc5569261c4fc2c05b60f2e553c003a72448649bf16f75029f6520d82bde27048a49015330345
7
- data.tar.gz: 46748f7f40700073a17e76fd2f47ad5dbc287c7156220736d2bc6438248c88f2dd4b5047f7ac839073cc110fff189607345369e3c2fdf4e230286a7ed7d1735a
6
+ metadata.gz: bbaeae81947c39944044cb73ac30d7347c5a204ccfe70843f7796e7aa17d5def67be3fc1a77f65abca4f64ce704cf81dff123ced4c08e98f1b7e124841d96d63
7
+ data.tar.gz: e58c103c1bbf728768f349d286b1c299524513b20bff9a0621548b861eeba906b9cb4582a01f688ef6b8bc6318aefa7958166b58ba7db4187a8e8d61f9223745
data/Gemfile CHANGED
@@ -12,6 +12,7 @@ gem 'compass'
12
12
  gem 'coffee-script'
13
13
  gem 'coveralls', require: false
14
14
  gem 'erubis'
15
+ gem 'fakefs'
15
16
  gem 'fog'
16
17
  gem 'haml'
17
18
  gem 'handlebars', platforms: :ruby
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanoc (4.0.0b3)
4
+ nanoc (4.0.0b4)
5
5
  cri (~> 2.3)
6
6
 
7
7
  GEM
@@ -48,6 +48,7 @@ GEM
48
48
  erubis (2.7.0)
49
49
  excon (0.45.3)
50
50
  execjs (2.5.2)
51
+ fakefs (0.6.7)
51
52
  ffi (1.9.8)
52
53
  fission (0.5.0)
53
54
  CFPropertyList (~> 2.2)
@@ -289,6 +290,7 @@ DEPENDENCIES
289
290
  compass
290
291
  coveralls
291
292
  erubis
293
+ fakefs
292
294
  fog
293
295
  haml
294
296
  handlebars
@@ -327,4 +329,4 @@ DEPENDENCIES
327
329
  yuicompressor
328
330
 
329
331
  BUNDLED WITH
330
- 1.10.2
332
+ 1.10.3
data/NEWS.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # nanoc news
2
2
 
3
+ ## 4.0.0b4 (2015-06-10)
4
+
5
+ Fixes:
6
+
7
+ * Added missing `#ext` method to identifiers (#612)
8
+ * Fixed issue where identifiers would have the wrong extension (#611)
9
+ * Fixed rule context exposing entities rather than views (#614, #615)
10
+ * Fixed `#key?` and `#fetch` not being available on layout views (#618)
11
+ * Fixed `#update_attributes` not being available on mutable layout views (#619)
12
+
3
13
  ## 4.0.0b3 (2015-05-31)
4
14
 
5
15
  Changes:
data/TODO.md ADDED
@@ -0,0 +1,15 @@
1
+ # To do
2
+
3
+ ## Ideas
4
+
5
+ * snapshots [name, array] is weird
6
+ * binary snapshots could be possible
7
+ * binary layotus could be possible
8
+
9
+ ## Removing `forget_progress`
10
+
11
+ This means not storing compiled content inside item reps anymore.
12
+
13
+ Compiler could store it, and `snapshot` could move temporary compiled content (like `:last`) and crystallize it in a more permanent store (even in-memory).
14
+
15
+ CompiledContent class, which is basically snapshot -> Content.
data/lib/nanoc/base.rb CHANGED
@@ -2,51 +2,26 @@ module Nanoc
2
2
  require 'nanoc/base/core_ext'
3
3
 
4
4
  autoload 'Error', 'nanoc/base/error'
5
-
6
5
  autoload 'DataSource', 'nanoc/base/source_data/data_source'
7
- autoload 'Identifier', 'nanoc/base/source_data/identifier'
8
-
9
- autoload 'ConfigView', 'nanoc/base/views/config'
10
- autoload 'IdentifiableCollectionView', 'nanoc/base/views/identifiable_collection'
11
- autoload 'ItemView', 'nanoc/base/views/item'
12
- autoload 'ItemRepCollectionView', 'nanoc/base/views/item_rep_collection'
13
- autoload 'ItemRepView', 'nanoc/base/views/item_rep'
14
- autoload 'ItemCollectionView', 'nanoc/base/views/item_collection'
15
- autoload 'LayoutView', 'nanoc/base/views/layout'
16
- autoload 'LayoutCollectionView', 'nanoc/base/views/layout_collection'
17
- autoload 'SiteView', 'nanoc/base/views/site'
18
-
19
- autoload 'MutableIdentifiableCollectionView', 'nanoc/base/views/mutable_identifiable_collection'
20
- autoload 'MutableConfigView', 'nanoc/base/views/mutable_config'
21
- autoload 'MutableItemView', 'nanoc/base/views/mutable_item'
22
- autoload 'MutableItemCollectionView', 'nanoc/base/views/mutable_item_collection'
23
- autoload 'MutableLayoutView', 'nanoc/base/views/mutable_layout'
24
- autoload 'MutableLayoutCollectionView', 'nanoc/base/views/mutable_layout_collection'
25
-
26
6
  autoload 'Filter', 'nanoc/base/compilation/filter'
27
7
  end
28
8
 
29
9
  # @api private
30
10
  module Nanoc::Int
31
- require_relative 'base/pattern'
32
-
33
11
  # Load helper classes
34
12
  autoload 'Context', 'nanoc/base/context'
35
13
  autoload 'Checksummer', 'nanoc/base/checksummer'
36
14
  autoload 'DirectedGraph', 'nanoc/base/directed_graph'
37
15
  autoload 'Errors', 'nanoc/base/errors'
38
16
  autoload 'Memoization', 'nanoc/base/memoization'
39
- autoload 'NotificationCenter', 'nanoc/base/notification_center'
40
17
  autoload 'PluginRegistry', 'nanoc/base/plugin_registry'
41
18
  autoload 'Store', 'nanoc/base/store'
42
- autoload 'TempFilenameFactory', 'nanoc/base/temp_filename_factory'
43
19
  autoload 'IdentifiableCollection', 'nanoc/base/identifiable_collection'
44
20
 
45
21
  # Load source data classes
46
22
  autoload 'CodeSnippet', 'nanoc/base/source_data/code_snippet'
47
23
  autoload 'Configuration', 'nanoc/base/source_data/configuration'
48
24
  autoload 'Item', 'nanoc/base/source_data/item'
49
- autoload 'Layout', 'nanoc/base/source_data/layout'
50
25
  autoload 'Site', 'nanoc/base/source_data/site'
51
26
 
52
27
  # Load result data classes
@@ -58,8 +33,6 @@ module Nanoc::Int
58
33
  autoload 'Compiler', 'nanoc/base/compilation/compiler'
59
34
  autoload 'CompilerDSL', 'nanoc/base/compilation/compiler_dsl'
60
35
  autoload 'DependencyTracker', 'nanoc/base/compilation/dependency_tracker'
61
- autoload 'ItemRepProxy', 'nanoc/base/compilation/item_rep_proxy'
62
- autoload 'ItemRepRecorderProxy', 'nanoc/base/compilation/item_rep_recorder_proxy'
63
36
  autoload 'OutdatednessChecker', 'nanoc/base/compilation/outdatedness_checker'
64
37
  autoload 'OutdatednessReasons', 'nanoc/base/compilation/outdatedness_reasons'
65
38
  autoload 'Rule', 'nanoc/base/compilation/rule'
@@ -68,3 +41,7 @@ module Nanoc::Int
68
41
  autoload 'RuleMemoryStore', 'nanoc/base/compilation/rule_memory_store'
69
42
  autoload 'RulesCollection', 'nanoc/base/compilation/rules_collection'
70
43
  end
44
+
45
+ require_relative 'base/entities'
46
+ require_relative 'base/services'
47
+ require_relative 'base/views'
@@ -6,63 +6,111 @@ module Nanoc::Int
6
6
  #
7
7
  # @api private
8
8
  class Checksummer
9
+ class VerboseDigest
10
+ def initialize
11
+ @str = ''
12
+ end
13
+
14
+ def update(str)
15
+ @str << str
16
+ end
17
+
18
+ def to_s
19
+ @str
20
+ end
21
+ end
22
+
23
+ class CompactDigest
24
+ def initialize
25
+ @digest = Digest::SHA1.new
26
+ end
27
+
28
+ def update(str)
29
+ @digest.update(str)
30
+ end
31
+
32
+ def to_s
33
+ @digest.base64digest
34
+ end
35
+ end
36
+
9
37
  class << self
10
38
  # @param obj The object to create a checksum for
11
39
  #
12
40
  # @return [String] The digest
13
- def calc(obj)
14
- digest = Digest::SHA1.new
41
+ def calc(obj, digest_class = CompactDigest)
42
+ digest = digest_class.new
15
43
  update(obj, digest)
16
- digest.base64digest
44
+ digest.to_s
17
45
  end
18
46
 
19
47
  private
20
48
 
21
49
  def update(obj, digest, visited = Set.new)
22
50
  digest.update(obj.class.to_s)
51
+ digest.update('<')
23
52
 
24
53
  if visited.include?(obj)
25
- digest.update('recur')
54
+ digest.update('recur>')
26
55
  return
27
56
  end
28
57
 
29
58
  case obj
30
- when String
59
+ when ::String
31
60
  digest.update(obj)
32
- when Array
61
+ when ::Symbol
62
+ digest.update(obj.to_s)
63
+ when nil, true, false
64
+ when ::Array
33
65
  obj.each do |el|
34
- digest.update('elem')
35
66
  update(el, digest, visited + [obj])
67
+ digest.update(',')
36
68
  end
37
- when Hash
69
+ when ::Hash
38
70
  obj.each do |key, value|
39
- digest.update('key')
40
71
  update(key, digest, visited + [obj])
41
- digest.update('value')
72
+ digest.update('=')
42
73
  update(value, digest, visited + [obj])
74
+ digest.update(',')
43
75
  end
44
- when Pathname
76
+ when ::Pathname
45
77
  filename = obj.to_s
46
78
  if File.exist?(filename)
47
79
  stat = File.stat(filename)
48
- digest.update(stat.size.to_s + '-' + stat.mtime.utc.to_s)
80
+ digest.update(stat.size.to_s + '-' + stat.mtime.to_i.to_s)
49
81
  else
50
82
  digest.update('???')
51
83
  end
84
+ when Time
85
+ digest.update(obj.to_i.to_s)
86
+ when Numeric
87
+ digest.update(obj.to_s)
88
+ when Nanoc::Identifier
89
+ update(obj.to_s, digest)
52
90
  when Nanoc::Int::RulesCollection
53
91
  update(obj.data, digest)
54
92
  when Nanoc::Int::CodeSnippet
55
93
  update(obj.data, digest)
94
+ when Nanoc::Int::TextualContent
95
+ update(obj.string, digest)
96
+ when Nanoc::Int::BinaryContent
97
+ update(Pathname.new(obj.filename), digest)
56
98
  when Nanoc::Int::Item, Nanoc::Int::Layout
57
- digest.update('content')
58
- if obj.respond_to?(:binary?) && obj.binary?
59
- update(Pathname.new(obj.raw_filename), digest)
60
- else
61
- update(obj.raw_content, digest)
62
- end
99
+ digest.update('content=')
100
+ update(obj.content, digest)
63
101
 
64
- digest.update('attributes')
102
+ digest.update(',attributes=')
65
103
  update(obj.attributes, digest, visited + [obj])
104
+
105
+ digest.update(',identifier=')
106
+ update(obj.identifier, digest)
107
+ when Nanoc::ItemView, Nanoc::LayoutView, Nanoc::ConfigView, Nanoc::IdentifiableCollectionView
108
+ update(obj.unwrap, digest)
109
+ when Nanoc::Int::IdentifiableCollection
110
+ obj.each do |el|
111
+ update(el, digest, visited + [obj])
112
+ digest.update(',')
113
+ end
66
114
  else
67
115
  data = begin
68
116
  Marshal.dump(obj)
@@ -72,6 +120,8 @@ module Nanoc::Int
72
120
 
73
121
  digest.update(data)
74
122
  end
123
+
124
+ digest.update('>')
75
125
  end
76
126
  end
77
127
  end
@@ -91,7 +91,7 @@ module Nanoc::Int
91
91
  Nanoc::Int::TempFilenameFactory.instance.cleanup(
92
92
  Nanoc::Filter::TMP_BINARY_ITEMS_DIR)
93
93
  Nanoc::Int::TempFilenameFactory.instance.cleanup(
94
- Nanoc::Int::ItemRep::TMP_TEXT_ITEMS_DIR)
94
+ Nanoc::Int::ItemRepWriter::TMP_TEXT_ITEMS_DIR)
95
95
  end
96
96
 
97
97
  # @group Private instance methods
@@ -163,7 +163,7 @@ module Nanoc::Int
163
163
 
164
164
  # Calculate checksums
165
165
  objects.each do |obj|
166
- checksum_store[obj] = obj.__nanoc_checksum
166
+ checksum_store[obj] = Nanoc::Int::Checksummer.calc(obj)
167
167
  end
168
168
 
169
169
  # Store
@@ -228,7 +228,7 @@ module Nanoc::Int
228
228
 
229
229
  rules.each_pair do |snapshot, rule|
230
230
  # Get basic path by applying matching rule
231
- basic_path = rule.apply_to(rep, compiler: self)
231
+ basic_path = rule.apply_to(rep, executor: nil, compiler: self)
232
232
  next if basic_path.nil?
233
233
  if basic_path !~ %r{^/}
234
234
  raise "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash."
@@ -260,9 +260,9 @@ module Nanoc::Int
260
260
  # @api private
261
261
  def assigns_for(rep)
262
262
  if rep.binary?
263
- content_or_filename_assigns = { filename: rep.temporary_filenames[:last] }
263
+ content_or_filename_assigns = { filename: rep.content_snapshots[:last].filename }
264
264
  else
265
- content_or_filename_assigns = { content: rep.content[:last] }
265
+ content_or_filename_assigns = { content: rep.content_snapshots[:last].string }
266
266
  end
267
267
 
268
268
  # TODO: Do not expose @site (necessary for captures store though…)
@@ -361,6 +361,8 @@ module Nanoc::Int
361
361
  #
362
362
  # @return [void]
363
363
  def compile_rep(rep)
364
+ executor = Nanoc::Int::Executor.new(self)
365
+
364
366
  Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
365
367
  Nanoc::Int::NotificationCenter.post(:processing_started, rep)
366
368
  Nanoc::Int::NotificationCenter.post(:visit_started, rep.item)
@@ -371,18 +373,18 @@ module Nanoc::Int
371
373
  if !rep.item.forced_outdated? && !outdatedness_checker.outdated?(rep) && compiled_content_cache[rep]
372
374
  # Reuse content
373
375
  Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
374
- rep.content = compiled_content_cache[rep]
376
+ rep.content_snapshots = compiled_content_cache[rep]
375
377
  else
376
378
  # Recalculate content
377
- rep.snapshot(:raw)
378
- rep.snapshot(:pre, final: false)
379
- rules_collection.compilation_rule_for(rep).apply_to(rep, compiler: self)
380
- rep.snapshot(:post) if rep.has_snapshot?(:post)
381
- rep.snapshot(:last)
379
+ executor.snapshot(rep, :raw)
380
+ executor.snapshot(rep, :pre, final: false)
381
+ rules_collection.compilation_rule_for(rep).apply_to(rep, executor: executor, compiler: self)
382
+ executor.snapshot(rep, :post) if rep.has_snapshot?(:post)
383
+ executor.snapshot(rep, :last)
382
384
  end
383
385
 
384
386
  rep.compiled = true
385
- compiled_content_cache[rep] = rep.content
387
+ compiled_content_cache[rep] = rep.content_snapshots
386
388
 
387
389
  Nanoc::Int::NotificationCenter.post(:processing_ended, rep)
388
390
  Nanoc::Int::NotificationCenter.post(:compilation_ended, rep)
@@ -1,5 +1,7 @@
1
1
  module Nanoc::Int
2
2
  # Contains methods that will be executed by the site’s `Rules` file.
3
+ #
4
+ # @api private
3
5
  class CompilerDSL
4
6
  # The current rules filename.
5
7
  #
@@ -56,9 +56,11 @@ module Nanoc
56
56
  # @return [void]
57
57
  def type(arg)
58
58
  if arg.is_a?(Hash)
59
- @from, @to = arg.keys[0], arg.values[0]
59
+ @from = arg.keys[0]
60
+ @to = arg.values[0]
60
61
  else
61
- @from, @to = arg, arg
62
+ @from = arg
63
+ @to = arg
62
64
  end
63
65
  end
64
66
 
@@ -81,8 +81,8 @@ module Nanoc::Int
81
81
  # @return [Nanoc::Int::OutdatednessReasons::Generic, nil] The reason why the
82
82
  # given object is outdated, or nil if the object is not outdated.
83
83
  def basic_outdatedness_reason_for(obj)
84
- case obj.type
85
- when :item_rep
84
+ case obj
85
+ when Nanoc::Int::ItemRep
86
86
  # Outdated if rules outdated
87
87
  return Nanoc::Int::OutdatednessReasons::RulesModified if
88
88
  rule_memory_differs_for(obj)
@@ -104,9 +104,9 @@ module Nanoc::Int
104
104
 
105
105
  # Not outdated
106
106
  return nil
107
- when :item
107
+ when Nanoc::Int::Item
108
108
  obj.reps.find { |rep| basic_outdatedness_reason_for(rep) }
109
- when :layout
109
+ when Nanoc::Int::Layout
110
110
  # Outdated if rules outdated
111
111
  return Nanoc::Int::OutdatednessReasons::RulesModified if
112
112
  rule_memory_differs_for(obj)
@@ -136,7 +136,7 @@ module Nanoc::Int
136
136
  # @return [Boolean] true if the object is outdated, false otherwise
137
137
  def outdated_due_to_dependencies?(obj, processed = Set.new)
138
138
  # Convert from rep to item if necessary
139
- obj = obj.item if obj.type == :item_rep
139
+ obj = obj.item if obj.is_a?(Nanoc::Int::ItemRep)
140
140
 
141
141
  # Get from cache
142
142
  if @objects_outdated_due_to_dependencies.key?(obj)
@@ -175,7 +175,7 @@ module Nanoc::Int
175
175
  # @return [Boolean] false if either the new or the old checksum for the
176
176
  # given object is not available, true if both checksums are available
177
177
  def checksums_available?(obj)
178
- checksum_store[obj] && obj.__nanoc_checksum
178
+ checksum_store[obj] && Nanoc::Int::Checksummer.calc(obj)
179
179
  end
180
180
  memoize :checksums_available?
181
181
 
@@ -184,7 +184,7 @@ module Nanoc::Int
184
184
  # @return [Boolean] false if the old and new checksums for the given
185
185
  # object differ, true if they are identical
186
186
  def checksums_identical?(obj)
187
- checksum_store[obj] == obj.__nanoc_checksum
187
+ checksum_store[obj] == Nanoc::Int::Checksummer.calc(obj)
188
188
  end
189
189
  memoize :checksums_identical?
190
190
 
@@ -31,7 +31,7 @@ module Nanoc::Int
31
31
  def initialize(pattern, rep_name, block, params = {})
32
32
  # TODO: remove me
33
33
  unless pattern.is_a?(Nanoc::Int::StringPattern) || pattern.is_a?(Nanoc::Int::RegexpPattern)
34
- raise "Can only create rules with patterns"
34
+ raise 'Can only create rules with patterns'
35
35
  end
36
36
 
37
37
  @pattern = pattern
@@ -60,11 +60,10 @@ module Nanoc::Int
60
60
  #
61
61
  # @return [void]
62
62
  def apply_to(rep, params = {})
63
- compiler = params.fetch(:compiler) do
64
- raise ArgumentError, 'Required :compiler option is missing'
65
- end
66
- rep = Nanoc::Int::ItemRepProxy.new(rep, compiler) unless rep.proxy?
67
- context = Nanoc::Int::RuleContext.new(rep: rep, compiler: compiler)
63
+ compiler = params.fetch(:compiler)
64
+ executor = params.fetch(:executor)
65
+
66
+ context = Nanoc::Int::RuleContext.new(rep: rep, executor: executor, compiler: compiler)
68
67
  context.instance_exec(matches(rep.item.identifier), &@block)
69
68
  end
70
69