nanoc 3.8.0 → 4.0.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +322 -0
  4. data/NEWS.md +6 -0
  5. data/bin/nanoc +0 -18
  6. data/lib/nanoc.rb +5 -3
  7. data/lib/nanoc/base.rb +24 -6
  8. data/lib/nanoc/base/checksummer.rb +6 -4
  9. data/lib/nanoc/base/compilation/checksum_store.rb +4 -4
  10. data/lib/nanoc/base/compilation/compiled_content_cache.rb +5 -5
  11. data/lib/nanoc/base/compilation/compiler.rb +60 -65
  12. data/lib/nanoc/base/compilation/compiler_dsl.rb +11 -9
  13. data/lib/nanoc/base/compilation/dependency_tracker.rb +24 -38
  14. data/lib/nanoc/base/compilation/filter.rb +22 -7
  15. data/lib/nanoc/base/compilation/item_rep_proxy.rb +14 -12
  16. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -8
  17. data/lib/nanoc/base/compilation/outdatedness_checker.rb +32 -32
  18. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +3 -1
  19. data/lib/nanoc/base/compilation/rule.rb +9 -7
  20. data/lib/nanoc/base/compilation/rule_context.rb +15 -15
  21. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
  22. data/lib/nanoc/base/compilation/rule_memory_store.rb +7 -7
  23. data/lib/nanoc/base/compilation/rules_collection.rb +28 -30
  24. data/lib/nanoc/base/context.rb +2 -2
  25. data/lib/nanoc/base/core_ext/array.rb +17 -25
  26. data/lib/nanoc/base/core_ext/hash.rb +17 -25
  27. data/lib/nanoc/base/core_ext/pathname.rb +4 -2
  28. data/lib/nanoc/base/core_ext/string.rb +5 -3
  29. data/lib/nanoc/base/directed_graph.rb +4 -9
  30. data/lib/nanoc/base/error.rb +7 -0
  31. data/lib/nanoc/base/errors.rb +16 -23
  32. data/lib/nanoc/base/memoization.rb +4 -2
  33. data/lib/nanoc/base/notification_center.rb +3 -1
  34. data/lib/nanoc/base/plugin_registry.rb +14 -21
  35. data/lib/nanoc/base/result_data/item_rep.rb +43 -88
  36. data/lib/nanoc/base/source_data/code_snippet.rb +6 -4
  37. data/lib/nanoc/base/source_data/configuration.rb +3 -1
  38. data/lib/nanoc/base/source_data/data_source.rb +12 -94
  39. data/lib/nanoc/base/source_data/identifier.rb +50 -0
  40. data/lib/nanoc/base/source_data/item.rb +24 -67
  41. data/lib/nanoc/base/source_data/item_array.rb +6 -4
  42. data/lib/nanoc/base/source_data/layout.rb +17 -28
  43. data/lib/nanoc/base/source_data/site.rb +33 -44
  44. data/lib/nanoc/base/store.rb +3 -5
  45. data/lib/nanoc/base/temp_filename_factory.rb +3 -2
  46. data/lib/nanoc/base/views/config.rb +19 -0
  47. data/lib/nanoc/base/views/item.rb +77 -0
  48. data/lib/nanoc/base/views/item_collection.rb +43 -0
  49. data/lib/nanoc/base/views/item_rep.rb +125 -0
  50. data/lib/nanoc/base/views/layout.rb +42 -0
  51. data/lib/nanoc/base/views/layout_collection.rb +26 -0
  52. data/lib/nanoc/base/views/mutable_config.rb +9 -0
  53. data/lib/nanoc/base/views/mutable_item.rb +9 -0
  54. data/lib/nanoc/base/views/mutable_item_collection.rb +18 -0
  55. data/lib/nanoc/base/views/mutable_layout.rb +9 -0
  56. data/lib/nanoc/base/views/mutable_layout_collection.rb +18 -0
  57. data/lib/nanoc/base/views/site.rb +35 -0
  58. data/lib/nanoc/cli.rb +3 -6
  59. data/lib/nanoc/cli/ansi_string_colorizer.rb +2 -0
  60. data/lib/nanoc/cli/cleaning_stream.rb +2 -0
  61. data/lib/nanoc/cli/command_runner.rb +8 -42
  62. data/lib/nanoc/cli/commands/check.rb +2 -2
  63. data/lib/nanoc/cli/commands/compile.rb +19 -34
  64. data/lib/nanoc/cli/commands/create-site.rb +46 -83
  65. data/lib/nanoc/cli/commands/deploy.rb +4 -4
  66. data/lib/nanoc/cli/commands/shell.rb +1 -1
  67. data/lib/nanoc/cli/commands/show-plugins.rb +4 -6
  68. data/lib/nanoc/cli/error_handler.rb +4 -14
  69. data/lib/nanoc/cli/logger.rb +2 -0
  70. data/lib/nanoc/cli/stream_cleaners.rb +1 -0
  71. data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -0
  72. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -0
  73. data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -0
  74. data/lib/nanoc/data_sources.rb +1 -17
  75. data/lib/nanoc/data_sources/filesystem.rb +6 -37
  76. data/lib/nanoc/data_sources/filesystem_unified.rb +5 -3
  77. data/lib/nanoc/data_sources/filesystem_verbose.rb +5 -3
  78. data/lib/nanoc/data_sources/static.rb +4 -2
  79. data/lib/nanoc/extra.rb +1 -13
  80. data/lib/nanoc/extra/checking.rb +1 -0
  81. data/lib/nanoc/extra/checking/check.rb +4 -2
  82. data/lib/nanoc/extra/checking/checks.rb +1 -0
  83. data/lib/nanoc/extra/checking/checks/css.rb +1 -0
  84. data/lib/nanoc/extra/checking/checks/external_links.rb +2 -0
  85. data/lib/nanoc/extra/checking/checks/html.rb +1 -0
  86. data/lib/nanoc/extra/checking/checks/internal_links.rb +2 -0
  87. data/lib/nanoc/extra/checking/checks/mixed_content.rb +2 -0
  88. data/lib/nanoc/extra/checking/checks/stale.rb +1 -0
  89. data/lib/nanoc/extra/checking/dsl.rb +1 -0
  90. data/lib/nanoc/extra/checking/issue.rb +1 -0
  91. data/lib/nanoc/extra/checking/runner.rb +3 -3
  92. data/lib/nanoc/extra/core_ext/pathname.rb +5 -3
  93. data/lib/nanoc/extra/core_ext/time.rb +4 -2
  94. data/lib/nanoc/extra/deployer.rb +3 -1
  95. data/lib/nanoc/extra/deployers.rb +1 -0
  96. data/lib/nanoc/extra/deployers/fog.rb +2 -0
  97. data/lib/nanoc/extra/deployers/rsync.rb +2 -0
  98. data/lib/nanoc/extra/filesystem_tools.rb +3 -7
  99. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -0
  100. data/lib/nanoc/extra/link_collector.rb +1 -0
  101. data/lib/nanoc/extra/piper.rb +2 -1
  102. data/lib/nanoc/extra/pruner.rb +5 -3
  103. data/lib/nanoc/filters.rb +1 -2
  104. data/lib/nanoc/filters/asciidoc.rb +2 -0
  105. data/lib/nanoc/filters/bluecloth.rb +1 -0
  106. data/lib/nanoc/filters/coffeescript.rb +2 -0
  107. data/lib/nanoc/filters/colorize_syntax.rb +1 -12
  108. data/lib/nanoc/filters/erb.rb +2 -1
  109. data/lib/nanoc/filters/erubis.rb +2 -1
  110. data/lib/nanoc/filters/haml.rb +2 -1
  111. data/lib/nanoc/filters/handlebars.rb +2 -0
  112. data/lib/nanoc/filters/kramdown.rb +1 -0
  113. data/lib/nanoc/filters/less.rb +1 -0
  114. data/lib/nanoc/filters/markaby.rb +1 -0
  115. data/lib/nanoc/filters/maruku.rb +1 -0
  116. data/lib/nanoc/filters/mustache.rb +2 -0
  117. data/lib/nanoc/filters/pandoc.rb +1 -0
  118. data/lib/nanoc/filters/rainpress.rb +1 -0
  119. data/lib/nanoc/filters/rdiscount.rb +1 -0
  120. data/lib/nanoc/filters/rdoc.rb +1 -0
  121. data/lib/nanoc/filters/redcarpet.rb +2 -0
  122. data/lib/nanoc/filters/redcloth.rb +1 -0
  123. data/lib/nanoc/filters/relativize_paths.rb +1 -0
  124. data/lib/nanoc/filters/rubypants.rb +1 -0
  125. data/lib/nanoc/filters/sass.rb +1 -0
  126. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +2 -0
  127. data/lib/nanoc/filters/slim.rb +3 -1
  128. data/lib/nanoc/filters/typogruby.rb +2 -0
  129. data/lib/nanoc/filters/uglify_js.rb +1 -0
  130. data/lib/nanoc/filters/xsl.rb +2 -0
  131. data/lib/nanoc/filters/yui_compressor.rb +2 -0
  132. data/lib/nanoc/helpers/blogging.rb +30 -30
  133. data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
  134. data/lib/nanoc/helpers/capturing.rb +6 -17
  135. data/lib/nanoc/helpers/filtering.rb +3 -3
  136. data/lib/nanoc/helpers/link_to.rb +3 -3
  137. data/lib/nanoc/helpers/rendering.rb +11 -11
  138. data/lib/nanoc/helpers/xml_sitemap.rb +3 -3
  139. data/lib/nanoc/tasks.rb +1 -0
  140. data/lib/nanoc/tasks/clean.rake +1 -1
  141. data/lib/nanoc/version.rb +1 -1
  142. data/tasks/doc.rake +2 -1
  143. data/tasks/test.rake +7 -1
  144. data/test/base/checksummer_spec.rb +15 -15
  145. data/test/base/core_ext/array_spec.rb +10 -10
  146. data/test/base/core_ext/hash_spec.rb +16 -16
  147. data/test/base/core_ext/pathname_spec.rb +2 -2
  148. data/test/base/core_ext/string_spec.rb +9 -9
  149. data/test/base/temp_filename_factory_spec.rb +3 -7
  150. data/test/base/test_checksum_store.rb +5 -5
  151. data/test/base/test_code_snippet.rb +3 -3
  152. data/test/base/test_compiler.rb +29 -29
  153. data/test/base/test_compiler_dsl.rb +23 -23
  154. data/test/base/test_context.rb +4 -4
  155. data/test/base/test_data_source.rb +17 -7
  156. data/test/base/test_dependency_tracker.rb +29 -29
  157. data/test/base/test_directed_graph.rb +27 -27
  158. data/test/base/test_item.rb +23 -21
  159. data/test/base/test_item_array.rb +18 -18
  160. data/test/base/test_item_rep.rb +76 -76
  161. data/test/base/test_item_rep_recorder_proxy.rb +4 -4
  162. data/test/base/test_layout.rb +8 -16
  163. data/test/base/test_memoization.rb +4 -4
  164. data/test/base/test_notification_center.rb +6 -6
  165. data/test/base/test_outdatedness_checker.rb +18 -18
  166. data/test/base/test_plugin.rb +1 -1
  167. data/test/base/test_rule.rb +2 -2
  168. data/test/base/test_rule_context.rb +5 -5
  169. data/test/base/test_site.rb +62 -38
  170. data/test/base/test_store.rb +2 -2
  171. data/test/cli/commands/test_check.rb +1 -1
  172. data/test/cli/commands/test_compile.rb +24 -18
  173. data/test/cli/commands/test_create_site.rb +5 -7
  174. data/test/cli/commands/test_deploy.rb +1 -1
  175. data/test/data_sources/test_filesystem.rb +22 -67
  176. data/test/data_sources/test_filesystem_unified.rb +10 -23
  177. data/test/data_sources/test_filesystem_verbose.rb +8 -53
  178. data/test/data_sources/test_static.rb +9 -9
  179. data/test/extra/checking/checks/test_stale.rb +1 -1
  180. data/test/extra/core_ext/test_pathname.rb +3 -3
  181. data/test/extra/core_ext/test_time.rb +4 -4
  182. data/test/extra/test_filesystem_tools.rb +1 -1
  183. data/test/filters/test_handlebars.rb +3 -3
  184. data/test/filters/test_less.rb +6 -6
  185. data/test/filters/test_mustache.rb +2 -2
  186. data/test/filters/test_relativize_paths.rb +81 -81
  187. data/test/filters/test_sass.rb +7 -7
  188. data/test/filters/test_xsl.rb +6 -6
  189. data/test/helper.rb +1 -1
  190. data/test/helpers/test_blogging.rb +78 -99
  191. data/test/helpers/test_breadcrumbs.rb +12 -12
  192. data/test/helpers/test_capturing.rb +10 -11
  193. data/test/helpers/test_filtering.rb +6 -6
  194. data/test/helpers/test_rendering.rb +3 -3
  195. data/test/helpers/test_tagging.rb +7 -7
  196. data/test/helpers/test_xml_sitemap.rb +34 -33
  197. metadata +19 -43
  198. data/lib/nanoc/cli/commands/autocompile.rb +0 -69
  199. data/lib/nanoc/cli/commands/create-item.rb +0 -55
  200. data/lib/nanoc/cli/commands/create-layout.rb +0 -68
  201. data/lib/nanoc/cli/commands/sync.rb +0 -32
  202. data/lib/nanoc/cli/commands/update.rb +0 -63
  203. data/lib/nanoc/cli/commands/validate-css.rb +0 -20
  204. data/lib/nanoc/cli/commands/validate-html.rb +0 -20
  205. data/lib/nanoc/cli/commands/validate-links.rb +0 -27
  206. data/lib/nanoc/cli/commands/watch.rb +0 -176
  207. data/lib/nanoc/data_sources/deprecated/delicious.rb +0 -38
  208. data/lib/nanoc/data_sources/deprecated/last_fm.rb +0 -85
  209. data/lib/nanoc/data_sources/deprecated/twitter.rb +0 -34
  210. data/lib/nanoc/extra/auto_compiler.rb +0 -99
  211. data/lib/nanoc/extra/chick.rb +0 -117
  212. data/lib/nanoc/extra/file_proxy.rb +0 -36
  213. data/lib/nanoc/extra/validators.rb +0 -8
  214. data/lib/nanoc/extra/validators/links.rb +0 -18
  215. data/lib/nanoc/extra/validators/w3c.rb +0 -23
  216. data/lib/nanoc/extra/vcs.rb +0 -62
  217. data/lib/nanoc/extra/vcses.rb +0 -15
  218. data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
  219. data/lib/nanoc/extra/vcses/dummy.rb +0 -20
  220. data/lib/nanoc/extra/vcses/git.rb +0 -21
  221. data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
  222. data/lib/nanoc/extra/vcses/subversion.rb +0 -21
  223. data/lib/nanoc/filters/coderay.rb +0 -19
  224. data/lib/nanoc3.rb +0 -3
  225. data/lib/nanoc3/cli.rb +0 -3
  226. data/lib/nanoc3/tasks.rb +0 -3
  227. data/test/cli/commands/test_create_item.rb +0 -10
  228. data/test/cli/commands/test_create_layout.rb +0 -24
  229. data/test/cli/commands/test_sync.rb +0 -27
  230. data/test/cli/commands/test_update.rb +0 -6
  231. data/test/cli/commands/test_watch.rb +0 -74
  232. data/test/extra/test_auto_compiler.rb +0 -437
  233. data/test/extra/test_vcs.rb +0 -18
  234. data/test/extra/validators/test_links.rb +0 -4
  235. data/test/extra/validators/test_w3c.rb +0 -37
  236. data/test/filters/test_coderay.rb +0 -40
