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,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
3
+ module Nanoc::Int
4
4
  # Responsible for remembering dependencies between items and layouts. It is
5
5
  # used to speed up compilation by only letting an item be recompiled when it
6
6
  # is outdated or any of its dependencies (or dependencies’ dependencies,
@@ -10,32 +10,32 @@ module Nanoc
10
10
  # based on an item’s or a layout’s content. When one object uses an
11
11
  # attribute of another object, then this is also treated as a dependency.
12
12
  # While dependencies based on an item’s or layout’s content (handled in
13
- # {Nanoc::Compiler}) cannot be mutually recursive, the more general
14
- # dependencies in Nanoc::DependencyTracker can (e.g. item A can use an
13
+ # {Nanoc::Int::Compiler}) cannot be mutually recursive, the more general
14
+ # dependencies in Nanoc::Int::DependencyTracker can (e.g. item A can use an
15
15
  # attribute of item B and vice versa without problems).
16
16
  #
17
17
  # The dependency tracker remembers the dependency information between runs.
18
18
  # Dependency information is stored in the `tmp/dependencies` file.
19
19
  #
20
20
  # @api private
21
- class DependencyTracker < ::Nanoc::Store
22
- # @return [Array<Nanoc::Item, Nanoc::Layout>] The list of items and
21
+ class DependencyTracker < ::Nanoc::Int::Store
22
+ # @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] The list of items and
23
23
  # layouts that are being tracked by the dependency tracker
24
24
  attr_reader :objects
25
25
 
26
- # @return [Nanoc::Compiler] The compiler that corresponds to this
26
+ # @return [Nanoc::Int::Compiler] The compiler that corresponds to this
27
27
  # dependency tracker
28
28
  attr_accessor :compiler
29
29
 
30
30
  # Creates a new dependency tracker for the given items and layouts.
31
31
  #
32
- # @param [Array<Nanoc::Item, Nanoc::Layout>] objects The list of items
32
+ # @param [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] objects The list of items
33
33
  # and layouts whose dependencies should be managed
34
34
  def initialize(objects)
35
35
  super('tmp/dependencies', 4)
36
36
 
37
37
  @objects = objects
38
- @graph = Nanoc::DirectedGraph.new([nil] + @objects)
38
+ @graph = Nanoc::Int::DirectedGraph.new([nil] + @objects)
39
39
  @stack = []
40
40
  end
41
41
 
@@ -50,16 +50,16 @@ module Nanoc
50
50
  @stack = []
51
51
 
52
52
  # Register start of visits
53
- Nanoc::NotificationCenter.on(:visit_started, self) do |obj|
53
+ Nanoc::Int::NotificationCenter.on(:visit_started, self) do |obj|
54
54
  unless @stack.empty?
55
- Nanoc::NotificationCenter.post(:dependency_created, @stack.last, obj)
55
+ Nanoc::Int::NotificationCenter.post(:dependency_created, @stack.last, obj)
56
56
  record_dependency(@stack.last, obj)
57
57
  end
58
58
  @stack.push(obj)
59
59
  end
60
60
 
61
61
  # Register end of visits
62
- Nanoc::NotificationCenter.on(:visit_ended, self) do |_obj|
62
+ Nanoc::Int::NotificationCenter.on(:visit_ended, self) do |_obj|
63
63
  @stack.pop
64
64
  end
65
65
  end
@@ -74,14 +74,12 @@ module Nanoc
74
74
  end
75
75
 
76
76
  # Unregister
77
- Nanoc::NotificationCenter.remove(:visit_started, self)
78
- Nanoc::NotificationCenter.remove(:visit_ended, self)
77
+ Nanoc::Int::NotificationCenter.remove(:visit_started, self)
78
+ Nanoc::Int::NotificationCenter.remove(:visit_ended, self)
79
79
  end
80
80
 
81
81
  # @return The topmost item on the stack, i.e. the one currently being
82
82
  # compiled
83
- #
84
- # @api private
85
83
  def top
86
84
  @stack.last
87
85
  end
@@ -97,10 +95,10 @@ module Nanoc
97
95
  # The direct predecessors can include nil, which indicates an item that is
98
96
  # no longer present in the site.
99
97
  #
