nanoc 3.7.4 → 3.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +19 -18
  3. data/LICENSE +1 -1
  4. data/NEWS.md +14 -0
  5. data/Rakefile +1 -1
  6. data/doc/yardoc_handlers/identifier.rb +1 -5
  7. data/lib/nanoc.rb +1 -3
  8. data/lib/nanoc/base.rb +1 -4
  9. data/lib/nanoc/base/checksummer.rb +10 -12
  10. data/lib/nanoc/base/compilation/checksum_store.rb +0 -4
  11. data/lib/nanoc/base/compilation/compiled_content_cache.rb +0 -4
  12. data/lib/nanoc/base/compilation/compiler.rb +27 -31
  13. data/lib/nanoc/base/compilation/compiler_dsl.rb +3 -7
  14. data/lib/nanoc/base/compilation/dependency_tracker.rb +2 -6
  15. data/lib/nanoc/base/compilation/filter.rb +1 -7
  16. data/lib/nanoc/base/compilation/item_rep_proxy.rb +0 -4
  17. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +0 -4
  18. data/lib/nanoc/base/compilation/outdatedness_checker.rb +0 -4
  19. data/lib/nanoc/base/compilation/outdatedness_reasons.rb +0 -6
  20. data/lib/nanoc/base/compilation/rule.rb +1 -5
  21. data/lib/nanoc/base/compilation/rule_context.rb +7 -11
  22. data/lib/nanoc/base/compilation/rule_memory_calculator.rb +0 -4
  23. data/lib/nanoc/base/compilation/rule_memory_store.rb +0 -4
  24. data/lib/nanoc/base/compilation/rules_collection.rb +5 -9
  25. data/lib/nanoc/base/context.rb +0 -3
  26. data/lib/nanoc/base/core_ext.rb +0 -1
  27. data/lib/nanoc/base/core_ext/array.rb +0 -2
  28. data/lib/nanoc/base/core_ext/hash.rb +0 -2
  29. data/lib/nanoc/base/core_ext/pathname.rb +0 -2
  30. data/lib/nanoc/base/core_ext/string.rb +0 -2
  31. data/lib/nanoc/base/directed_graph.rb +0 -4
  32. data/lib/nanoc/base/errors.rb +1 -39
  33. data/lib/nanoc/base/memoization.rb +0 -4
  34. data/lib/nanoc/base/notification_center.rb +1 -7
  35. data/lib/nanoc/base/plugin_registry.rb +4 -10
  36. data/lib/nanoc/base/result_data/item_rep.rb +8 -16
  37. data/lib/nanoc/base/source_data/code_snippet.rb +1 -5
  38. data/lib/nanoc/base/source_data/configuration.rb +0 -4
  39. data/lib/nanoc/base/source_data/data_source.rb +2 -5
  40. data/lib/nanoc/base/source_data/item.rb +3 -7
  41. data/lib/nanoc/base/source_data/item_array.rb +1 -5
  42. data/lib/nanoc/base/source_data/layout.rb +2 -6
  43. data/lib/nanoc/base/source_data/site.rb +20 -23
  44. data/lib/nanoc/base/store.rb +1 -5
  45. data/lib/nanoc/base/temp_filename_factory.rb +0 -4
  46. data/lib/nanoc/cli.rb +3 -5
  47. data/lib/nanoc/cli/ansi_string_colorizer.rb +6 -10
  48. data/lib/nanoc/cli/cleaning_stream.rb +2 -6
  49. data/lib/nanoc/cli/command_runner.rb +1 -5
  50. data/lib/nanoc/cli/commands/autocompile.rb +2 -6
  51. data/lib/nanoc/cli/commands/check.rb +0 -4
  52. data/lib/nanoc/cli/commands/compile.rb +12 -27
  53. data/lib/nanoc/cli/commands/create-item.rb +1 -5
  54. data/lib/nanoc/cli/commands/create-layout.rb +0 -4
  55. data/lib/nanoc/cli/commands/create-site.rb +2 -8
  56. data/lib/nanoc/cli/commands/deploy.rb +3 -7
  57. data/lib/nanoc/cli/commands/prune.rb +2 -6
  58. data/lib/nanoc/cli/commands/shell.rb +4 -8
  59. data/lib/nanoc/cli/commands/show-data.rb +3 -7
  60. data/lib/nanoc/cli/commands/show-plugins.rb +3 -7
  61. data/lib/nanoc/cli/commands/show-rules.rb +11 -15
  62. data/lib/nanoc/cli/commands/sync.rb +0 -4
  63. data/lib/nanoc/cli/commands/update.rb +1 -7
  64. data/lib/nanoc/cli/commands/validate-css.rb +0 -4
  65. data/lib/nanoc/cli/commands/validate-html.rb +0 -4
  66. data/lib/nanoc/cli/commands/validate-links.rb +0 -4
  67. data/lib/nanoc/cli/commands/view.rb +3 -7
  68. data/lib/nanoc/cli/commands/watch.rb +4 -10
  69. data/lib/nanoc/cli/error_handler.rb +9 -13
  70. data/lib/nanoc/cli/logger.rb +8 -12
  71. data/lib/nanoc/cli/stream_cleaners.rb +0 -4
  72. data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -5
  73. data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +0 -4
  74. data/lib/nanoc/cli/stream_cleaners/utf8.rb +1 -5
  75. data/lib/nanoc/data_sources.rb +2 -4
  76. data/lib/nanoc/data_sources/deprecated/delicious.rb +6 -10
  77. data/lib/nanoc/data_sources/deprecated/last_fm.rb +7 -11
  78. data/lib/nanoc/data_sources/deprecated/twitter.rb +2 -6
  79. data/lib/nanoc/data_sources/filesystem.rb +10 -13
  80. data/lib/nanoc/data_sources/filesystem_unified.rb +0 -4
  81. data/lib/nanoc/data_sources/filesystem_verbose.rb +0 -4
  82. data/lib/nanoc/data_sources/static.rb +4 -8
  83. data/lib/nanoc/extra.rb +2 -4
  84. data/lib/nanoc/extra/auto_compiler.rb +2 -6
  85. data/lib/nanoc/extra/checking.rb +0 -4
  86. data/lib/nanoc/extra/checking/check.rb +0 -4
  87. data/lib/nanoc/extra/checking/checks.rb +0 -2
  88. data/lib/nanoc/extra/checking/checks/css.rb +6 -6
  89. data/lib/nanoc/extra/checking/checks/external_links.rb +3 -11
  90. data/lib/nanoc/extra/checking/checks/html.rb +6 -6
  91. data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -7
  92. data/lib/nanoc/extra/checking/checks/stale.rb +3 -7
  93. data/lib/nanoc/extra/checking/dsl.rb +0 -4
  94. data/lib/nanoc/extra/checking/issue.rb +0 -4
  95. data/lib/nanoc/extra/checking/runner.rb +4 -7
  96. data/lib/nanoc/extra/chick.rb +7 -17
  97. data/lib/nanoc/extra/core_ext.rb +0 -1
  98. data/lib/nanoc/extra/core_ext/pathname.rb +0 -4
  99. data/lib/nanoc/extra/core_ext/time.rb +0 -2
  100. data/lib/nanoc/extra/deployer.rb +0 -4
  101. data/lib/nanoc/extra/deployers.rb +0 -4
  102. data/lib/nanoc/extra/deployers/fog.rb +7 -11
  103. data/lib/nanoc/extra/deployers/rsync.rb +1 -5
  104. data/lib/nanoc/extra/file_proxy.rb +1 -5
  105. data/lib/nanoc/extra/filesystem_tools.rb +37 -12
  106. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +0 -4
  107. data/lib/nanoc/extra/link_collector.rb +3 -7
  108. data/lib/nanoc/extra/piper.rb +0 -6
  109. data/lib/nanoc/extra/pruner.rb +1 -7
  110. data/lib/nanoc/extra/validators.rb +0 -4
  111. data/lib/nanoc/extra/validators/links.rb +0 -4
  112. data/lib/nanoc/extra/validators/w3c.rb +0 -4
  113. data/lib/nanoc/extra/vcs.rb +3 -7
  114. data/lib/nanoc/extra/vcses.rb +0 -2
  115. data/lib/nanoc/extra/vcses/bazaar.rb +0 -4
  116. data/lib/nanoc/extra/vcses/dummy.rb +0 -4
  117. data/lib/nanoc/extra/vcses/git.rb +0 -4
  118. data/lib/nanoc/extra/vcses/mercurial.rb +0 -4
  119. data/lib/nanoc/extra/vcses/subversion.rb +0 -4
  120. data/lib/nanoc/filters.rb +0 -2
  121. data/lib/nanoc/filters/asciidoc.rb +1 -5
  122. data/lib/nanoc/filters/bluecloth.rb +0 -2
  123. data/lib/nanoc/filters/coderay.rb +0 -2
  124. data/lib/nanoc/filters/coffeescript.rb +0 -4
  125. data/lib/nanoc/filters/colorize_syntax.rb +17 -15
  126. data/lib/nanoc/filters/erb.rb +1 -3
  127. data/lib/nanoc/filters/erubis.rb +2 -4
  128. data/lib/nanoc/filters/haml.rb +2 -4
  129. data/lib/nanoc/filters/handlebars.rb +0 -4
  130. data/lib/nanoc/filters/kramdown.rb +7 -4
  131. data/lib/nanoc/filters/less.rb +1 -3
  132. data/lib/nanoc/filters/markaby.rb +0 -2
  133. data/lib/nanoc/filters/maruku.rb +0 -2
  134. data/lib/nanoc/filters/mustache.rb +1 -5
  135. data/lib/nanoc/filters/pandoc.rb +0 -2
  136. data/lib/nanoc/filters/rainpress.rb +0 -2
  137. data/lib/nanoc/filters/rdiscount.rb +0 -2
  138. data/lib/nanoc/filters/rdoc.rb +0 -2
  139. data/lib/nanoc/filters/redcarpet.rb +0 -4
  140. data/lib/nanoc/filters/redcloth.rb +0 -2
  141. data/lib/nanoc/filters/relativize_paths.rb +2 -4
  142. data/lib/nanoc/filters/rubypants.rb +0 -2
  143. data/lib/nanoc/filters/sass.rb +2 -4
  144. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +0 -2
  145. data/lib/nanoc/filters/slim.rb +2 -6
  146. data/lib/nanoc/filters/typogruby.rb +0 -4
  147. data/lib/nanoc/filters/uglify_js.rb +0 -2
  148. data/lib/nanoc/filters/xsl.rb +1 -5
  149. data/lib/nanoc/filters/yui_compressor.rb +0 -4
  150. data/lib/nanoc/helpers.rb +0 -2
  151. data/lib/nanoc/helpers/blogging.rb +12 -20
  152. data/lib/nanoc/helpers/breadcrumbs.rb +0 -4
  153. data/lib/nanoc/helpers/capturing.rb +2 -10
  154. data/lib/nanoc/helpers/filtering.rb +0 -4
  155. data/lib/nanoc/helpers/html_escape.rb +3 -7
  156. data/lib/nanoc/helpers/link_to.rb +0 -4
  157. data/lib/nanoc/helpers/rendering.rb +8 -12
  158. data/lib/nanoc/helpers/tagging.rb +0 -4
  159. data/lib/nanoc/helpers/text.rb +1 -5
  160. data/lib/nanoc/helpers/xml_sitemap.rb +3 -7
  161. data/lib/nanoc/tasks/clean.rb +1 -7
  162. data/lib/nanoc/tasks/deploy/rsync.rake +0 -2
  163. data/lib/nanoc/tasks/validate.rake +0 -4
  164. data/lib/nanoc/version.rb +1 -3
  165. data/nanoc.gemspec +12 -9
  166. data/tasks/rubocop.rake +1 -1
  167. data/tasks/test.rake +6 -7
  168. data/test/base/checksummer_spec.rb +28 -44
  169. data/test/base/core_ext/array_spec.rb +1 -9
  170. data/test/base/core_ext/hash_spec.rb +7 -19
  171. data/test/base/core_ext/pathname_spec.rb +2 -4
  172. data/test/base/core_ext/string_spec.rb +0 -4
  173. data/test/base/temp_filename_factory_spec.rb +0 -8
  174. data/test/base/test_checksum_store.rb +0 -2
  175. data/test/base/test_code_snippet.rb +0 -2
  176. data/test/base/test_compiler.rb +15 -17
  177. data/test/base/test_compiler_dsl.rb +7 -9
  178. data/test/base/test_context.rb +2 -4
  179. data/test/base/test_data_source.rb +0 -2
  180. data/test/base/test_dependency_tracker.rb +0 -2
  181. data/test/base/test_directed_graph.rb +2 -4
  182. data/test/base/test_filter.rb +5 -7
  183. data/test/base/test_item.rb +17 -13
  184. data/test/base/test_item_array.rb +2 -4
  185. data/test/base/test_item_rep.rb +79 -73
  186. data/test/base/test_layout.rb +3 -5
  187. data/test/base/test_memoization.rb +13 -21
  188. data/test/base/test_notification_center.rb +0 -2
  189. data/test/base/test_outdatedness_checker.rb +34 -36
  190. data/test/base/test_plugin.rb +0 -2
  191. data/test/base/test_rule.rb +3 -5
  192. data/test/base/test_rule_context.rb +4 -6
  193. data/test/base/test_site.rb +9 -17
  194. data/test/base/test_store.rb +2 -6
  195. data/test/cli/commands/test_check.rb +1 -3
  196. data/test/cli/commands/test_compile.rb +24 -15
  197. data/test/cli/commands/test_create_item.rb +1 -3
  198. data/test/cli/commands/test_create_layout.rb +0 -2
  199. data/test/cli/commands/test_create_site.rb +0 -3
  200. data/test/cli/commands/test_deploy.rb +9 -11
  201. data/test/cli/commands/test_help.rb +0 -2
  202. data/test/cli/commands/test_info.rb +0 -2
  203. data/test/cli/commands/test_prune.rb +6 -8
  204. data/test/cli/commands/test_sync.rb +0 -2
  205. data/test/cli/commands/test_update.rb +0 -2
  206. data/test/cli/commands/test_watch.rb +4 -6
  207. data/test/cli/test_cleaning_stream.rb +4 -6
  208. data/test/cli/test_cli.rb +9 -5
  209. data/test/cli/test_error_handler.rb +9 -7
  210. data/test/cli/test_logger.rb +0 -2
  211. data/test/data_sources/test_filesystem.rb +8 -10
  212. data/test/data_sources/test_filesystem_unified.rb +35 -34
  213. data/test/data_sources/test_filesystem_verbose.rb +31 -33
  214. data/test/data_sources/test_static.rb +20 -21
  215. data/test/extra/checking/checks/test_css.rb +23 -2
  216. data/test/extra/checking/checks/test_external_links.rb +2 -4
  217. data/test/extra/checking/checks/test_html.rb +4 -3
  218. data/test/extra/checking/checks/test_internal_links.rb +1 -3
  219. data/test/extra/checking/checks/test_stale.rb +4 -6
  220. data/test/extra/checking/test_check.rb +0 -2
  221. data/test/extra/checking/test_dsl.rb +1 -3
  222. data/test/extra/checking/test_runner.rb +0 -2
  223. data/test/extra/core_ext/test_pathname.rb +0 -3
  224. data/test/extra/core_ext/test_time.rb +0 -2
  225. data/test/extra/deployers/test_fog.rb +13 -15
  226. data/test/extra/deployers/test_rsync.rb +4 -6
  227. data/test/extra/test_auto_compiler.rb +47 -25
  228. data/test/extra/test_file_proxy.rb +1 -3
  229. data/test/extra/test_filesystem_tools.rb +47 -7
  230. data/test/extra/test_link_collector.rb +0 -2
  231. data/test/extra/test_piper.rb +3 -5
  232. data/test/extra/test_vcs.rb +0 -2
  233. data/test/extra/validators/test_links.rb +0 -1
  234. data/test/extra/validators/test_w3c.rb +2 -4
  235. data/test/filters/test_asciidoc.rb +0 -2
  236. data/test/filters/test_bluecloth.rb +0 -2
  237. data/test/filters/test_coderay.rb +2 -4
  238. data/test/filters/test_coffeescript.rb +0 -2
  239. data/test/filters/test_colorize_syntax.rb +16 -18
  240. data/test/filters/test_erb.rb +12 -14
  241. data/test/filters/test_erubis.rb +4 -6
  242. data/test/filters/test_haml.rb +7 -9
  243. data/test/filters/test_handlebars.rb +10 -12
  244. data/test/filters/test_kramdown.rb +13 -1
  245. data/test/filters/test_less.rb +9 -11
  246. data/test/filters/test_markaby.rb +0 -2
  247. data/test/filters/test_maruku.rb +0 -2
  248. data/test/filters/test_mustache.rb +4 -6
  249. data/test/filters/test_pandoc.rb +1 -3
  250. data/test/filters/test_rainpress.rb +1 -3
  251. data/test/filters/test_rdiscount.rb +1 -3
  252. data/test/filters/test_rdoc.rb +0 -2
  253. data/test/filters/test_redcarpet.rb +6 -8
  254. data/test/filters/test_redcloth.rb +1 -3
  255. data/test/filters/test_relativize_paths.rb +29 -34
  256. data/test/filters/test_rubypants.rb +0 -2
  257. data/test/filters/test_sass.rb +8 -10
  258. data/test/filters/test_slim.rb +2 -4
  259. data/test/filters/test_typogruby.rb +0 -3
  260. data/test/filters/test_uglify_js.rb +2 -4
  261. data/test/filters/test_xsl.rb +16 -18
  262. data/test/filters/test_yui_compressor.rb +3 -5
  263. data/test/fixtures/vcr_cassettes/css_run_parse_error.yml +65 -0
  264. data/test/gem_loader.rb +1 -1
  265. data/test/helper.rb +11 -15
  266. data/test/helpers/test_blogging.rb +61 -63
  267. data/test/helpers/test_breadcrumbs.rb +0 -2
  268. data/test/helpers/test_capturing.rb +4 -6
  269. data/test/helpers/test_filtering.rb +2 -4
  270. data/test/helpers/test_html_escape.rb +0 -2
  271. data/test/helpers/test_link_to.rb +5 -6
  272. data/test/helpers/test_rendering.rb +2 -4
  273. data/test/helpers/test_tagging.rb +9 -11
  274. data/test/helpers/test_text.rb +6 -8
  275. data/test/helpers/test_xml_sitemap.rb +11 -13
  276. data/test/tasks/test_clean.rb +0 -2
  277. data/test/test_gem.rb +1 -3
  278. metadata +15 -14
  279. data/Gemfile.lock +0 -252
  280. data/lib/nanoc/base/core_ext/date.rb +0 -29
  281. data/lib/nanoc/base/ordered_hash.rb +0 -228
  282. data/lib/nanoc/extra/core_ext/enumerable.rb +0 -33
  283. data/test/base/core_ext/date_spec.rb +0 -15
  284. data/test/extra/core_ext/test_enumerable.rb +0 -28
