nanoc 3.7.3 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +71 -46
  3. data/NEWS.md +14 -0
  4. data/lib/nanoc.rb +1 -1
  5. data/lib/nanoc/base/checksummer.rb +1 -1
  6. data/lib/nanoc/base/compilation/checksum_store.rb +1 -1
  7. data/lib/nanoc/base/compilation/compiled_content_cache.rb +1 -1
  8. data/lib/nanoc/base/compilation/compiler.rb +11 -10
  9. data/lib/nanoc/base/compilation/compiler_dsl.rb +4 -4
  10. data/lib/nanoc/base/compilation/dependency_tracker.rb +7 -7
  11. data/lib/nanoc/base/compilation/filter.rb +1 -1
  12. data/lib/nanoc/base/compilation/item_rep_proxy.rb +6 -5
  13. data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -7
  14. data/lib/nanoc/base/compilation/outdatedness_checker.rb +6 -6
  15. data/lib/nanoc/base/compilation/rule.rb +1 -1
  16. data/lib/nanoc/base/compilation/rule_memory_store.rb +1 -1
  17. data/lib/nanoc/base/compilation/rules_collection.rb +5 -5
  18. data/lib/nanoc/base/context.rb +1 -1
  19. data/lib/nanoc/base/core_ext/array.rb +1 -1
  20. data/lib/nanoc/base/core_ext/date.rb +1 -1
  21. data/lib/nanoc/base/core_ext/hash.rb +1 -1
  22. data/lib/nanoc/base/directed_graph.rb +3 -3
  23. data/lib/nanoc/base/memoization.rb +1 -1
  24. data/lib/nanoc/base/notification_center.rb +1 -1
  25. data/lib/nanoc/base/ordered_hash.rb +1 -1
  26. data/lib/nanoc/base/plugin_registry.rb +3 -3
  27. data/lib/nanoc/base/result_data/item_rep.rb +13 -11
  28. data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
  29. data/lib/nanoc/base/source_data/data_source.rb +3 -3
  30. data/lib/nanoc/base/source_data/item.rb +8 -8
  31. data/lib/nanoc/base/source_data/item_array.rb +1 -1
  32. data/lib/nanoc/base/source_data/layout.rb +1 -1
  33. data/lib/nanoc/base/source_data/site.rb +27 -18
  34. data/lib/nanoc/base/store.rb +3 -3
  35. data/lib/nanoc/base/temp_filename_factory.rb +2 -2
  36. data/lib/nanoc/cli.rb +6 -6
  37. data/lib/nanoc/cli/cleaning_stream.rb +1 -1
  38. data/lib/nanoc/cli/command_runner.rb +4 -3
  39. data/lib/nanoc/cli/commands/autocompile.rb +3 -3
  40. data/lib/nanoc/cli/commands/check.rb +3 -3
  41. data/lib/nanoc/cli/commands/compile.rb +23 -23
  42. data/lib/nanoc/cli/commands/create-item.rb +5 -5
  43. data/lib/nanoc/cli/commands/create-layout.rb +14 -14
  44. data/lib/nanoc/cli/commands/create-site.rb +6 -6
  45. data/lib/nanoc/cli/commands/deploy.rb +8 -8
  46. data/lib/nanoc/cli/commands/nanoc.rb +3 -3
  47. data/lib/nanoc/cli/commands/prune.rb +3 -3
  48. data/lib/nanoc/cli/commands/shell.rb +4 -4
  49. data/lib/nanoc/cli/commands/show-data.rb +5 -5
  50. data/lib/nanoc/cli/commands/show-plugins.rb +5 -5
  51. data/lib/nanoc/cli/commands/show-rules.rb +4 -4
  52. data/lib/nanoc/cli/commands/sync.rb +1 -1
  53. data/lib/nanoc/cli/commands/update.rb +13 -13
  54. data/lib/nanoc/cli/commands/validate-css.rb +3 -3
  55. data/lib/nanoc/cli/commands/validate-html.rb +3 -3
  56. data/lib/nanoc/cli/commands/validate-links.rb +6 -6
  57. data/lib/nanoc/cli/commands/view.rb +4 -4
  58. data/lib/nanoc/cli/commands/watch.rb +11 -11
  59. data/lib/nanoc/cli/error_handler.rb +10 -10
  60. data/lib/nanoc/cli/logger.rb +1 -1
  61. data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
  62. data/lib/nanoc/data_sources/deprecated/last_fm.rb +5 -5
  63. data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
  64. data/lib/nanoc/data_sources/filesystem.rb +16 -16
  65. data/lib/nanoc/data_sources/filesystem_unified.rb +1 -1
  66. data/lib/nanoc/data_sources/filesystem_verbose.rb +1 -1
  67. data/lib/nanoc/data_sources/static.rb +1 -1
  68. data/lib/nanoc/extra/auto_compiler.rb +2 -2
  69. data/lib/nanoc/extra/checking/check.rb +11 -1
  70. data/lib/nanoc/extra/checking/checks/external_links.rb +15 -7
  71. data/lib/nanoc/extra/checking/checks/internal_links.rb +3 -3
  72. data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
  73. data/lib/nanoc/extra/checking/runner.rb +10 -9
  74. data/lib/nanoc/extra/chick.rb +2 -2
  75. data/lib/nanoc/extra/core_ext/enumerable.rb +1 -1
  76. data/lib/nanoc/extra/deployers/fog.rb +2 -2
  77. data/lib/nanoc/extra/deployers/rsync.rb +3 -3
  78. data/lib/nanoc/extra/file_proxy.rb +3 -3
  79. data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -1
  80. data/lib/nanoc/extra/link_collector.rb +3 -3
  81. data/lib/nanoc/extra/piper.rb +2 -2
  82. data/lib/nanoc/extra/pruner.rb +4 -3
  83. data/lib/nanoc/extra/validators/links.rb +2 -2
  84. data/lib/nanoc/extra/validators/w3c.rb +1 -1
  85. data/lib/nanoc/extra/vcs.rb +5 -5
  86. data/lib/nanoc/extra/vcses/dummy.rb +1 -1
  87. data/lib/nanoc/filters/asciidoc.rb +1 -1
  88. data/lib/nanoc/filters/bluecloth.rb +1 -1
  89. data/lib/nanoc/filters/coffeescript.rb +1 -1
  90. data/lib/nanoc/filters/colorize_syntax.rb +19 -21
  91. data/lib/nanoc/filters/erubis.rb +1 -1
  92. data/lib/nanoc/filters/handlebars.rb +1 -1
  93. data/lib/nanoc/filters/less.rb +2 -2
  94. data/lib/nanoc/filters/markaby.rb +1 -1
  95. data/lib/nanoc/filters/mustache.rb +1 -1
  96. data/lib/nanoc/filters/rdoc.rb +1 -1
  97. data/lib/nanoc/filters/relativize_paths.rb +5 -5
  98. data/lib/nanoc/filters/rubypants.rb +1 -1
  99. data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
  100. data/lib/nanoc/filters/typogruby.rb +1 -1
  101. data/lib/nanoc/filters/xsl.rb +1 -1
  102. data/lib/nanoc/helpers/blogging.rb +12 -12
  103. data/lib/nanoc/helpers/capturing.rb +3 -3
  104. data/lib/nanoc/helpers/html_escape.rb +6 -6
  105. data/lib/nanoc/helpers/tagging.rb +1 -1
  106. data/lib/nanoc/helpers/xml_sitemap.rb +4 -4
  107. data/lib/nanoc/tasks/clean.rake +1 -1
  108. data/lib/nanoc/tasks/clean.rb +1 -1
  109. data/lib/nanoc/tasks/deploy/rsync.rake +2 -2
  110. data/lib/nanoc/version.rb +1 -1
  111. data/tasks/rubocop.rake +1 -0
  112. data/test/base/core_ext/array_spec.rb +7 -7
  113. data/test/base/core_ext/hash_spec.rb +1 -1
  114. data/test/base/test_checksum_store.rb +1 -1
  115. data/test/base/test_compiler.rb +14 -14
  116. data/test/base/test_compiler_dsl.rb +13 -13
  117. data/test/base/test_context.rb +2 -2
  118. data/test/base/test_dependency_tracker.rb +42 -42
  119. data/test/base/test_directed_graph.rb +102 -102
  120. data/test/base/test_item.rb +21 -21
  121. data/test/base/test_item_array.rb +19 -19
  122. data/test/base/test_item_rep.rb +50 -50
  123. data/test/base/test_layout.rb +6 -6
  124. data/test/base/test_outdatedness_checker.rb +2 -2
  125. data/test/base/test_rule_context.rb +2 -2
  126. data/test/base/test_site.rb +5 -5
  127. data/test/cli/commands/test_compile.rb +7 -7
  128. data/test/cli/commands/test_create_site.rb +2 -2
  129. data/test/cli/commands/test_deploy.rb +10 -10
  130. data/test/cli/commands/test_prune.rb +2 -2
  131. data/test/cli/commands/test_sync.rb +1 -1
  132. data/test/cli/commands/test_watch.rb +7 -7
  133. data/test/cli/test_cleaning_stream.rb +4 -4
  134. data/test/cli/test_cli.rb +3 -3
  135. data/test/cli/test_error_handler.rb +3 -3
  136. data/test/data_sources/test_filesystem.rb +19 -19
  137. data/test/data_sources/test_filesystem_unified.rb +30 -30
  138. data/test/data_sources/test_filesystem_verbose.rb +3 -3
  139. data/test/data_sources/test_static.rb +9 -9
  140. data/test/extra/checking/checks/test_stale.rb +8 -8
  141. data/test/extra/checking/test_check.rb +11 -1
  142. data/test/extra/checking/test_dsl.rb +1 -1
  143. data/test/extra/core_ext/test_enumerable.rb +2 -2
  144. data/test/extra/deployers/test_fog.rb +10 -10
  145. data/test/extra/deployers/test_rsync.rb +2 -2
  146. data/test/extra/test_auto_compiler.rb +28 -28
  147. data/test/extra/test_filesystem_tools.rb +3 -3
  148. data/test/extra/test_link_collector.rb +39 -20
  149. data/test/extra/validators/test_w3c.rb +5 -5
  150. data/test/filters/test_asciidoc.rb +2 -2
  151. data/test/filters/test_bluecloth.rb +1 -1
  152. data/test/filters/test_coffeescript.rb +1 -1
  153. data/test/filters/test_colorize_syntax.rb +20 -13
  154. data/test/filters/test_erb.rb +1 -1
  155. data/test/filters/test_kramdown.rb +1 -1
  156. data/test/filters/test_less.rb +10 -10
  157. data/test/filters/test_markaby.rb +2 -2
  158. data/test/filters/test_maruku.rb +2 -2
  159. data/test/filters/test_pandoc.rb +3 -3
  160. data/test/filters/test_rainpress.rb +4 -4
  161. data/test/filters/test_rdiscount.rb +2 -2
  162. data/test/filters/test_rdoc.rb +1 -1
  163. data/test/filters/test_redcarpet.rb +5 -5
  164. data/test/filters/test_redcloth.rb +5 -5
  165. data/test/filters/test_relativize_paths.rb +33 -31
  166. data/test/filters/test_rubypants.rb +2 -2
  167. data/test/filters/test_sass.rb +8 -8
  168. data/test/filters/test_slim.rb +3 -3
  169. data/test/filters/test_uglify_js.rb +1 -1
  170. data/test/filters/test_yui_compressor.rb +3 -3
  171. data/test/gem_loader.rb +1 -1
  172. data/test/helper.rb +14 -16
  173. data/test/helpers/test_blogging.rb +28 -28
  174. data/test/helpers/test_breadcrumbs.rb +12 -12
  175. data/test/helpers/test_capturing.rb +7 -7
  176. data/test/helpers/test_filtering.rb +16 -16
  177. data/test/helpers/test_link_to.rb +3 -3
  178. data/test/helpers/test_rendering.rb +1 -1
  179. data/test/helpers/test_tagging.rb +11 -11
  180. data/test/helpers/test_xml_sitemap.rb +18 -18
  181. data/test/tasks/test_clean.rb +8 -8
  182. metadata +2 -2
