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,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Nanoc::CodeSnippet represent a piece of custom code of a nanoc site.
6
5
  class CodeSnippet
7
-
8
6
  # A string containing the actual code in this code snippet.
9
7
  #
10
8
  # @return [String]
@@ -22,7 +20,7 @@ module Nanoc
22
20
  #
23
21
  # @param [String] filename The filename corresponding to this code snippet
24
22
  #
25
- # @param [Time, Hash] params Extra parameters. Ignored by nanoc; it is
23
+ # @param [Time, Hash] _params Extra parameters. Ignored by nanoc; it is
26
24
  # only included for backwards compatibility.
27
25
  def initialize(data, filename, _params = nil)
28
26
  @data = data
@@ -52,7 +50,5 @@ module Nanoc
52
50
  def checksum
53
51
  Nanoc::Checksummer.calc(self)
54
52
  end
55
-
56
53
  end
57
-
58
54
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Represents the site configuration.
6
5
  class Configuration < ::Hash
7
-
8
6
  # Creates a new configuration with the given hash.
9
7
  #
10
8
  # @param [Hash] hash The actual configuration hash
@@ -18,7 +16,5 @@ module Nanoc
18
16
  def reference
19
17
  :config
20
18
  end
21
-
22
19
  end
23
-
24
20
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Responsible for loading site data. It is the (abstract) superclass for all
6
5
  # data sources. Subclasses must at least implement the data reading methods
7
6
  # ({#items} and {#layouts}); all other methods involving data manipulation
@@ -26,7 +25,6 @@ module Nanoc
26
25
  # {#create_item} and {#create_layout} methods should be implemented as
27
26
  # well.
28
27
  class DataSource
29
-
30
28
  # @return [String] The root path where items returned by this data source
31
29
  # should be mounted.
32
30
  attr_reader :items_root
@@ -207,7 +205,7 @@ module Nanoc
207
205
  # files that should be generated.
208
206
  #
209
207
  # @return [void]
210
- def create_item(_content, _attributes, _identifier, _params = {})
208
+ def create_item(content, attributes, identifier, params = {}) # rubocop:disable Lint/UnusedMethodArgument
211
209
  not_implemented('create_item')
212
210
  end
213
211
 
@@ -230,7 +228,7 @@ module Nanoc
230
228
  # files that should be generated.
231
229
  #
232
230
  # @return [void]
233
- def create_layout(_content, _attributes, _identifier, _params = {})
231
+ def create_layout(content, attributes, identifier, params = {}) # rubocop:disable Lint/UnusedMethodArgument
234
232
  not_implemented('create_layout')
235
233
  end
236
234
 
@@ -241,6 +239,5 @@ module Nanoc
241
239
  "#{self.class} does not implement ##{name}"
242
240
  )
243
241
  end
244
-
245
242
  end
246
243
  end
@@ -1,12 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Represents a compileable item in a site. It has content and attributes, as
6
5
  # well as an identifier (which starts and ends with a slash). It can also
7
6
  # store the modification time to speed up compilation.
8
7
  class Item
9
-
10
8
  extend Nanoc::Memoization
11
9
 
12
10
  # @return [Hash] This item's attributes
@@ -70,7 +68,7 @@ module Nanoc
70
68
  def initialize(raw_content_or_raw_filename, attributes, identifier, params = nil)
71
69
  # Parse params
72
70
  params ||= {}
73
- params = { :mtime => params } if params.is_a?(Time)
71
+ params = { mtime: params } if params.is_a?(Time)
74
72
  params[:binary] = false unless params.key?(:binary)
75
73
 
76
74
  if raw_content_or_raw_filename.nil?
@@ -91,7 +89,7 @@ module Nanoc
91
89
  @identifier = identifier.cleaned_identifier.freeze
92
90
 
93
91
  # Set mtime
94
- @attributes.merge!(:mtime => params[:mtime]) if params[:mtime]
92
+ @attributes.merge!(mtime: params[:mtime]) if params[:mtime]
95
93
 
96
94
  @parent = nil
97
95
  @children = []
@@ -172,7 +170,7 @@ module Nanoc
172
170
  Nanoc::NotificationCenter.post(:visit_ended, self)
173
171
 
174
172
  # Get captured content (hax)