@@ -1,11 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Provides support for breadcrumbs, which allow the user to go up in the
6
5
  # page hierarchy.
7
6
  module Breadcrumbs
8
-
9
7
  # Creates a breadcrumb trail leading from the current item to its parent,
10
8
  # to its parent’s parent, etc, until the root item is reached. This
11
9
  # function does not require that each intermediate item exist; for
@@ -29,7 +27,5 @@ module Nanoc::Helpers
29
27
 
30
28
  trail
31
29
  end
32
-
33
30
  end
34
-
35
31
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Provides functionality for “capturing” content in one place and reusing
6
5
  # this content elsewhere.
7
6
  #
@@ -35,10 +34,8 @@ module Nanoc::Helpers
35
34
  # <%= @item[:content_for_summary] || '(no summary)' %>
36
35
  # </div>
37
36
  module Capturing
38
-
39
37
  # @api private
40
38
  class CapturesStore
41
-
42
39
  def initialize
43
40
  @store = {}
44
41
  end
@@ -52,11 +49,9 @@ module Nanoc::Helpers
52
49
  @store[item.identifier] ||= {}
53
50
  @store[item.identifier][name]
54
51
  end
55
-
56
52
  end
57
53
 
58
54
  class ::Nanoc::Site
59
-
60
55
  # @api private