@@ -48,7 +48,7 @@ module Nanoc
48
48
  end
49
49
  end
50
50
 
51
- protected
51
+ protected
52
52
 
53
53
  def item_with_identifier(identifier)
54
54
  if self.frozen?
@@ -78,7 +78,7 @@ module Nanoc
78
78
  #
79
79
  # @return [Object] An unique reference to this object
80
80
  def reference
81
- [ type, identifier ]
81
+ [type, identifier]
82
82
  end
83
83
 
84
84
  def inspect
@@ -35,10 +35,10 @@ module Nanoc
35
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
36
  :lib_dirs => %w( lib ),
37
37
  :output_dir => 'output',
38
- :data_sources => [ {} ],
39
- :index_filenames => [ 'index.html' ],
38
+ :data_sources => [{}],
39
+ :index_filenames => ['index.html'],
40
40
  :enable_output_diff => false,
41
- :prune => { :auto_prune => false, :exclude => [ '.git', '.hg', '.svn', 'CVS' ] }
41
+ :prune => { :auto_prune => false, :exclude => ['.git', '.hg', '.svn', 'CVS'] }
42
42
  }
43
43
 
44
44
  # Creates a site object for the site specified by the given
@@ -189,14 +189,14 @@ module Nanoc
189
189
 
190
190
  @items.each do |item|