@@ -1,60 +1,16 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
4
- # A single representation (rep) of an item ({Nanoc::Item}). An item can
3
+ module Nanoc::Int
4
+ # A single representation (rep) of an item ({Nanoc::Int::Item}). An item can
5
5
  # have multiple representations. A representation has its own output file.
6
6
  # A single item can therefore have multiple output files, each run through
7
7
  # a different set of filters with a different layout.
8
+ #
9
+ # @api private
8
10
  class ItemRep
9
- # Contains all deprecated methods. Mixed into {Nanoc::ItemRep}.
10
- module Deprecated
11
- # @deprecated Modify the {#raw_paths} attribute instead
12
- def raw_path=(raw_path)
13
- raw_paths[:last] = raw_path
14
- end
15
-
16
- # @deprecated Modify the {#paths} attribute instead
17
- def path=(path)
18
- paths[:last] = path
19
- end
20
-
21
- # @deprecated Use {Nanoc::ItemRep#compiled_content} instead.
22
- def content_at_snapshot(snapshot = :pre)
23
- compiled_content(snapshot: snapshot)
24
- end
25
-
26
- # @deprecated
27
- def created
28
- raise NotImplementedError, 'Nanoc::ItemRep#created is no longer implemented'
29
- end
30
-
31
- # @deprecated
32
- def created?
33
- raise NotImplementedError, 'Nanoc::ItemRep#created? is no longer implemented'
34
- end
35
-
36
- # @deprecated
37
- def modified
38
- raise NotImplementedError, 'Nanoc::ItemRep#modified is no longer implemented'
39
- end
40
-
41
- # @deprecated
42
- def modified?
43
- raise NotImplementedError, 'Nanoc::ItemRep#modified? is no longer implemented'
44
- end
45
-
46
- # @deprecated
47
- def written
48
- raise NotImplementedError, 'Nanoc::ItemRep#written is no longer implemented'
49
- end
50
-
51
- # @deprecated
52
- def written?
53
- raise NotImplementedError, 'Nanoc::ItemRep#written? is no longer implemented'
54
- end
55
- end
56
-
57
- # Contains all private methods. Mixed into {Nanoc::ItemRep}.
11
+ # Contains all private methods. Mixed into {Nanoc::Int::ItemRep}.
12
+ #
13
+ # @api private
58
14
  module Private