61
56
  def captures_store
62
57
  @captures_store ||= CapturesStore.new
@@ -67,7 +62,6 @@ module Nanoc::Helpers
67
62
  require 'set'
68
63
  @captures_store_compiled_items ||= Set.new
69
64
  end
70
-
71
65
  end
72
66
 
73
67
  # @overload content_for(name, &block)
@@ -127,13 +121,13 @@ module Nanoc::Helpers
127
121
  # This is an extremely ugly hack to get the compiler to recompile the
128
122
  # item from which we use content. For this, we need to manually edit
129
123
  # the content attribute to reset it. :(
130
- # FIXME clean this up
124
+ # FIXME: clean this up
131
125
  unless @site.captures_store_compiled_items.include? item
132
126
  @site.captures_store_compiled_items << item
133
127
  item.forced_outdated = true
134
128
  item.reps.each do |r|
135
129
  raw_content = item.raw_content
136
- r.content = { :raw => raw_content, :last => raw_content }
130
+ r.content = { raw: raw_content, last: raw_content }
137
131
  raise Nanoc::Errors::UnmetDependency.new(r)
138
132
  end
139
133
  end
@@ -169,7 +163,5 @@ module Nanoc::Helpers
169
163
  # Done.
170
164
  erbout_addition
171
165
  end