100
- # @param [Nanoc::Item, Nanoc::Layout] object The object for
98
+ # @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for
101
99
  # which to fetch the direct predecessors
102
100
  #
103
- # @return [Array<Nanoc::Item, Nanoc::Layout, nil>] The direct
101
+ # @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout, nil>] The direct
104
102
  # predecessors of
105
103
  # the given object
106
104
  def objects_causing_outdatedness_of(object)
@@ -115,10 +113,10 @@ module Nanoc
115
113
  # depends on C, then the direct inverse dependencies of C do not include
116
114
  # A).
117
115
  #
118
- # @param [Nanoc::Item, Nanoc::Layout] object The object for which to
116
+ # @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for which to
119
117
  # fetch the direct successors
120
118
  #
121
- # @return [Array<Nanoc::Item, Nanoc::Layout>] The direct successors of
119
+ # @return [Array<Nanoc::Int::Item, Nanoc::Int::Layout>] The direct successors of
122
120
  # the given object
123
121
  def objects_outdated_due_to(object)
124
122
  @graph.direct_successors_of(object).compact
@@ -127,10 +125,10 @@ module Nanoc
127
125
  # Records a dependency from `src` to `dst` in the dependency graph. When
128
126
  # `dst` is oudated, `src` will also become outdated.
129
127
  #
130
- # @param [Nanoc::Item, Nanoc::Layout] src The source of the dependency,
128
+ # @param [Nanoc::Int::Item, Nanoc::Int::Layout] src The source of the dependency,
131
129
  # i.e. the object that will become outdated if dst is outdated
132
130
  #
133
- # @param [Nanoc::Item, Nanoc::Layout] dst The destination of the
131
+ # @param [Nanoc::Int::Item, Nanoc::Int::Layout] dst The destination of the
134
132
  # dependency, i.e. the object that will cause the source to become
135
133
  # outdated if the destination is outdated
136
134
  #
@@ -145,9 +143,7 @@ module Nanoc
145
143
  # will stick around and new dependencies will appear twice. This function
146
144
  # removes all incoming edges for the given vertex.
147
145
  #
148
- # @api private
149
- #
150
- # @param [Nanoc::Item, Nanoc::Layout] object The object for which to
146
+ # @param [Nanoc::Int::Item, Nanoc::Int::Layout] object The object for which to
151
147
  # forget all dependencies
152
148
  #
153
149
  # @return [void]
@@ -155,19 +151,9 @@ module Nanoc
155
151
  @graph.delete_edges_to(object)
156
152
  end
157
153
 
158
- # @deprecated Use {#store} instead
159
- def store_graph
160
- store
161
- end
162
-
163
- # @deprecated Use {#load} instead
164
- def load_graph
165
- load
166
- end
167
-
168
- # @see Nanoc::Store#unload
154
+ # @see Nanoc::Int::Store#unload
169
155
  def unload
170
- @graph = Nanoc::DirectedGraph.new([nil] + @objects)
156
+ @graph = Nanoc::Int::DirectedGraph.new([nil] + @objects)
171
157
  end
172
158
 
173
159
  protected
@@ -181,7 +167,7 @@ module Nanoc
181
167
 
182
168
  def data=(new_data)
183
169
  # Create new graph
184
- @graph = Nanoc::DirectedGraph.new([nil] + @objects)
170
+ @graph = Nanoc::Int::DirectedGraph.new([nil] + @objects)
185
171
 
186
172
  # Load vertices
187
173
  previous_objects = new_data[:vertices].map do |reference|
@@ -200,7 +186,7 @@ module Nanoc
200
186
  new_objects = (@objects - previous_objects)
201
187
  new_objects.each do |new_obj|
202
188
  @objects.each do |obj|
203
- next unless obj.is_a?(Nanoc::Item)
189
+ next unless obj.is_a?(Nanoc::Int::Item)
204
190
  @graph.add_edge(new_obj, obj)
205
191
  end
206
192
  end
@@ -25,16 +25,19 @@ module Nanoc
25
25
  # # => 'bar'
26
26
  #
27
27
  # @abstract Subclass and override {#run} to implement a custom filter.
28
- class Filter < Context
28
+ class Filter < Nanoc::Int::Context
29
+ # @api private
29
30
  TMP_BINARY_ITEMS_DIR = 'binary_items'