59
15
  # @return [Hash] A hash containing the assigns that will be used in the
60
16
  # next filter or layout operation. The keys (symbols) will be made
@@ -125,7 +81,7 @@ module Nanoc
125
81
  is_created = !File.file?(raw_path)
126
82
 
127
83
  # Notify
128
- Nanoc::NotificationCenter.post(:will_write_rep, self, snapshot)
84
+ Nanoc::Int::NotificationCenter.post(:will_write_rep, self, snapshot)
129
85
 
130
86
  if self.binary?
131
87
  temp_path = temporary_filenames[:last]
@@ -141,13 +97,13 @@ module Nanoc
141
97
  FileUtils.cp(temp_path, raw_path) if is_modified
142
98
 
143
99
  # Notify
144
- Nanoc::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
100
+ Nanoc::Int::NotificationCenter.post(:rep_written, self, raw_path, is_created, is_modified)
145
101
  end
146
102
 
147
103
  TMP_TEXT_ITEMS_DIR = 'text_items'
148
104
 
149
105
  def temp_filename
150
- Nanoc::TempFilenameFactory.instance.create(TMP_TEXT_ITEMS_DIR)
106
+ Nanoc::Int::TempFilenameFactory.instance.create(TMP_TEXT_ITEMS_DIR)
151
107
  end