172
-
173
166
  end
174
-
175
167
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Provides functionality for filtering parts of an item or a layout.
6
5
  module Filtering
7
-
8
6
  require 'nanoc/helpers/capturing'
9
7
  include Nanoc::Helpers::Capturing
10
8
 
@@ -46,7 +44,5 @@ module Nanoc::Helpers
46
44
  buffer = eval('_erbout', block.binding)
47
45
  buffer << filtered_data
48
46
  end
49
-
50
47
  end
51
-
52
48
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Contains functionality for HTML-escaping strings.
6
5
  module HTMLEscape
7
-
8
6
  require 'nanoc/helpers/capturing'
9
7
  include Nanoc::Helpers::Capturing
10
8
 
@@ -39,9 +37,9 @@ module Nanoc::Helpers
39
37
  buffer << escaped_data
40
38
  elsif string
41
39
  string.gsub('&', '&amp;')
42
- .gsub('<', '&lt;')
43
- .gsub('>', '&gt;')
44
- .gsub('"', '&quot;')
40
+ .gsub('<', '&lt;')
41
+ .gsub('>', '&gt;')
42
+ .gsub('"', '&quot;')
45
43
  else
46
44
  raise 'The #html_escape or #h function needs either a ' \
47
45
  'string or a block to HTML-escape, but neither a string nor a block was given'