191
191
  parent_id_end = item.identifier.rindex('/', -2)
192
- if parent_id_end
193
- parent_id = item.identifier[0..parent_id_end]
194
- parent = item_map[parent_id]
195
- if parent
196
- item.parent = parent
197
- parent.children << item
198
- end
199
- end
192
+ next unless parent_id_end
193
+
194
+ parent_id = item.identifier[0..parent_id_end]
195
+ parent = item_map[parent_id]
196
+ next unless parent
197
+
198
+ item.parent = parent
199
+ parent.children << item
200
200
  end
201
201
  end
202
202
 
@@ -224,7 +224,7 @@ module Nanoc
224
224
 
225
225
  # @deprecated It is no longer necessary to explicitly load site data. It
226
226
  # is safe to remove all {#load_data} calls.
227
- def load_data(force = false)
227
+ def load_data(_force = false)
228
228
  warn 'It is no longer necessary to call Nanoc::Site#load_data. This method no longer has any effect. All calls to this method can be safely removed.'
229
229
  end
230
230
 
@@ -240,10 +240,10 @@ module Nanoc
240
240
 
241
241
  # Load all data
242
242
  load_code_snippets
243
- data_sources.each { |ds| ds.use }
244
- load_items
245
- load_layouts
246
- data_sources.each { |ds| ds.unuse }
243
+ with_datasources do
244
+ load_items
245
+ load_layouts
246
+ end
247
247
  setup_child_parent_links