152
108
 
153
109
  # Resets the compilation progress for this item representation. This is
@@ -172,10 +128,9 @@ module Nanoc
172
128
  end
173
129
  end
174
130
 
175
- include Deprecated
176
131
  include Private
177
132
 
178
- # @return [Nanoc::Item] The item to which this rep belongs
133
+ # @return [Nanoc::Int::Item] The item to which this rep belongs
179
134
  attr_reader :item
180
135
 
181
136
  # @return [Symbol] The representation's unique name
@@ -192,7 +147,7 @@ module Nanoc
192
147
 
193
148
  # Creates a new item representation for the given item.
194
149
  #
195
- # @param [Nanoc::Item] item The item to which the new representation will
150
+ # @param [Nanoc::Int::Item] item The item to which the new representation will
196
151
  # belong.
197
152
  #
198
153
  # @param [Symbol] name The unique name for the new item representation.
@@ -227,12 +182,12 @@ module Nanoc
227
182
  def compiled_content(params = {})
228
183
  # Make sure we're not binary
229
184
  if item.binary?
230
- raise Nanoc::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
185
+ raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(self)
231
186
  end
232
187
 
233
188
  # Notify
234
- Nanoc::NotificationCenter.post(:visit_started, item)
235
- Nanoc::NotificationCenter.post(:visit_ended, item)
189
+ Nanoc::Int::NotificationCenter.post(:visit_started, item)
190
+ Nanoc::Int::NotificationCenter.post(:visit_ended, item)
236
191
 