30
31
 
31
32
  # A hash containing variables that will be made available during
32
33
  # filtering.
33
34
  #
34
35
  # @return [Hash]
36
+ #
37
+ # @api private
35
38
  attr_reader :assigns
36
39
 
37
- extend Nanoc::PluginRegistry::PluginMethods
40
+ extend Nanoc::Int::PluginRegistry::PluginMethods
38
41
 
39
42
  class << self
40
43
  # Sets the new type for the filter. The type can be `:binary` (default)
@@ -63,12 +66,16 @@ module Nanoc
63
66
 
64
67
  # @return [Boolean] True if this filter can be applied to binary item
65
68
  # representations, false otherwise
69
+ #
70
+ # @api private
66
71
  def from_binary?
67
72
  (@from || :text) == :binary
68
73
  end
69
74
 
70
75
  # @return [Boolean] True if this filter results in a binary item
71
76
  # representation, false otherwise
77
+ #
78
+ # @api private
72
79
  def to_binary?
73
80
  (@to || :text) == :binary
74
81
  end
@@ -91,6 +98,8 @@ module Nanoc
91
98
  # Requires the filter’s required library if necessary.
92
99
  #
93
100
  # @return [void]
101
+ #
102
+ # @api private
94
103
  def setup
95
104
  @setup ||= begin
96
105
  requires.each { |r| require r }
@@ -103,6 +112,8 @@ module Nanoc
103
112
  #
104
113
  # @param [Hash] hash A hash containing variables that should be made
105
114
  # available during filtering.
115
+ #
116
+ # @api private
106
117
  def initialize(hash = {})
107
118
  @assigns = hash
108
119
  super
@@ -112,6 +123,8 @@ module Nanoc
112
123
  # to {#run} unchanged and returns the return value from {#run}.
113
124
  #
114
125
  # @see {#run}
126
+ #
127
+ # @api private
115
128
  def setup_and_run(*args)
116
129
  self.class.setup
117
130
  run(*args)
@@ -145,13 +158,15 @@ module Nanoc
145
158
  # @return [String] The output filename
146
159
  def output_filename
147
160
  @output_filename ||=
148
- Nanoc::TempFilenameFactory.instance.create(TMP_BINARY_ITEMS_DIR)
161
+ Nanoc::Int::TempFilenameFactory.instance.create(TMP_BINARY_ITEMS_DIR)
149
162
  end
150
163
 
151
164
  # Returns the filename associated with the item that is being filtered.
152
165
  # It is in the format `item <identifier> (rep <name>)`.
153
166
  #
154
167
  # @return [String] The filename
168
+ #
169
+ # @api private
155
170
  def filename
156
171
  if assigns[:layout]
157
172
  "layout #{assigns[:layout].identifier}"
@@ -166,20 +181,20 @@ module Nanoc
166
181
  # the given collection of items. In other words, require the given items
167
182
  # to be compiled first before this items is processed.
168
183
  #
169
- # @param [Array<Nanoc::Item>] items The items that are depended on.
184
+ # @param [Array<Nanoc::Int::Item>] items The items that are depended on.
170
185
  #
171
186
  # @return [void]
172
187
  def depend_on(items)
173
188
  # Notify
174
189
  items.each do |item|
175
- Nanoc::NotificationCenter.post(:visit_started, item)
176
- Nanoc::NotificationCenter.post(:visit_ended, item)
190
+ Nanoc::Int::NotificationCenter.post(:visit_started, item)
191
+ Nanoc::Int::NotificationCenter.post(:visit_ended, item)
177
192
  end
178
193
 
179
194
  # Raise unmet dependency error if necessary
180
195
  items.each do |item|
181
196
  rep = item.reps.find { |r| !r.compiled? }
182
- raise Nanoc::Errors::UnmetDependency.new(rep) if rep
197
+ raise Nanoc::Int::Errors::UnmetDependency.new(rep) if rep
183
198
  end
184
199
  end
185
200
  end
@@ -1,23 +1,25 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
3
+ module Nanoc::Int
4
4
  # Represents an item representation, but provides an interface that is
5
5
  # easier to use when writing compilation and routing rules. It is also