248
248
 
249
249
  # Ensure unique
@@ -297,7 +297,16 @@ module Nanoc
297
297
  filenames.find { |f| File.file?(f) }
298
298
  end
299
299
 
300
- private
300
+ private
301
+
302
+ # Executes the given block, making sure that the datasources are
303
+ # available for the duration of the block
304
+ def with_datasources(&block)
305
+ data_sources.each { |ds| ds.use }
306
+ yield
307
+ ensure
308
+ data_sources.each { |ds| ds.unuse }
309
+ end
301
310
 
302
311
  # Loads this site’s code and executes it.
303
312
  def load_code_snippets
@@ -365,7 +374,7 @@ module Nanoc
365
374
  if parent_config_file
366
375
  config.delete(:parent_config_file)
367
376
  config_path = File.absolute_path(parent_config_file, File.dirname(config_paths.last))
368
- if !File.file?(config_path)
377
+ unless File.file?(config_path)
369
378
  raise Nanoc::Errors::GenericTrivial, "Could not find parent configuration file '#{parent_config_file}'"
370
379
  end
371
380
  if config_paths.include?(config_path)
@@ -52,7 +52,7 @@ module Nanoc
52
52
  # @abstract This method must be implemented by the subclass.
53
53
  #
54
54
  # @return [void]