@@ -49,7 +47,5 @@ module Nanoc::Helpers
49
47
  end
50
48
 
51
49
  alias_method :h, :html_escape
52
-
53
50
  end
54
-
55
51
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Contains functions for linking to items and item representations.
6
5
  module LinkTo
7
-
8
6
  require 'nanoc/helpers/html_escape'
9
7
  include Nanoc::Helpers::HTMLEscape
10
8
 
@@ -154,7 +152,5 @@ module Nanoc::Helpers
154
152
  # Done
155
153
  relative_path
156
154
  end
157
-
158
155
  end
159
-
160
156
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Provides functionality for rendering layouts as partials.
6
5
  module Rendering
7
-
8
6
  include Nanoc::Helpers::Capturing
9
7
 
10
8
  # Renders the given layout. The given layout will be run through the first
@@ -91,14 +89,14 @@ module Nanoc::Helpers
91
89
 
92
90
  # Get assigns
93
91
  assigns = {
94
- :content => captured_content,
95
- :item => @item,
96
- :item_rep => @item_rep,
97
- :items => @items,
98
- :layout => layout,
99
- :layouts => @layouts,
100
- :config => @config,
101
- :site => @site
92
+ content: captured_content,
93
+ item: @item,
94
+ item_rep: @item_rep,
95
+ items: @items,
96
+ layout: layout,
97
+ layouts: @layouts,
98
+ config: @config,
99
+ site: @site
102
100
  }.merge(other_assigns)
103
101
 
104
102
  # Get filter name
@@ -134,7 +132,5 @@ module Nanoc::Helpers
134
132
  Nanoc::NotificationCenter.post(:processing_ended, layout)
135
133
  end
136
134
  end
137
-
138
135
  end
139
-
140
136
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Provides support for managing tags added to items.
6
5
  #
7
6
  # To add tags to items, set the `tags` attribute to an array of tags that
@@ -11,7 +10,6 @@ module Nanoc::Helpers
11
10
  #
12
11
  # tags: [ 'foo', 'bar', 'baz' ]
13
12
  module Tagging
14
-
15
13
  require 'nanoc/helpers/html_escape'
16
14
  include Nanoc::Helpers::HTMLEscape
17
15
 
@@ -65,7 +63,5 @@ module Nanoc::Helpers
65
63
  def link_for_tag(tag, base_url)
66
64
  %(<a href="#{h base_url}#{h tag}" rel="tag">#{h tag}</a>)
67
65
  end
68
-
69
66
  end
70
-
71
67
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Contains several useful text-related helper functions.
6
5
  module Text
7
-
8
6
  # Returns an excerpt for the given string. HTML tags are ignored, so if
9
7
  # you don't want them to turn up, they should be stripped from the string
10
8
  # before passing it to the excerpt function.
@@ -35,10 +33,8 @@ module Nanoc::Helpers
35
33
  #
36
34
  # @return [String] The given string with all HTML stripped
37
35
  def strip_html(string)
38
- # FIXME will need something more sophisticated than this, because it sucks
36
+ # FIXME: will need something more sophisticated than this, because it sucks
39
37
  string.gsub(/<[^>]*(>+|\s*\z)/m, '').strip
40
38
  end
41
-
42
39
  end
43
-
44
40
  end
@@ -1,12 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Helpers
4
-
5
4
  # Contains functionality for building XML sitemaps that will be crawled by
6
5
  # search engines. See the [Sitemaps protocol site](http://www.sitemaps.org)
7
6
  # for details.
8
7
  module XMLSitemap
9
-
10
8
  # Builds an XML sitemap and returns it.
11
9
  #
12
10
  # The following attributes can optionally be set on items to change the
@@ -48,7 +46,7 @@ module Nanoc::Helpers
48
46
 
49
47
  # Create builder
50
48
  buffer = ''
51
- xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)
49
+ xml = Builder::XmlMarkup.new(target: buffer, indent: 2)
52
50
 