6
6
  # responsible for fetching the necessary information from the compiler, such
7
7
  # as assigns.
8
8
  #
9
9
  # The API provided by item representation proxies allows layout identifiers
10
- # to be given as literals instead of as references to {Nanoc::Layout}.
10
+ # to be given as literals instead of as references to {Nanoc::Int::Layout}.
11
+ #
12
+ # @api private
11
13
  class ItemRepProxy
12
14
  extend Forwardable
13
15
 
14
16
  def_delegators :@item_rep, :item, :name, :binary, :binary?, :compiled_content, :has_snapshot?, :raw_path, :path
15
17
  def_delegator :@item_rep, :snapshot
16
18
 
17
- # @param [Nanoc::ItemRep] item_rep The item representation that this
19
+ # @param [Nanoc::Int::ItemRep] item_rep The item representation that this
18
20
  # proxy should behave like
19
21
  #
20
- # @param [Nanoc::Compiler] compiler The compiler that will provide the
22
+ # @param [Nanoc::Int::Compiler] compiler The compiler that will provide the
21
23
  # necessary compilation-related functionality.
22
24
  def initialize(item_rep, compiler)
23
25
  @item_rep = item_rep
@@ -29,9 +31,9 @@ module Nanoc
29
31
  # filtered content of the last snapshot.
30
32
  #
31
33
  # This method is supposed to be called only in a compilation rule block
32
- # (see {Nanoc::CompilerDSL#compile}).
34
+ # (see {Nanoc::Int::CompilerDSL#compile}).
33
35
  #
34
- # @see Nanoc::ItemRep#filter
36
+ # @see Nanoc::Int::ItemRep#filter
35
37
  #
36
38
  # @param [Symbol] name The name of the filter to run the item
37
39
  # representations' content through
@@ -50,9 +52,9 @@ module Nanoc
50
52
  # snapshot.
51
53
  #
52
54
  # This method is supposed to be called only in a compilation rule block
53
- # (see {Nanoc::CompilerDSL#compile}).
55
+ # (see {Nanoc::Int::CompilerDSL#compile}).
54
56
  #
55
- # @see Nanoc::ItemRep#layout
57
+ # @see Nanoc::Int::ItemRep#layout
56
58
  #
57
59
  # @param [String] layout_identifier The identifier of the layout to use
58
60
  #
@@ -74,8 +76,8 @@ module Nanoc
74
76
  #
75
77
  # @return [true]
76
78
  #
77
- # @see Nanoc::ItemRep#proxy?
78
- # @see Nanoc::ItemRepRecorderProxy#proxy?
79
+ # @see Nanoc::Int::ItemRep#proxy?
80
+ # @see Nanoc::Int::ItemRepRecorderProxy#proxy?
79
81
  def proxy?
80
82
  true
81
83
  end
@@ -92,8 +94,8 @@ module Nanoc
92
94
  end
93
95
 
94
96
  def layout_with_identifier(layout_identifier)
95
- layout ||= layouts.find { |l| l.identifier == layout_identifier.cleaned_identifier }
96
- raise Nanoc::Errors::UnknownLayout.new(layout_identifier) if layout.nil?
97
+ layout ||= layouts.find { |l| l.identifier == layout_identifier.__nanoc_cleaned_identifier }
98
+ raise Nanoc::Int::Errors::UnknownLayout.new(layout_identifier) if layout.nil?
97
99
  layout
98
100
  end
99
101
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
3
+ module Nanoc::Int
4
4
  # Represents a fake iem representation that does not actually perform any
5
5
  # actual filtering, layouting or snapshotting, but instead keeps track of
6
6
  # what would happen if a real item representation would have been used
@@ -37,7 +37,7 @@ module Nanoc
37
37
  # @return [Array] The list of recorded actions (“rule memory”)
38
38
  attr_reader :rule_memory
39
39
 
40
- # @param [Nanoc::ItemRep] item_rep The item representation that this
40
+ # @param [Nanoc::Int::ItemRep] item_rep The item representation that this
41
41
  # proxy should behave like
42
42
  def initialize(item_rep)
43
43
  @item_rep = item_rep
@@ -46,14 +46,14 @@ module Nanoc
46
46
 