55
- def data=(new_data)
55
+ def data=(_new_data)
56
56
  raise NotImplementedError.new('Nanoc::Store subclasses must implement #data and #data=')
57
57
  end
58
58
 
@@ -67,7 +67,7 @@ module Nanoc
67
67
  end
68
68
 
69
69
  # Check file existance
70
- if !File.file?(filename)
70
+ unless File.file?(filename)
71
71
  no_data_found
72
72
  @loaded = true
73
73
  return
@@ -129,7 +129,7 @@ module Nanoc
129
129
  def version_mismatch_detected
130
130
  end
131
131
 
132
- private
132
+ private
133
133
 
134
134
  def pstore
135
135
  @pstore ||= PStore.new(filename)
@@ -42,13 +42,13 @@ module Nanoc
42
42
  def cleanup(prefix)
43
43
  path = File.join(@root_dir, prefix)
44
44
  if File.exist?(path)
45
- FileUtils.remove_entry_secure(path)
45
+ FileUtils.rm_rf(path)
46
46
  end
47
47
 
48
48
  @counts.delete(prefix)
49
49
 
50
50
  if @counts.empty? && File.directory?(@root_dir)
51
- FileUtils.remove_entry_secure(@root_dir)
51
+ FileUtils.rm_rf(@root_dir)
52
52
  end
53
53
  end
54
54
 
@@ -79,10 +79,10 @@ module Nanoc::CLI
79
79
  # @return [void]
80
80
  def self.after_setup(&block)
81
81
  # TODO decide what should happen if the CLI is already set up
82
- self.add_after_setup_proc(block)
82
+ add_after_setup_proc(block)
83
83
  end
84
84
 
85
- protected
85
+ protected
86
86
 
87
87
  # Makes the commandline interface ready for use.
88
88
  #
@@ -177,11 +177,11 @@ protected
177
177
  def self.wrap_in_cleaning_stream(io)
178
178
  cio = ::Nanoc::CLI::CleaningStream.new(io)
179
179
 
180
- if !self.enable_utf8?(io)
180
+ unless self.enable_utf8?(io)
181
181
  cio.add_stream_cleaner(Nanoc::CLI::StreamCleaners::UTF8)
182
182
  end
183
183
 
184
- if !self.enable_ansi_colors?(io)
184
+ unless self.enable_ansi_colors?(io)
185
185
  cio.add_stream_cleaner(Nanoc::CLI::StreamCleaners::ANSIColors)
186
186
  end
187
187
 
@@ -198,14 +198,14 @@ protected
198
198
 
199
199
  # @return [Boolean] true if UTF-8 support is present, false if not
200
200
  def self.enable_utf8?(io)
201
- return true if !io.tty?
201
+ return true unless io.tty?
202
202
 
203
203
  %w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/i }
204
204
  end
205
205
 
206
206
  # @return [Boolean] true if color support is present, false if not
207
207
  def self.enable_ansi_colors?(io)
208
- if !io.tty?
208
+ unless io.tty?
209
209
  return false
210
210
  end
211
211
 
@@ -119,7 +119,7 @@ module Nanoc::CLI
119
119
  @stream.winsize = (arg)
120
120
  end
121
121
 
122
- protected
122
+ protected
123
123
 
124
124
  def _nanoc_clean(s)
125
125
  @stream_cleaners.reduce(s) { |m, c| c.clean(m) }
@@ -38,9 +38,10 @@ module Nanoc::CLI
38
38
 
39
39
  # @return [Boolean] true if the current working directory is a nanoc site
40
40
  # directory, false otherwise
41
- def is_in_site_dir?
41
+ def in_site_dir?
42
42
  Nanoc::Site.cwd_is_nanoc_site?
43
43
  end
44
+ alias_method :is_in_site_dir?, :in_site_dir?
44
45
 