237
192
  # Get name of last pre-layout snapshot
238
193
  snapshot_name = params.fetch(:snapshot) { @content[:pre] ? :pre : :last }
@@ -241,7 +196,7 @@ module Nanoc
241
196
  # Check existance of snapshot
242
197
  snapshot = snapshots.find { |s| s.first == snapshot_name }
243
198
  if !is_moving && (snapshot.nil? || snapshot[-1] == false)
244
- raise Nanoc::Errors::NoSuchSnapshot.new(self, snapshot_name)
199
+ raise Nanoc::Int::Errors::NoSuchSnapshot.new(self, snapshot_name)
245
200
  end
246
201
 
247
202
  # Verify snapshot is usable
@@ -254,7 +209,7 @@ module Nanoc
254
209
  end
255
210
  is_usable_snapshot = @content[snapshot_name] && (self.compiled? || !is_still_moving)
256
211
  unless is_usable_snapshot
257
- raise Nanoc::Errors::UnmetDependency.new(self)
212
+ raise Nanoc::Int::Errors::UnmetDependency.new(self)
258
213
  end
259
214
 
260
215
  @content[snapshot_name]
@@ -279,8 +234,8 @@ module Nanoc
279
234
  #
280
235
  # @return [String] The item rep’s path
281
236
  def raw_path(params = {})
282
- Nanoc3::NotificationCenter.post(:visit_started, item)
283
- Nanoc3::NotificationCenter.post(:visit_ended, item)
237
+ Nanoc::Int::NotificationCenter.post(:visit_started, item)
238
+ Nanoc::Int::NotificationCenter.post(:visit_ended, item)
284
239
 
285
240
  snapshot_name = params[:snapshot] || :last
286
241
  @raw_paths[snapshot_name]
@@ -296,8 +251,8 @@ module Nanoc
296
251
  #
297
252
  # @return [String] The item rep’s path
298
253
  def path(params = {})
299
- Nanoc3::NotificationCenter.post(:visit_started, item)
300
- Nanoc3::NotificationCenter.post(:visit_ended, item)
254
+ Nanoc::Int::NotificationCenter.post(:visit_started, item)
255
+ Nanoc::Int::NotificationCenter.post(:visit_ended, item)
301
256
 
302
257
  snapshot_name = params[:snapshot] || :last
303
258
  @paths[snapshot_name]