175
- # TODO [in nanoc 4.0] remove me
173
+ # TODO: [in nanoc 4.0] remove me
176
174
  if key.to_s =~ /^content_for_(.*)$/
177
175
  @@_content_for_warning_issued ||= false
178
176
  @@_capturing_helper_included ||= false
@@ -295,7 +293,5 @@ module Nanoc
295
293
  def mtime
296
294
  self[:mtime]
297
295
  end
298
-
299
296
  end
300
-
301
297
  end
@@ -1,10 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Acts as an array, but allows fetching items using identifiers, e.g. `@items['/blah/']`.
6
5
  class ItemArray
7
-
8
6
  include Enumerable
9
7
 
10
8
  extend Forwardable
@@ -18,7 +16,7 @@ module Nanoc
18
16
  :instance_eval, :instance_exec, :__send__, :__id__
19
17
  ]
20
18
 
21
- DELEGATED_METHODS = (Array.instance_methods + Enumerable.instance_methods).map { |m| m.to_sym } - EXCLUDED_METHODS
19
+ DELEGATED_METHODS = (Array.instance_methods + Enumerable.instance_methods).map(&:to_sym) - EXCLUDED_METHODS
22
20
  def_delegators :@items, *DELEGATED_METHODS
23
21
 
24
22
  def initialize
@@ -65,7 +63,5 @@ module Nanoc
65
63
  end
66
64
  @mapping.freeze
67
65
  end
68
-
69
66
  end
70
-
71
67
  end
@@ -1,11 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # Represents a layout in a nanoc site. It has content, attributes, an
6
5
  # identifier and a modification time (to speed up compilation).
7
6
  class Layout
8
-
9
7
  extend Nanoc::Memoization
10
8
 
11
9
  # @return [String] The raw content of this layout
@@ -40,8 +38,8 @@ module Nanoc
40
38
 
41
39
  # Set mtime
42
40
  params ||= {}
43
- params = { :mtime => params } if params.is_a?(Time)
44
- @attributes.merge(:mtime => params[:mtime]) if params[:mtime]
41
+ params = { mtime: params } if params.is_a?(Time)
42
+ @attributes.merge(mtime: params[:mtime]) if params[:mtime]
45
43
  end
46
44
 
47
45
  # Requests the attribute with the given key.
@@ -122,7 +120,5 @@ module Nanoc
122
120
  def mtime
123
121
  self[:mtime]
124
122
  end
125
-
126
123
  end
127
-
128
124
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # The in-memory representation of a nanoc site. It holds references to the
6
5
  # following site data:
7
6
  #
@@ -17,14 +16,13 @@ module Nanoc
17
16
  # that contains a configuration file, site data, a rakefile, a rules file,
18
17
  # etc. The way site data is stored depends on the data source.
19
18
  class Site
20
-
21
19
  # The default configuration for a data source. A data source's
22
20
  # configuration overrides these options.
23
21
  DEFAULT_DATA_SOURCE_CONFIG = {
24
- :type => 'filesystem_unified',
25
- :items_root => '/',
26
- :layouts_root => '/',
27
- :config => {}
22
+ type: 'filesystem_unified',
23
+ items_root: '/',
24
+ layouts_root: '/',
25
+ config: {}
28
26
  }
29
27
 
30
28
  # The default configuration for a site. A site's configuration overrides
@@ -32,13 +30,13 @@ module Nanoc
32
30
  # that lacks some options, the default value will be taken from
33
31
  # `DEFAULT_CONFIG`.
34
32
  DEFAULT_CONFIG = {
35
- :text_extensions => %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim ).sort,
36
- :lib_dirs => %w( lib ),
37
- :output_dir => 'output',
38
- :data_sources => [{}],
39
- :index_filenames => ['index.html'],
40
- :enable_output_diff => false,
41
- :prune => { :auto_prune => false, :exclude => ['.git', '.hg', '.svn', 'CVS'] }
33
+ text_extensions: %w( css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim ).sort,
34
+ lib_dirs: %w( lib ),
35
+ output_dir: 'output',
36
+ data_sources: [{}],
37
+ index_filenames: ['index.html'],
38
+ enable_output_diff: false,
39
+ prune: { auto_prune: false, exclude: ['.git', '.hg', '.svn', 'CVS'] }
42
40
  }