45
46
  # Asserts that the current working directory contains a site
46
47
  # ({Nanoc::Site} instance). If no site is present, prints an error
@@ -71,7 +72,7 @@ module Nanoc::CLI
71
72
  Nanoc::CLI.debug?
72
73
  end
73
74
 
74
- protected
75
+ protected
75
76
 
76
77
  # Sets the data source's VCS to the VCS with the given name. Does nothing
77
78
  # when the site's data source does not support VCSes (i.e. does not
@@ -92,7 +93,7 @@ module Nanoc::CLI
92
93
 
93
94
  site.data_sources.each do |data_source|
94
95
  # Skip if not possible
95
- next if !data_source.respond_to?(:vcs=)
96
+ next unless data_source.respond_to?(:vcs=)
96
97
 
97
98
  # Set VCS
98
99
  data_source.vcs = vcs_class.new
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
- usage 'autocompile [options]'
4
- summary 'start the autocompiler'
3
+ usage 'autocompile [options]'
4
+ summary 'start the autocompiler'
5
5
  be_hidden
6
- aliases :aco
6
+ aliases :aco
7
7
  description <<-EOS
8
8
  Start the autocompiler web server. Unless overridden with commandline options
9
9
  or configuration entries, the web server will run on port 3000 and listen on all
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- usage 'check [options] [names]'
4
- summary 'run issue checks'
3
+ usage 'check [options] [names]'
4
+ summary 'run issue checks'
5
5
  description "
6
6
  Run issue checks on the current site. If the `--all` option is passed, all available issue checks will be run. If the `--deploy` option is passed, the issue checks marked for deployment will be run.
7
7
  "
@@ -39,7 +39,7 @@ module Nanoc::CLI::Commands
39
39
  end
40
40
  end
41
41
 
42
- protected
42
+ protected
43
43
 
44
44
  def validate_options_and_arguments
45
45
  if arguments.empty? && !options[:all] && !options[:deploy] && !options[:list]
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- usage 'compile [options]'
4
- summary 'compile items of this site'
3
+ usage 'compile [options]'
4
+ summary 'compile items of this site'
5
5
  description <<-EOS
6
6
  Compile all items of the current site.
7
7
 
@@ -33,7 +33,7 @@ module Nanoc::CLI::Commands
33
33
  # @abstract Subclasses must override {#start} and may override {#stop}.
34
34
  class Listener
35
35
 
36
- def initialize(params = {})
36
+ def initialize(_params = {})
37
37
  end
38
38
 
39
39
  # @param [Nanoc::CLI::CommandRunner] command_runner The command runner for this listener
@@ -41,7 +41,7 @@ module Nanoc::CLI::Commands
41
41
  # @return [Boolean] true if this listener should be enabled for the given command runner, false otherwise
42
42
  #
43
43
  # @abstract Returns `true` by default, but subclasses may override this.
44
- def self.enable_for?(command_runner)
44
+ def self.enable_for?(_command_runner)
45
45
  true
46
46
  end
47
47
 
@@ -79,8 +79,8 @@ module Nanoc::CLI::Commands
79
79
  path = rep.raw_path(:snapshot => snapshot)
80
80
  old_contents[rep] = File.file?(path) ? File.read(path) : nil
81
81
  end
82
- Nanoc::NotificationCenter.on(:rep_written) do |rep, path, is_created, is_modified|
83
- if !rep.binary?
82
+ Nanoc::NotificationCenter.on(:rep_written) do |rep, path, _is_created, _is_modified|
83
+ unless rep.binary?
84
84
  new_contents = File.file?(path) ? File.read(path) : nil
85
85
  if old_contents[rep] && new_contents
86
86
  generate_diff_for(rep, old_contents[rep], new_contents)
@@ -96,7 +96,7 @@ module Nanoc::CLI::Commands
96
96
  teardown_diffs
97
97
  end
98
98
 
99
- protected
99
+ protected
100
100
 
101
101
  def setup_diffs
102
102
  @diff_lock = Mutex.new