@@ -308,9 +263,9 @@ module Nanoc
308
263
  # filtered content of the last snapshot.
309
264
  #
310
265
  # This method is supposed to be called only in a compilation rule block
311
- # (see {Nanoc::CompilerDSL#compile}).
266
+ # (see {Nanoc::Int::CompilerDSL#compile}).
312
267
  #
313
- # @see Nanoc::ItemRepProxy#filter
268
+ # @see Nanoc::Int::ItemRepProxy#filter
314
269
  #
315
270
  # @param [Symbol] filter_name The name of the filter to run the item
316
271
  # representations' content through
@@ -322,18 +277,18 @@ module Nanoc
322
277
  def filter(filter_name, filter_args = {})
323
278
  # Get filter class
324
279
  klass = filter_named(filter_name)
325
- raise Nanoc::Errors::UnknownFilter.new(filter_name) if klass.nil?
280
+ raise Nanoc::Int::Errors::UnknownFilter.new(filter_name) if klass.nil?
326
281
 
327
282
  # Check whether filter can be applied
328
283
  if klass.from_binary? && !self.binary?
329
- raise Nanoc::Errors::CannotUseBinaryFilter.new(self, klass)
284
+ raise Nanoc::Int::Errors::CannotUseBinaryFilter.new(self, klass)
330
285
  elsif !klass.from_binary? && self.binary?
331
- raise Nanoc::Errors::CannotUseTextualFilter.new(self, klass)
286
+ raise Nanoc::Int::Errors::CannotUseTextualFilter.new(self, klass)
332
287
  end
333
288
 
334
289
  begin
335
290
  # Notify start
336
- Nanoc::NotificationCenter.post(:filtering_started, self, filter_name)
291
+ Nanoc::Int::NotificationCenter.post(:filtering_started, self, filter_name)
337
292
 
338
293
  # Create filter
339
294
  filter = klass.new(assigns)
@@ -358,7 +313,7 @@ module Nanoc
358
313
  snapshot(@content[:post] ? :post : :pre, final: false) unless self.binary?
359
314
  ensure
360
315
  # Notify end
361
- Nanoc::NotificationCenter.post(:filtering_ended, self, filter_name)
316
+ Nanoc::Int::NotificationCenter.post(:filtering_ended, self, filter_name)
362
317
  end
363
318
  end
364
319
 
@@ -367,11 +322,11 @@ module Nanoc
367
322
  # snapshot.
368
323
  #
369
324
  # This method is supposed to be called only in a compilation rule block
370
- # (see {Nanoc::CompilerDSL#compile}).
325
+ # (see {Nanoc::Int::CompilerDSL#compile}).
371
326
  #
372
- # @see Nanoc::ItemRepProxy#layout
327
+ # @see Nanoc::Int::ItemRepProxy#layout
373
328
  #
374
- # @param [Nanoc::Layout] layout The layout to use
329
+ # @param [Nanoc::Int::Layout] layout The layout to use
375
330
  #
376
331
  # @param [Symbol] filter_name The name of the filter to layout the item
377
332
  # representations' content with
@@ -382,7 +337,7 @@ module Nanoc
382
337
  # @return [void]
383
338
  def layout(layout, filter_name, filter_args)
384
339
  # Check whether item can be laid out
385
- raise Nanoc::Errors::CannotLayoutBinaryItem.new(self) if self.binary?
340
+ raise Nanoc::Int::Errors::CannotLayoutBinaryItem.new(self) if self.binary?
386
341
 
387
342
  # Create "pre" snapshot
388
343
  if @content[:post].nil?
@@ -391,17 +346,17 @@ module Nanoc
391
346
 
392
347
  # Create filter
393
348
  klass = filter_named(filter_name)
394
- raise Nanoc::Errors::UnknownFilter.new(filter_name) if klass.nil?
349
+ raise Nanoc::Int::Errors::UnknownFilter.new(filter_name) if klass.nil?
395
350
  filter = klass.new(assigns.merge({ layout: layout }))
396
351
 
397
352
  # Visit
398
- Nanoc::NotificationCenter.post(:visit_started, layout)
399
- Nanoc::NotificationCenter.post(:visit_ended, layout)
353
+ Nanoc::Int::NotificationCenter.post(:visit_started, layout)
354
+ Nanoc::Int::NotificationCenter.post(:visit_ended, layout)
400
355
 
401
356
  begin
402
357
  # Notify start
403
- Nanoc::NotificationCenter.post(:processing_started, layout)
404
- Nanoc::NotificationCenter.post(:filtering_started, self, filter_name)
358
+ Nanoc::Int::NotificationCenter.post(:processing_started, layout)
359
+ Nanoc::Int::NotificationCenter.post(:filtering_started, self, filter_name)
405
360
 