47
47
  # @return [void]
48
48
  #
49
- # @see Nanoc::ItemRepProxy#filter, Nanoc::ItemRep#filter
49
+ # @see Nanoc::Int::ItemRepProxy#filter, Nanoc::Int::ItemRep#filter
50
50
  def filter(name, args = {})
51
51
  @rule_memory << [:filter, name, args]
52
52
  end
53
53
 
54
54
  # @return [void]
55
55
  #
56
- # @see Nanoc::ItemRepProxy#layout, Nanoc::ItemRep#layout
56
+ # @see Nanoc::Int::ItemRepProxy#layout, Nanoc::Int::ItemRep#layout
57
57
  def layout(layout_identifier, extra_filter_args = nil)
58
58
  if extra_filter_args
59
59
  @rule_memory << [:layout, layout_identifier, extra_filter_args]
@@ -64,7 +64,7 @@ module Nanoc
64
64
 
65
65
  # @return [void]
66
66
  #
67
- # @see Nanoc::ItemRep#snapshot
67
+ # @see Nanoc::Int::ItemRep#snapshot
68
68
  def snapshot(snapshot_name, params = {})
69
69
  @rule_memory << [:snapshot, snapshot_name, params]
70
70
 
@@ -73,7 +73,7 @@ module Nanoc
73
73
  names = @rule_memory.select { |r| r[0] == :snapshot }.map { |r| r[1] }
74
74
  names.each do |n|
75
75
  if existing.include?(n)
76
- raise Nanoc::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, snapshot_name)
76
+ raise Nanoc::Int::Errors::CannotCreateMultipleSnapshotsWithSameName.new(@item_rep, snapshot_name)
77
77
  end
78
78
  existing << n
79
79
  end
@@ -89,8 +89,8 @@ module Nanoc
89
89
  #
90
90
  # @return [true]
91
91
  #
92
- # @see Nanoc::ItemRep#proxy?
93
- # @see Nanoc::ItemRepProxy#proxy?
92
+ # @see Nanoc::Int::ItemRep#proxy?
93
+ # @see Nanoc::Int::ItemRepProxy#proxy?
94
94
  def proxy?
95
95
  true
96
96
  end
@@ -1,29 +1,29 @@
1
1
  # encoding: utf-8
2
2
 
3
- module Nanoc
3
+ module Nanoc::Int
4
4
  # Responsible for determining whether an item or a layout is outdated.
5
5
  #
6
6
  # @api private
7
7
  class OutdatednessChecker
8
- extend Nanoc::Memoization
8
+ extend Nanoc::Int::Memoization
9
9
 
10
- # @option params [Nanoc::Site] :site (nil) The site this outdatedness
10
+ # @option params [Nanoc::Int::Site] :site (nil) The site this outdatedness
11
11
  # checker belongs to.
12
12
  #
13
- # @option params [Nanoc::ChecksumStore] :checksum_store (nil) The
13
+ # @option params [Nanoc::Int::ChecksumStore] :checksum_store (nil) The
14
14
  # checksum store where checksums of items, layouts, … are stored.
15
15
  #
16
- # @option params [Nanoc::DependencyTracker] :dependency_tracker (nil) The
16
+ # @option params [Nanoc::Int::DependencyTracker] :dependency_tracker (nil) The
17
17
  # dependency tracker for the given site.
18
18
  def initialize(params = {})
19
19
  @site = params.fetch(:site) do
20
- raise ArgumentError, 'Nanoc::OutdatednessChecker#initialize needs a :site parameter'
20
+ raise ArgumentError, 'Nanoc::Int::OutdatednessChecker#initialize needs a :site parameter'
21
21
  end
22
22
  @checksum_store = params.fetch(:checksum_store) do
23
- raise ArgumentError, 'Nanoc::OutdatednessChecker#initialize needs a :checksum_store parameter'
23
+ raise ArgumentError, 'Nanoc::Int::OutdatednessChecker#initialize needs a :checksum_store parameter'
24
24
  end
25
25
  @dependency_tracker = params.fetch(:dependency_tracker) do
26
- raise ArgumentError, 'Nanoc::OutdatednessChecker#initialize needs a :dependency_tracker parameter'
26
+ raise ArgumentError, 'Nanoc::Int::OutdatednessChecker#initialize needs a :dependency_tracker parameter'
27
27
  end