53
51
  # Check for required attributes
54
52
  if @site.config[:base_url].nil?
@@ -57,9 +55,9 @@ module Nanoc::Helpers
57
55
 
58
56
  # Build sitemap
59
57
  xml.instruct!
60
- xml.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') do
58
+ xml.urlset(xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9') do
61
59
  # Add item
62
- items.sort_by { |i| i.identifier }.each do |item|
60
+ items.sort_by(&:identifier).each do |item|
63
61
  reps = item.reps.reject { |r| r.raw_path.nil? }
64
62
  reps.reject! { |r| !select_proc[r] } if select_proc
65
63
  reps.sort_by { |r| r.name.to_s }.each do |rep|
@@ -76,7 +74,5 @@ module Nanoc::Helpers
76
74
  # Return sitemap
77
75
  buffer
78
76
  end
79
-
80
77
  end
81
-
82
78
  end
@@ -1,9 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::Tasks
4
-
5
4
  class Clean
6
-
7
5
  def initialize(site)
8
6
  @site = site
9
7
  end
@@ -18,12 +16,8 @@ module Nanoc::Tasks
18
16
 
19
17
  def filenames
20
18
  @site.items.map do |item|
21
- item.reps.map do |rep|
22
- rep.raw_path
23
- end
19
+ item.reps.map(&:raw_path)
24
20
  end.flatten
25
21
  end
26
-
27
22
  end
28
-
29
23
  end
@@ -3,7 +3,6 @@
3
3
  require 'nanoc/cli'
4
4
 
5
5
  namespace :deploy do
6
-
7
6
  desc 'Upload the compiled site using rsync'
8
7
  task :rsync do
9
8
  dry_run = ENV['dry_run']
@@ -14,5 +13,4 @@ namespace :deploy do
14
13
 
15
14
  Nanoc::CLI.run cmd
16
15
  end
17
-
18
16
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  namespace :validate do
4
-
5
4
  desc 'Validate the site’s HTML files'
6
5
  task :html do
7
6
  Nanoc::CLI.run %w( validate_html )
@@ -13,7 +12,6 @@ namespace :validate do
13
12
  end
14
13
 
15
14
  namespace :links do
16
-
17
15
  desc 'Validate the site’s internal links'
18
16
  task :internal do
19
17
  Nanoc::CLI.run %w( validate_links --internal )
@@ -23,12 +21,10 @@ namespace :validate do
23
21
  task :external do
24
22
  Nanoc::CLI.run %w( validate_links --external )
25
23
  end
26
-
27
24
  end
28
25
 
29
26
  desc 'Validate the site’s internal and external links'
30
27
  task :links do
31
28
  Nanoc::CLI.run %w( validate_links )
32
29
  end
33
-
34
30
  end
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # The current nanoc version.
6
- VERSION = '3.7.4'
7
-
5
+ VERSION = '3.7.5'
8
6
  end
@@ -14,17 +14,20 @@ Gem::Specification.new do |s|
14
14
  s.email = 'denis.defreyne@stoneship.org'
15
15
  s.license = 'MIT'
16
16
 
17
- s.files = Dir['[A-Z]*'] +
18
- Dir['doc/yardoc_{templates,handlers}/**/*'] +
19
- Dir['{bin,lib,tasks,test}/**/*'] +
20
- [ 'nanoc.gemspec' ]
21
- s.executables = [ 'nanoc' ]
22
- s.require_paths = [ 'lib' ]
17
+ s.files =
18
+ Dir['[A-Z]*'] +
19
+ Dir['doc/yardoc_{templates,handlers}/**/*'] +
20
+ Dir['{bin,lib,tasks,test}/**/*'] +
21
+ ['nanoc.gemspec']
22
+ s.executables = ['nanoc']
23
+ s.require_paths = ['lib']
23
24
 
24
- s.rdoc_options = [ '--main', 'README.md' ]
25
- s.extra_rdoc_files = [ 'ChangeLog', 'LICENSE', 'README.md', 'NEWS.md' ]
25
+ s.rdoc_options = ['--main', 'README.md']
26
+ s.extra_rdoc_files = ['ChangeLog', 'LICENSE', 'README.md', 'NEWS.md']
27
+
28
+ s.required_ruby_version = '>= 1.9.3'
26
29
 
27
30
  s.add_runtime_dependency('cri', '~> 2.3')
28
31
 
29
- s.add_development_dependency('bundler', '~> 1.5')
32
+ s.add_development_dependency('bundler', '>= 1.7.10', '< 2.0')
30
33
  end
@@ -6,5 +6,5 @@ begin
6
6
  task.patterns = ['lib/**/*.rb']
7
7
  end
8
8
  rescue LoadError
9
- warn "Could not load RuboCop. RuboCop rake tasks will be unavailable."
9
+ warn 'Could not load RuboCop. RuboCop rake tasks will be unavailable.'
10
10
  end
@@ -12,26 +12,25 @@ def run_tests(dir_glob)
12
12
  test_files = Dir["#{dir_glob}*_spec.rb"] + Dir["#{dir_glob}test_*.rb"]
13
13
  test_files.each { |f| require f }
14
14
 
15
- exit MiniTest::Unit.new.run(ENV['ARGS'].split)
15
+ res = MiniTest::Unit.new.run(ENV['ARGS'].split)
16
+ exit(res) if res != 0
16
17
  end
17
18
 
18
19
  namespace :test do
19
-
20
20
  # test:all
21
21
  desc 'Run all tests'
22
22
  task :all do
23
- run_tests "test/**/"
23
+ run_tests 'test/**/'
24
24
  end
25
25
 
26
26
  # test:...
27
27
  %w( base cli data_sources extra filters helpers tasks ).each do |dir|
28
28
  desc "Run all #{dir} tests"
29
- task dir.to_sym do |task|
29
+ task dir.to_sym do |_task|
30
30
  run_tests "test/#{dir}/**/"
31
31
  end
32
32
  end
33
-
34
33
  end
35
34
 
36
- desc 'Alias for test:all'
37
- task :test => [ :'test:all' ]
35
+ desc 'Alias for test:all + rubocop'
36
+ task test: [:'test:all', :rubocop]
@@ -3,21 +3,17 @@
3
3
  require 'tempfile'
4
4
 
5
5
  describe Nanoc::Checksummer do
6
-
7
6
  subject { Nanoc::Checksummer }
8
7
 
9
8
  CHECKSUM_REGEX = /\A[0-9a-zA-Z\/+]+=*\Z/
10
9
 
11
10
  describe 'for String' do
12
-
13
11
  it 'should checksum strings' do
14
12
  subject.calc('foo').must_equal('+5k/BWvkYc6T1qhGaSyf3861CyE=')
15
13
  end
16
-
17
14
  end
18
15
 
19
16
  describe 'for Array' do
20
-
21
17
  it 'should checksum arrays' do
22
18
  subject.calc([1, 'a', :a]).must_equal 'YtWOEFUAMQritkY38KXHFZM/n2E='
23
19
  end
@@ -30,10 +26,14 @@ describe Nanoc::Checksummer do
30
26
  subject.calc([-> {}]).must_match(CHECKSUM_REGEX)
31
27
  end
32
28
 
29
+ it 'should checksum recursive arrays' do
30
+ array = [:a]
31
+ array << array
32
+ subject.calc(array).must_equal('mR3c98xA5ecazxx+M3h0Ss4/J20=')
33
+ end
33
34
  end
34
35
 
35
36
  describe 'for Hash' do
36
-
37
37
  it 'should checksum hashes' do
38
38
  subject.calc({ a: 1, b: 2 }).must_equal 'qY8fW6gWK7F1XQ9MLrx3Gru/RTY='
39
39
  end
@@ -43,18 +43,28 @@ describe Nanoc::Checksummer do
43
43
  end
44
44
 
45
45
  it 'should checksum non-serializable hashes' do
46
- subject.calc({ a: ->{} }).must_match(CHECKSUM_REGEX)
46
+ subject.calc({ a: -> {} }).must_match(CHECKSUM_REGEX)
47
47
  end
48
48
 
49
+ it 'should checksum recursive hash keys' do
50
+ hash = {}
51
+ hash[hash] = 123
52
+ subject.calc(hash).must_equal('mKucWMhRtR/FHWNqR/EErF4qgTk=')
53
+ end
54
+
55
+ it 'should checksum recursive hash values' do
56
+ hash = {}
57
+ hash[123] = hash
58
+ subject.calc(hash).must_equal('PBiDX0nWnV+DAYB+w+xM0Kf21ZM=')
59
+ end
49
60
  end
50
61
 
51
62
  describe 'for Pathname' do
52
-
53
63
  let(:file) { Tempfile.new('foo') }
54
64
  let(:filename) { file.path }
55
65
  let(:pathname) { Pathname.new(filename) }
56
- let(:atime) { 1234567890 }
57
- let(:mtime) { 1234567890 }
66
+ let(:atime) { 1_234_567_890 }
67
+ let(:mtime) { 1_234_567_890 }
58
68
  let(:data) { 'stuffs' }
59
69
  let(:normal_checksum) { 'THy7Y28oroov/KvPxT6wcMnXr/s=' }
60
70
 
@@ -69,14 +79,12 @@ describe Nanoc::Checksummer do
69
79
  end
70
80
 
71
81
  describe 'does not exist' do
72
-
73
82
  let(:non_existing_filename) { 'askldjfklaslasdfkjsajdf' }
74
83
  let(:pathname) { Pathname.new(filename) }
75
84
 
76
85
  it 'should still checksum' do
77
86
  subject.calc(pathname).must_equal(normal_checksum)
78
87
  end
79
-
80
88
  end
81
89
 
82
90
  it 'should get the mtime right' do
@@ -94,43 +102,35 @@ describe Nanoc::Checksummer do
94
102
  end
95
103
 
96
104
  describe 'if the mtime changes' do
97
-
98
- let(:mtime) { 1333333333 }
105
+ let(:mtime) { 1_333_333_333 }
99
106
 
100
107
  it 'should have a different checksum' do
101
108
  subject.calc(pathname).must_match(CHECKSUM_REGEX)
102
109
  subject.calc(pathname).wont_equal(normal_checksum)
103
110
  end
104
-
105
111
  end
106
112
 
107
113
  describe 'if the content changes, but not the file size' do
108
-
109
114
  let(:data) { 'STUFF!' }
110
115
 
111
116
  it 'should have the same checksum' do
112
117
  subject.calc(pathname).must_equal(normal_checksum)
113
118
  end
114
-
115
119
  end
116
120
 
117
121
  describe 'if the file size changes' do
118
-
119
122
  let(:data) { 'stuff and stuff and stuff!!!' }
120
123
 
121
124
  it 'should have a different checksum' do
122
125
  subject.calc(pathname).must_match(CHECKSUM_REGEX)
123
126
  subject.calc(pathname).wont_equal(normal_checksum)
124
127
  end
125
-
126
128
  end
127
-
128
129
  end
129
130
 
130
131
  it 'should not have the same checksum for same content but different class'
131
132
 
132
133
  describe 'for Nanoc::RulesCollection' do
133
-
134
134
  let(:data) { 'STUFF!' }
135
135
  let(:normal_checksum) { 'r4SwDpCp5saBPeZk2gQOJcipTZU=' }
136
136
 
@@ -145,20 +145,16 @@ describe Nanoc::Checksummer do
145
145
  end
146
146
 
147
147
  describe 'if the content changes' do
148
-
149
148
  let(:data) { 'Other stuff!' }
150
149
 
151
150
  it 'should have a different checksum' do
152
151
  subject.calc(rules_collection).must_match(CHECKSUM_REGEX)
153
152
  subject.calc(rules_collection).wont_equal(normal_checksum)
154
153
  end
155
-
156
154
  end
157
-
158
155
  end
159
156
 
160
157
  describe 'for Nanoc::CodeSnippet' do
161
-
162
158
  let(:data) { 'asdf' }
163
159
  let(:filename) { File.expand_path('bob.txt') }
164
160
  let(:code_snippet) { Nanoc::CodeSnippet.new(data, filename) }
@@ -169,30 +165,24 @@ describe Nanoc::Checksummer do
169
165
  end
170
166
 
171
167
  describe 'if the filename changes' do
172
-
173
168
  let(:filename) { File.expand_path('george.txt') }
174
169
 
175
170
  it 'should have the same checksum' do
176
171
  subject.calc(code_snippet).must_equal(normal_checksum)
177
172
  end
178
-
179
173
  end
180
174
 
181
175
  describe 'if the content changes' do
182
-
183
176
  let(:data) { 'Other stuff!' }
184
177
 
185
178
  it 'should have a different checksum' do
186
179
  subject.calc(code_snippet).must_match(CHECKSUM_REGEX)
187
180
  subject.calc(code_snippet).wont_equal(normal_checksum)
188
181
  end
189
-
190
182
  end
191
-
192
183
  end
193
184
 
194
185
  describe 'for Nanoc::Configuration' do
195
-
196
186
  let(:wrapped) { { a: 1, b: 2 } }
197
187
  let(:configuration) { Nanoc::Configuration.new(wrapped) }
198
188
  let(:normal_checksum) { 'eYYQ74x29njbtXMtuKZX/ogD8JA=' }
@@ -202,20 +192,16 @@ describe Nanoc::Checksummer do
202
192
  end
203
193
 
204
194
  describe 'if the content changes' do
205
-
206
195
  let(:wrapped) { { a: 666, b: 2 } }
207
196
 
208
197
  it 'should have a different checksum' do
209
198
  subject.calc(configuration).must_match(CHECKSUM_REGEX)
210
199
  subject.calc(configuration).wont_equal(normal_checksum)
211
200
  end
212
-
213
201
  end
214
-
215
202
  end
216
203
 
217
204
  describe 'for Nanoc::Item' do
218
-
219
205
  let(:content) { 'asdf' }
220
206
  let(:filename) { File.expand_path('bob.txt') }
221
207
  let(:attributes) { { a: 1, b: 2 } }
@@ -227,48 +213,46 @@ describe Nanoc::Checksummer do
227
213
  subject.calc(item).must_equal(normal_checksum)
228
214
  end
229
215
 
230
- describe 'with changed attributes' do
216
+ describe 'with recursive attributes' do
217
+ it 'should checksum' do
218
+ item.attributes[:a] = item
219
+ subject.calc(item).must_match(CHECKSUM_REGEX)
220
+ subject.calc(item).wont_equal(normal_checksum)
221
+ end
222
+ end
231
223
 
224
+ describe 'with changed attributes' do
232
225
  let(:attributes) { { x: 4, y: 5 } }
233
226
 
234
227
  it 'should have a different checksum' do
235
228
  subject.calc(item).must_match(CHECKSUM_REGEX)
236
229
  subject.calc(item).wont_equal(normal_checksum)
237
230
  end
238
-
239
231
  end
240
232
 
241
233
  describe 'with changed content' do
242
-
243
234
  let(:content) { 'something drastically different' }
244
235
 
245
236
  it 'should have a different checksum' do
246
237
  subject.calc(item).must_match(CHECKSUM_REGEX)
247
238
  subject.calc(item).wont_equal(normal_checksum)
248
239
  end
249
-
250
240
  end
251
-
252
241
  end
253
242
 
254
243
  describe 'for other marshal-able classes' do
255
-
256
244
  let(:obj) { :foobar }
257
245
 
258
246
  it 'should checksum' do
259
247
  subject.calc(obj).must_match(CHECKSUM_REGEX)
260
248
  end
261
-
262
249
  end
263
250
 
264
251
  describe 'for other non-marshal-able classes' do
265
-
266
252
  let(:obj) { proc {} }
267
253
 
268
254
  it 'should checksum' do
269
255
  subject.calc(obj).must_match(CHECKSUM_REGEX)
270
256
  end
271
-
272
257
  end
273
-
274
258
  end