406
361
  # Layout
407
362
  @content[:last] = filter.setup_and_run(layout.raw_content, filter_args)
@@ -410,8 +365,8 @@ module Nanoc
410
365
  snapshot(:post, final: false)
411
366
  ensure
412
367
  # Notify end
413
- Nanoc::NotificationCenter.post(:filtering_ended, self, filter_name)
414
- Nanoc::NotificationCenter.post(:processing_ended, layout)
368
+ Nanoc::Int::NotificationCenter.post(:filtering_ended, self, filter_name)
369
+ Nanoc::Int::NotificationCenter.post(:processing_ended, layout)
415
370
  end
416
371
  end
417
372
 
@@ -444,9 +399,9 @@ module Nanoc
444
399
  #
445
400
  # @api private
446
401
  #
447
- # @return [Nanoc::ItemRepRecorderProxy] The recording proxy
402
+ # @return [Nanoc::Int::ItemRepRecorderProxy] The recording proxy
448
403
  def to_recording_proxy
449
- Nanoc::ItemRepRecorderProxy.new(self)
404
+ Nanoc::Int::ItemRepRecorderProxy.new(self)
450
405
  end
451
406
 
452
407
  # Returns false because this item is not yet a proxy, and therefore does
@@ -456,8 +411,8 @@ module Nanoc
456
411
  #
457
412
  # @return [false]
458
413
  #
459
- # @see Nanoc::ItemRepRecorderProxy#proxy?
460
- # @see Nanoc::ItemRepProxy#proxy?
414
+ # @see Nanoc::Int::ItemRepRecorderProxy#proxy?
415
+ # @see Nanoc::Int::ItemRepProxy#proxy?
461
416
  def proxy?
462
417
  false
463
418
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
4
- # Nanoc::CodeSnippet represent a piece of custom code of a nanoc site.
3
+ module Nanoc::Int
4
+ # Nanoc::Int::CodeSnippet represent a piece of custom code of a nanoc site.
5
+ #
6
+ # @api private
5
7
  class CodeSnippet
6
8
  # A string containing the actual code in this code snippet.
7
9
  #
@@ -47,8 +49,8 @@ module Nanoc
47
49
 
48
50
  # @return [String] The checksum for this object. If its contents change,
49
51
  # the checksum will change as well.
50
- def checksum
51
- Nanoc::Checksummer.calc(self)
52
+ def __nanoc_checksum
53
+ Nanoc::Int::Checksummer.calc(self)
52
54
  end
53
55
  end
54
56
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
3
+ module Nanoc::Int
4
4
  # Represents the site configuration.
5
+ #
6
+ # @api private
5
7
  class Configuration < ::Hash
6
8
  # Creates a new configuration with the given hash.
7
9
  #
@@ -3,8 +3,7 @@
3
3
  module Nanoc
4
4
  # Responsible for loading site data. It is the (abstract) superclass for all
5
5
  # data sources. Subclasses must at least implement the data reading methods
6
- # ({#items} and {#layouts}); all other methods involving data manipulation
7
- # are optional.
6
+ # ({#items} and {#layouts}).
8
7
  #
9
8
  # Apart from the methods for loading and storing data, there are the {#up}
10
9
  # and {#down} methods for bringing up and tearing down the connection to the
@@ -16,14 +15,7 @@ module Nanoc
16
15
  # reference count goes from 1 to 0, the data source will be unloaded
17
16
  # ({#down} will be called).
18
17
  #
19
- # The {#setup} method is used for setting up a site's data source for the
20
- # first time.
21
- #
22
- # @abstract Subclasses should at least implement {#items} and {#layouts}. If
23
- # the data source should support creating items and layouts using the
24
- # `create_item` and `create_layout` CLI commands, the {#setup},
25
- # {#create_item} and {#create_layout} methods should be implemented as
26
- # well.
18
+ # @abstract Subclasses should at least implement {#items} and {#layouts}.
27
19
  class DataSource
28
20
  # @return [String] The root path where items returned by this data source
29
21
  # should be mounted.
@@ -37,11 +29,11 @@ module Nanoc
37
29
  # online data sources could contain authentication details.
38
30
  attr_reader :config
39
31
 
40
- extend Nanoc::PluginRegistry::PluginMethods
32
+ extend Nanoc::Int::PluginRegistry::PluginMethods
41
33
 
42
34
  # Creates a new data source for the given site.
43
35
  #
44
- # @param [Nanoc::Site] site The site this data source belongs to.
36
+ # @param [Nanoc::Int::Site] site The site this data source belongs to.
45
37
  #
46
38
  # @param [String] items_root The prefix that should be given to all items
47
39
  # returned by the #items method (comparable to mount points for