28
28
 
29
29
  @basic_outdatedness_reasons = {}
@@ -34,7 +34,7 @@ module Nanoc
34
34
  # Checks whether the given object is outdated and therefore needs to be
35
35
  # recompiled.
36
36
  #
37
- # @param [Nanoc::Item, Nanoc::ItemRep, Nanoc::Layout] obj The object
37
+ # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
38
38
  # whose outdatedness should be checked.
39
39
  #
40
40
  # @return [Boolean] true if the object is outdated, false otherwise
@@ -44,15 +44,15 @@ module Nanoc
44
44
 
45
45
  # Calculates the reason why the given object is outdated.
46
46
  #
47
- # @param [Nanoc::Item, Nanoc::ItemRep, Nanoc::Layout] obj The object
47
+ # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
48
48
  # whose outdatedness reason should be calculated.
49
49
  #
50
- # @return [Nanoc::OutdatednessReasons::Generic, nil] The reason why the
50
+ # @return [Nanoc::Int::OutdatednessReasons::Generic, nil] The reason why the
51
51
  # given object is outdated, or nil if the object is not outdated.
52
52
  def outdatedness_reason_for(obj)
53
53
  reason = basic_outdatedness_reason_for(obj)
54
54
  if reason.nil? && outdated_due_to_dependencies?(obj)
55
- reason = Nanoc::OutdatednessReasons::DependenciesOutdated
55
+ reason = Nanoc::Int::OutdatednessReasons::DependenciesOutdated
56
56
  end
57
57
  reason
58
58
  end
@@ -65,7 +65,7 @@ module Nanoc
65
65
  # {#outdated?} if you want to include dependencies in the outdatedness
66
66
  # check.
67
67
  #
68
- # @param [Nanoc::Item, Nanoc::ItemRep, Nanoc::Layout] obj The object
68
+ # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
69
69
  # whose outdatedness should be checked.
70
70
  #
71
71
  # @return [Boolean] true if the object is outdated, false otherwise
@@ -77,32 +77,32 @@ module Nanoc
77
77
  # not take dependencies into account; use {#outdatedness_reason_for?} if
78
78
  # you want to include dependencies in the outdatedness check.
79
79
  #
80
- # @param [Nanoc::Item, Nanoc::ItemRep, Nanoc::Layout] obj The object
80
+ # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
81
81
  # whose outdatedness reason should be calculated.
82
82
  #
83
- # @return [Nanoc::OutdatednessReasons::Generic, nil] The reason why the
83
+ # @return [Nanoc::Int::OutdatednessReasons::Generic, nil] The reason why the
84
84
  # given object is outdated, or nil if the object is not outdated.
85
85
  def basic_outdatedness_reason_for(obj)
86
86
  case obj.type
87
87
  when :item_rep
88
88
  # Outdated if rules outdated
89
- return Nanoc::OutdatednessReasons::RulesModified if
89
+ return Nanoc::Int::OutdatednessReasons::RulesModified if
90
90
  rule_memory_differs_for(obj)
91
91
 
92
92
  # Outdated if checksums are missing or different
93
- return Nanoc::OutdatednessReasons::NotEnoughData unless checksums_available?(obj.item)
94
- return Nanoc::OutdatednessReasons::SourceModified unless checksums_identical?(obj.item)
93
+ return Nanoc::Int::OutdatednessReasons::NotEnoughData unless checksums_available?(obj.item)
94
+ return Nanoc::Int::OutdatednessReasons::SourceModified unless checksums_identical?(obj.item)
95
95
 
96
96
  # Outdated if compiled file doesn't exist (yet)
97
- return Nanoc::OutdatednessReasons::NotWritten if obj.raw_path && !File.file?(obj.raw_path)
97
+ return Nanoc::Int::OutdatednessReasons::NotWritten if obj.raw_path && !File.file?(obj.raw_path)
98
98
 
99
99
  # Outdated if code snippets outdated
100
- return Nanoc::OutdatednessReasons::CodeSnippetsModified if site.code_snippets.any? do |cs|
100
+ return Nanoc::Int::OutdatednessReasons::CodeSnippetsModified if site.code_snippets.any? do |cs|
101
101
  object_modified?(cs)