43
41
 
44
42
  # Creates a site object for the site specified by the given
@@ -85,7 +83,7 @@ module Nanoc
85
83
  raise Nanoc::Errors::UnknownDataSource.new(data_source_hash[:type]) if data_source_class.nil?
86
84
 
87
85
  # Warn about deprecated data sources
88
- # TODO [in nanoc 4.0] remove me
86
+ # TODO: [in nanoc 4.0] remove me
89
87
  case data_source_hash[:type]
90
88
  when 'filesystem'
91
89
  warn "Warning: the 'filesystem' data source has been renamed to 'filesystem_verbose'. Using 'filesystem' will work in nanoc 3.1.x, but it will likely not work anymore in a future release of nanoc. Please update your data source configuration and replace 'filesystem' with 'filesystem_verbose'."
@@ -217,9 +215,9 @@ module Nanoc
217
215
  # @return [void]
218
216
  def freeze
219
217
  config.freeze_recursively
220
- items.each { |i| i.freeze }
221
- layouts.each { |l| l.freeze }
222
- code_snippets.each { |cs| cs.freeze }
218
+ items.each(&:freeze)
219
+ layouts.each(&:freeze)
220
+ code_snippets.each(&:freeze)
223
221
  end
224
222
 
225
223
  # @deprecated It is no longer necessary to explicitly load site data. It
@@ -251,7 +249,7 @@ module Nanoc
251
249
  ensure_identifier_uniqueness(@layouts, 'layout')
252
250
 
253
251
  # Load compiler too
254
- # FIXME this should not be necessary
252
+ # FIXME: this should not be necessary
255
253
  compiler.load
256
254
 
257
255
  @loaded = true
@@ -301,11 +299,11 @@ module Nanoc
301
299
 
302
300
  # Executes the given block, making sure that the datasources are
303
301
  # available for the duration of the block
304
- def with_datasources(&block)
305
- data_sources.each { |ds| ds.use }
302
+ def with_datasources(&_block)
303
+ data_sources.each(&:use)
306
304
  yield
307
305
  ensure
308
- data_sources.each { |ds| ds.unuse }
306
+ data_sources.each(&:unuse)
309
307
  end
310
308
 
311
309
  # Loads this site’s code and executes it.
@@ -327,7 +325,7 @@ module Nanoc
327
325
  end
328
326
 
329
327
  # Execute code snippets
330
- @code_snippets.each { |cs| cs.load }
328
+ @code_snippets.each(&:load)
331
329
  end
332
330
 
333
331
  # Loads this site’s items, sets up item child-parent relationships and
@@ -431,5 +429,4 @@ module Nanoc
431
429
  @config = Nanoc::Configuration.new(@config)
432
430
  end
433
431
  end
434
-
435
432
  end
@@ -1,7 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc
4
-
5
4
  # An abstract superclass for classes that need to store data to the
6
5
  # filesystem, such as checksums, cached compiled content and dependency
7
6
  # graphs.
@@ -15,7 +14,6 @@ module Nanoc
15
14
  #
16
15
  # @api private
17
16
  class Store
18
-
19
17
  # @return [String] The name of the file where data will be loaded from and
20
18
  # stored to.
21
19
  attr_reader :filename
@@ -52,7 +50,7 @@ module Nanoc
52
50
  # @abstract This method must be implemented by the subclass.
53
51
  #
54
52
  # @return [void]
55
- def data=(_new_data)
53
+ def data=(new_data) # rubocop:disable Lint/UnusedMethodArgument
56
54
  raise NotImplementedError.new('Nanoc::Store subclasses must implement #data and #data=')
57
55
  end
58
56
 
@@ -134,7 +132,5 @@ module Nanoc
134
132
  def pstore
135
133
  @pstore ||= PStore.new(filename)
136
134
  end
137
-
138
135
  end
139
-
140
136
  end
@@ -3,9 +3,7 @@
3
3
  require 'tmpdir'
4
4
 
5
5
  module Nanoc
6
-
7
6
  class TempFilenameFactory
8
-
9
7
  # @return [String] The root directory for all temporary filenames
10
8
  attr_reader :root_dir
11
9
 