@@ -122,43 +114,7 @@ module Nanoc
122
114
  def down
123
115
  end
124
116
 
125
- # Creates the bare minimum essentials for this data source to work. This
126
- # action will likely be destructive. This method should not create sample
127
- # data such as a default home page, a default layout, etc. For example,
128
- # when using a database, this is where you should create the necessary
129
- # tables for the data source to function properly.
130
- #
131
- # @abstract
132
- #
133
- # @return [void]
134
- def setup
135
- not_implemented('setup')
136
- end
137
-
138
- # Updated the content stored in this site to a newer version. A newer
139
- # version of a data source may store content in a different format, and
140
- # this method will update the stored content to this newer format.
141
- #
142
- # Subclasses may override this method, but are not required to do so; the
143
- # default implementation simply does nothing.
144
- #
145
- # @return [void]
146
- def update
147
- end
148
-
149
- # Sync the content for this data source with an external source.
150
- # This method is called by the `nanoc sync` command so that data sources may
151
- # update local caches of external data, such as items fetched from
152
- # third-party APIs.
153
- #
154
- # Subclasses may override this method, but are not required to do so; the
155
- # default implementation simply does nothing.
156
- #
157
- # @return [void]
158
- def sync
159
- end
160
-
161
- # Returns the list of items (represented by {Nanoc::Item}) in this site.
117
+ # Returns the list of items (represented by {Nanoc::Int::Item}) in this site.
162
118
  # The default implementation simply returns an empty array.
163
119
  #
164
120
  # Subclasses should not prepend `items_root` to the item's identifiers, as
@@ -167,12 +123,12 @@ module Nanoc
167
123
  # Subclasses may override this method, but are not required to do so; the
168
124
  # default implementation simply does nothing.
169
125
  #
170
- # @return [Array<Nanoc::Item>] A list of items
126
+ # @return [Array<Nanoc::Int::Item>] A list of items
171
127
  def items
172
128
  []
173
129
  end
174
130
 
175
- # Returns the list of layouts (represented by {Nanoc::Layout}) in this
131
+ # Returns the list of layouts (represented by {Nanoc::Int::Layout}) in this
176
132
  # site. The default implementation simply returns an empty array.
177
133
  #
178
134
  # Subclasses should prepend `layout_root` to the layout's identifiers,
@@ -181,55 +137,17 @@ module Nanoc
181
137
  # Subclasses may override this method, but are not required to do so; the
182
138
  # default implementation simply does nothing.
183
139
  #
184
- # @return [Array<Nanoc::Layout>] A list of layouts
140
+ # @return [Array<Nanoc::Int::Layout>] A list of layouts
185
141
  def layouts
186
142
  []
187
143
  end
188
144
 
189
- # Creates a new item with the given content, attributes and identifier. No
190
- # instance of {Nanoc::Item} will be created; this method creates the item
191
- # in the data source so that it can be loaded and turned into a
192
- # {Nanoc::Item} instance by the {#items} method.
193
- #
194
- # @abstract
195
- #
196
- # @param [String] content
197
- #
198
- # @param [Hash] attributes
199
- #
200
- # @param [String] identifier
201
- #
202
- # @param [Hash] params Extra parameters to give to the data source. This
203
- # can be used to influence the way items are stored. For example,
204
- # filesystem data sources could use this to pass the extension of the
205
- # files that should be generated.
206
- #
207
- # @return [void]
208
- def create_item(content, attributes, identifier, params = {}) # rubocop:disable Lint/UnusedMethodArgument
209
- not_implemented('create_item')
145
+ def new_item(content, attributes, identifier, params = {})
146
+ Nanoc::Int::Item.new(content, attributes, identifier, params)
210
147
  end
211
148
 
212
- # Creates a new layout with the given content, attributes and identifier.
213
- # No instance of {Nanoc::Layout} will be created; this method creates the
214
- # layout in the data source so that it can be loaded and turned into a
215
- # {Nanoc::Layout} instance by the {#layouts} method.
216
- #
217
- # @abstract
218
- #
219
- # @param [String] content
220
- #
221
- # @param [Hash] attributes
222
- #
223
- # @param [String] identifier
224
- #
225
- # @param [Hash] params Extra parameters to give to the data source. This
226
- # can be used to influence the way items are stored. For example,
227
- # filesystem data sources could use this to pass the extension of the
228
- # files that should be generated.
229
- #
230
- # @return [void]
231
- def create_layout(content, attributes, identifier, params = {}) # rubocop:disable Lint/UnusedMethodArgument
232
- not_implemented('create_layout')
149
+ def new_layout(content, attributes, identifier)
150
+ Nanoc::Int::Layout.new(content, attributes, identifier)
233
151
  end
234
152
 
235
153
  private