@@ -137,8 +137,8 @@ module Nanoc::CLI::Commands
137
137
  new_file.flush
138
138
 
139
139
  # Diff
140
- cmd = [ 'diff', '-u', old_file.path, new_file.path ]
141
- Open3.popen3(*cmd) do |stdin, stdout, stderr|
140
+ cmd = ['diff', '-u', old_file.path, new_file.path]
141
+ Open3.popen3(*cmd) do |_stdin, stdout, _stderr|
142
142
  result = stdout.read
143
143
  return (result == '' ? nil : result)
144
144
  end
@@ -169,11 +169,11 @@ module Nanoc::CLI::Commands
169
169
 
170
170
  # @see Listener#start
171
171
  def start
172
- Nanoc::NotificationCenter.on(:filtering_started) do |rep, filter_name|
172
+ Nanoc::NotificationCenter.on(:filtering_started) do |_rep, filter_name|
173
173
  @times[filter_name] ||= []
174
174
  @times[filter_name] << { :start => Time.now }
175
175
  end
176
- Nanoc::NotificationCenter.on(:filtering_ended) do |rep, filter_name|
176
+ Nanoc::NotificationCenter.on(:filtering_ended) do |_rep, filter_name|
177
177
  @times[filter_name].last[:stop] = Time.now
178
178
  end
179
179
  end
@@ -184,7 +184,7 @@ module Nanoc::CLI::Commands
184
184
  super
185
185
  end
186
186
 
187
- protected
187
+ protected
188
188
 
189
189
  def print_profiling_feedback
190
190
  # Get max filter length
@@ -194,7 +194,7 @@ module Nanoc::CLI::Commands
194
194
  # Print warning if necessary
195
195
  if @reps.any? { |r| !r.compiled? }
196
196
  $stderr.puts
197
- $stderr.puts 'Warning: profiling information may not be accurate because ' +
197
+ $stderr.puts 'Warning: profiling information may not be accurate because ' \
198
198
  'some items were not compiled.'
199
199
  end
200
200
 
@@ -260,17 +260,17 @@ module Nanoc::CLI::Commands
260
260
  class GCController < Listener
261
261
 
262
262
  # @see Listener#enable_for?
263
- def self.enable_for?(command_runner)
263
+ def self.enable_for?(_command_runner)
264
264
  !ENV.key?('TRAVIS')
265
265
  end
266
266
 
267
- def initialize(params = {})
267
+ def initialize(_params = {})
268
268
  @gc_count = 0
269
269
  end
270
270
 
271
271
  # @see Listener#start
272
272
  def start
273
- Nanoc::NotificationCenter.on(:compilation_started) do |rep|
273
+ Nanoc::NotificationCenter.on(:compilation_started) do |_rep|
274
274
  if @gc_count % 20 == 0
275
275
  GC.enable
276
276
  GC.start
@@ -345,7 +345,7 @@ module Nanoc::CLI::Commands
345
345
  Nanoc::NotificationCenter.on(:compilation_started) do |rep|
346
346
  @start_times[rep.raw_path] = Time.now
347
347
  end
348
- Nanoc::NotificationCenter.on(:rep_written) do |rep, path, is_created, is_modified|
348
+ Nanoc::NotificationCenter.on(:rep_written) do |_rep, path, is_created, is_modified|
349
349
  duration = path && @start_times[path] ? Time.now - @start_times[path] : nil
350
350
  action =
351
351
  case
@@ -367,13 +367,13 @@ module Nanoc::CLI::Commands
367
367
  def stop
368
368
  super
369
369
  @reps.select { |r| !r.compiled? }.each do |rep|
370
- rep.raw_paths.each do |snapshot_name, raw_path|
370
+ rep.raw_paths.each do |_snapshot_name, raw_path|
371
371
  log(:low, :skip, raw_path, nil)
372
372
  end
373
373
  end
374
374
  end
375
375
 
376
- private
376
+ private
377
377
 
378
378
  def log(level, action, path, duration)
379
379
  Nanoc::CLI::Logger.instance.file(level, action, path, duration)