@@ -51,7 +49,5 @@ module Nanoc
51
49
  FileUtils.rm_rf(@root_dir)
52
50
  end
53
51
  end
54
-
55
52
  end
56
-
57
53
  end
@@ -16,7 +16,6 @@ if Nanoc.on_windows?
16
16
  end
17
17
 
18
18
  module Nanoc::CLI
19
-
20
19
  module Commands
21
20
  end
22
21
 
@@ -28,7 +27,7 @@ module Nanoc::CLI
28
27
  autoload 'ErrorHandler', 'nanoc/cli/error_handler'
29
28
 
30
29
  # Deprecated; use CommandRunner instead
31
- # TODO [in nanoc 4.0] remove me
30
+ # TODO: [in nanoc 4.0] remove me
32
31
  autoload 'Command', 'nanoc/cli/command_runner'
33
32
 
34
33
  # @return [Boolean] true if debug output is enabled, false if not
@@ -78,7 +77,7 @@ module Nanoc::CLI
78
77
  #
79
78
  # @return [void]
80
79
  def self.after_setup(&block)
81
- # TODO decide what should happen if the CLI is already set up
80
+ # TODO: decide what should happen if the CLI is already set up
82
81
  add_after_setup_proc(block)
83
82
  end
84
83
 
@@ -91,7 +90,7 @@ module Nanoc::CLI
91
90
  setup_cleaning_streams
92
91
  setup_commands
93
92
  load_custom_commands
94
- after_setup_procs.each { |b| b.call }
93
+ after_setup_procs.each(&:call)
95
94
  end
96
95
 
97
96
  # Sets up the root command and base subcommands.
@@ -224,5 +223,4 @@ module Nanoc::CLI
224
223
  @after_setup_procs ||= []
225
224
  @after_setup_procs << proc
226
225
  end
227
-
228
226
  end
@@ -1,18 +1,16 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::CLI
4
-
5
4
  # A simple ANSI colorizer for strings. When given a string and a list of
6
5
  # attributes, it returns a colorized string.
7
6
  module ANSIStringColorizer
8
-
9
- # TODO complete mapping
7
+ # TODO: complete mapping
10
8
  MAPPING = {
11
- :bold => "\e[1m",
12
- :red => "\e[31m",
13
- :green => "\e[32m",
14
- :yellow => "\e[33m",
15
- :blue => "\e[34m"
9
+ bold: "\e[1m",
10
+ red: "\e[31m",
11
+ green: "\e[32m",
12
+ yellow: "\e[33m",
13
+ blue: "\e[34m"
16
14
  }
17
15
 
18
16
  # @param [String] s The string to colorize
@@ -24,7 +22,5 @@ module Nanoc::CLI
24
22
  def self.c(s, *as)
25
23
  as.map { |a| MAPPING[a] }.join('') + s + "\e[0m"
26
24
  end
27
-
28
25
  end
29
-
30
26
  end
@@ -1,11 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Nanoc::CLI
4
-
5
4
  # An output stream that passes output through stream cleaners. This can be
6
5
  # used to strip ANSI color sequences, for instance.
7
6
  class CleaningStream
8
-
9
7
  # @param [IO, StringIO] stream The stream to wrap
10
8
  def initialize(stream)
11
9
  @stream = stream
@@ -20,7 +18,7 @@ module Nanoc::CLI
20
18
  #
21
19
  # @return [void]
22
20
  def add_stream_cleaner(klass)
23
- unless @stream_cleaners.map { |c| c.class }.include?(klass)
21
+ unless @stream_cleaners.map(&:class).include?(klass)
24
22
  @stream_cleaners << klass.new
25
23
  end
26
24
  end
@@ -122,14 +120,12 @@ module Nanoc::CLI
122
120
  protected
123
121
 
124
122
  def _nanoc_clean(s)
125
- @stream_cleaners.reduce(s) { |m, c| c.clean(m) }
123
+ @stream_cleaners.reduce(s) { |a, e| e.clean(a) }
126
124
  end
127
125
 
128
126
  def _nanoc_swallow_broken_pipe_errors_while
129
127
  yield
130
128
  rescue Errno::EPIPE
131
129
  end
132
-
133
130
  end
134
-
135
131
  end