102
102
  end
103
103
 
104
104
  # Outdated if configuration outdated
105
- return Nanoc::OutdatednessReasons::ConfigurationModified if object_modified?(site.config)
105
+ return Nanoc::Int::OutdatednessReasons::ConfigurationModified if object_modified?(site.config)
106
106
 
107
107
  # Not outdated
108
108
  return nil
@@ -110,12 +110,12 @@ module Nanoc
110
110
  obj.reps.find { |rep| basic_outdatedness_reason_for(rep) }
111
111
  when :layout
112
112
  # Outdated if rules outdated
113
- return Nanoc::OutdatednessReasons::RulesModified if
113
+ return Nanoc::Int::OutdatednessReasons::RulesModified if
114
114
  rule_memory_differs_for(obj)
115
115
 
116
116
  # Outdated if checksums are missing or different
117
- return Nanoc::OutdatednessReasons::NotEnoughData unless checksums_available?(obj)
118
- return Nanoc::OutdatednessReasons::SourceModified unless checksums_identical?(obj)
117
+ return Nanoc::Int::OutdatednessReasons::NotEnoughData unless checksums_available?(obj)
118
+ return Nanoc::Int::OutdatednessReasons::SourceModified unless checksums_identical?(obj)
119
119
 
120
120
  # Not outdated
121
121
  return nil
@@ -127,7 +127,7 @@ module Nanoc
127
127
 
128
128
  # Checks whether the given object is outdated due to dependencies.
129
129
  #
130
- # @param [Nanoc::Item, Nanoc::ItemRep, Nanoc::Layout] obj The object
130
+ # @param [Nanoc::Int::Item, Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The object
131
131
  # whose outdatedness should be checked.
132
132
  #
133
133
  # @param [Set] processed The collection of items that has been visited
@@ -162,7 +162,7 @@ module Nanoc
162
162
  is_outdated
163
163
  end
164
164
 
165
- # @param [Nanoc::ItemRep, Nanoc::Layout] obj The layout or item
165
+ # @param [Nanoc::Int::ItemRep, Nanoc::Int::Layout] obj The layout or item
166
166
  # representation to check the rule memory for
167
167
  #
168
168
  # @return [Boolean] true if the rule memory for the given item
@@ -177,7 +177,7 @@ module Nanoc
177
177
  # @return [Boolean] false if either the new or the old checksum for the
178
178
  # given object is not available, true if both checksums are available
179
179
  def checksums_available?(obj)
180
- checksum_store[obj] && obj.checksum
180
+ checksum_store[obj] && obj.__nanoc_checksum
181
181
  end
182
182
  memoize :checksums_available?
183
183
 
@@ -186,7 +186,7 @@ module Nanoc
186
186
  # @return [Boolean] false if the old and new checksums for the given
187
187
  # object differ, true if they are identical
188
188
  def checksums_identical?(obj)
189
- checksum_store[obj] == obj.checksum
189
+ checksum_store[obj] == obj.__nanoc_checksum
190
190
  end
191
191
  memoize :checksums_identical?
192
192
 
@@ -199,22 +199,22 @@ module Nanoc
199
199
  end
200
200
  memoize :object_modified?
201
201
 
202
- # @return [Nanoc::ChecksumStore] The checksum store
202
+ # @return [Nanoc::Int::ChecksumStore] The checksum store
203
203
  def checksum_store
204
204
  @checksum_store
205
205
  end
206
206
 
207
- # @return [Nanoc::RulesCollection] The rules collection
207
+ # @return [Nanoc::Int::RulesCollection] The rules collection
208
208
  def rules_collection
209
209
  site.compiler.rules_collection
210
210
  end
211
211
 
212
- # @return [Nanoc::DependencyTracker] The dependency tracker
212
+ # @return [Nanoc::Int::DependencyTracker] The dependency tracker
213
213
  def dependency_tracker
214
214
  @dependency_tracker
215
215
  end
216
216
 
217
- # @return [Nanoc::Site] The site
217
+ # @return [Nanoc::Int::Site] The site
218
218
  def site
219
219
  @site
220
220
  end