@@ -403,7 +403,7 @@ module Nanoc::CLI::Commands
403
403
  puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
404
404
  end
405
405
 
406
- protected
406
+ protected
407
407
 
408
408
  def prune
409
409
  if site.config[:prune][:auto_prune]
@@ -422,9 +422,9 @@ module Nanoc::CLI::Commands
422
422
  end
423
423
 
424
424
  def setup_listeners
425
- @listeners = @listener_classes.
426
- select { |klass| klass.enable_for?(self) }.
427
- map { |klass| klass.new(:reps => reps) }
425
+ @listeners = @listener_classes
426
+ .select { |klass| klass.enable_for?(self) }
427
+ .map { |klass| klass.new(:reps => reps) }
428
428
 
429
429
  @listeners.each { |s| s.start }
430
430
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- usage 'create-item [options] identifier'
4
- aliases :create_item, :ci
5
- summary 'create an item'
3
+ usage 'create-item [options] identifier'
4
+ aliases :create_item, :ci
5
+ summary 'create an item'
6
6
  description <<-EOS
7
7
  Create a new item in the current site. The first data source in the site
8
8
  configuration will be used.
@@ -30,9 +30,9 @@ module Nanoc::CLI::Commands
30
30
  set_vcs(options[:vcs])
31
31
 
32
32
  # Check whether item is unique
33
- if !site.items.find { |i| i.identifier == identifier }.nil?
33
+ unless site.items.find { |i| i.identifier == identifier }.nil?
34
34
  raise Nanoc::Errors::GenericTrivial,
35
- "An item already exists at #{identifier}. Please " +
35
+ "An item already exists at #{identifier}. Please " \
36
36
  'pick a unique name for the item you are creating.'
37
37
  end
38
38
 
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- usage 'create-layout [options] identifier'
4
- aliases :create_layout, :cl
5
- summary 'create a layout'
3
+ usage 'create-layout [options] identifier'
4
+ aliases :create_layout, :cl
5
+ summary 'create a layout'
6
6
  description <<-EOS
7
7
  Create a new layout in the current site. The first data source in the site
8
8
  configuration will be used.
@@ -28,16 +28,16 @@ module Nanoc::CLI::Commands
28
28
  set_vcs(options[:vcs])
29
29
 
30
30
  # Check whether layout is unique
31
- if !site.layouts.find { |l| l.identifier == identifier }.nil?
31
+ unless site.layouts.find { |l| l.identifier == identifier }.nil?
32
32
  raise Nanoc::Errors::GenericTrivial,
33
- "A layout already exists at #{identifier}. Please " +
33
+ "A layout already exists at #{identifier}. Please " \
34
34
  'pick a unique name for the layout you are creating.'
35
35
  end
36
36
 
37
37
  # Check whether layout is not at /
38
38
  if identifier == '/'
39
39
  raise Nanoc::Errors::GenericTrivial,
40
- "There cannot be a layout with the identifier '/'; " +
40
+ "There cannot be a layout with the identifier '/'; " \
41
41
  'please pick a different identifier for this layout.'
42
42
  end
43
43
 
@@ -49,14 +49,14 @@ module Nanoc::CLI::Commands
49
49
  # Create layout
50
50
  data_source = site.data_sources[0]
51
51
  data_source.create_layout(
52
- "<html>\n" +
53
- " <head>\n" +
54
- " <title><%= @item[:title] %></title>\n" +
55
- " </head>\n" +
56
- " <body>\n" +
57
- " <p>Hi, I'm a new layout. Please customize me!</p>\n" +
58
- "<%= yield %>\n" +
59
- " </body>\n" +
52
+ "<html>\n" \
53
+ " <head>\n" \
54
+ " <title><%= @item[:title] %></title>\n" \
55
+ " </head>\n" \
56
+ " <body>\n" \
57
+ " <p>Hi, I'm a new layout. Please customize me!</p>\n" \
58
+ "<%= yield %>\n" \
59
+ " </body>\n" \
60
60
  "</html>\n",
61
61
  {},
62
62
  identifier