nanoc 3.7.3 → 3.7.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -47,7 +47,7 @@ module Nanoc::CLI
47
47
  ACTION_COLORS[action.to_sym],
48
48
  action,
49
49
  "\e[0m",
50
- duration.nil? ? '' : '[%2.2fs] ' % [ duration ],
50
+ duration.nil? ? '' : '[%2.2fs] ' % [duration],
51
51
  name
52
52
  ]
53
53
  )
@@ -14,7 +14,7 @@ module Nanoc::CLI::StreamCleaners
14
14
  # @param [String] s The string to clean
15
15
  #
16
16
  # @return [String] The cleaned string
17
- def clean(s)
17
+ def clean(_s)
18
18
  raise NotImplementedError, 'Subclasses of Nanoc::CLI::StreamCleaners::Abstract must implement #clean'
19
19
  end
20
20
 
@@ -21,9 +21,9 @@ module Nanoc::DataSources
21
21
  # Get data
22
22
  @http_client ||= Nanoc::Extra::CHiCk::Client.new
23
23
  _status, _headers, data = *@http_client.get(
24
- 'http://ws.audioscrobbler.com/2.0/' +
25
- '?method=user.getRecentTracks' +
26
- '&format=json' +
24
+ 'http://ws.audioscrobbler.com/2.0/' \
25
+ '?method=user.getRecentTracks' \
26
+ '&format=json' \
27
27
  '&user=' + URI.escape(config[:username]) +
28
28
  '&api_key=' + URI.escape(config[:api_key])
29
29
  )
@@ -36,8 +36,8 @@ module Nanoc::DataSources
36
36
  raw_items.enum_with_index.map do |raw_item, i|
37
37
  # Get artist data
38
38
  _artist_status, _artist_headers, artist_data = *@http_client.get(
39
- 'http://ws.audioscrobbler.com/2.0/' +
40
- '?method=artist.getInfo' +
39
+ 'http://ws.audioscrobbler.com/2.0/' \
40
+ '?method=artist.getInfo' \
41
41
  '&format=json' +
42
42
  (
43
43
  if raw_item['artist']['mbid'].empty?
@@ -17,7 +17,7 @@ module Nanoc::DataSources
17
17
  raw_items = JSON.parse(data)
18
18
 
19
19
  # Convert to items
20
- raw_items.enum_with_index.map do |raw_item, i|
20
+ raw_items.enum_with_index.map do |raw_item, _i|
21
21
  # Get data
22
22
  content = raw_item['text']
23
23
  attributes = {
@@ -34,7 +34,7 @@ module Nanoc::DataSources
34
34
  # See {Nanoc::DataSource#setup}.
35
35
  def setup
36
36
  # Create directories
37
- [ content_dir_name, layouts_dir_name ].each do |dir|
37
+ [content_dir_name, layouts_dir_name].each do |dir|
38
38
  FileUtils.mkdir_p(dir)
39
39
  vcs.add(dir)
40
40
  end
@@ -60,12 +60,12 @@ module Nanoc::DataSources
60
60
  create_object(layouts_dir_name, content, attributes, identifier, params)
61
61
  end
62
62
 
63
- protected
63
+ protected
64
64
 
65
65
  # Creates a new object (item or layout) on disk in dir_name according to
66
66
  # the given identifier. The file will have its attributes taken from the
67
67
  # attributes hash argument and its content from the content argument.
68
- def create_object(dir_name, content, attributes, identifier, params = {})
68
+ def create_object(_dir_name, _content, _attributes, _identifier, _params = {})
69
69
  raise NotImplementedError.new(
70
70
  "#{self.class} does not implement ##{name}"
71
71
  )
@@ -89,7 +89,7 @@ module Nanoc::DataSources
89
89
  content_filename = filename_for(base_filename, content_ext)
90
90
 
91
91
  # Read content and metadata
92
- is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))
92
+ is_binary = content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1])
93
93
  if is_binary && klass == Nanoc::Item
94
94
  meta = (meta_filename && YAML.load_file(meta_filename)) || {}
95
95
  content_or_filename = content_filename
@@ -153,9 +153,9 @@ module Nanoc::DataSources
153
153
  # 'content/qux' => [ nil, 'html' ]
154
154
  # }
155
155
  def all_split_files_in(dir_name)
156
- grouped_filenames = all_files_in(dir_name).
157
- reject { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }.
158
- group_by { |fn| basename_of(fn) }
156
+ grouped_filenames = all_files_in(dir_name)
157
+ .reject { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }
158
+ .group_by { |fn| basename_of(fn) }
159
159
 
160
160
  grouped_filenames.each_pair do |key, filenames|
161
161
  # Divide
@@ -163,10 +163,10 @@ module Nanoc::DataSources
163
163
  content_filenames = filenames.select { |fn| ext_of(fn) != '.yaml' }
164
164
 
165
165
  # Check number of files per type
166
- if ![ 0, 1 ].include?(meta_filenames.size)
166
+ unless [0, 1].include?(meta_filenames.size)
167
167
  raise "Found #{meta_filenames.size} meta files for #{key}; expected 0 or 1"
168
168
  end
169
- if ![ 0, 1 ].include?(content_filenames.size)
169
+ unless [0, 1].include?(content_filenames.size)
170
170
  raise "Found #{content_filenames.size} content files for #{key}; expected 0 or 1"
171
171
  end
172
172
 
@@ -193,7 +193,7 @@ module Nanoc::DataSources
193
193
  # data sources may prefer to implement this differently (for example,
194
194
  # {Nanoc::DataSources::FilesystemVerbose} doubles the last part of the
195
195
  # basename before concatenating it with a period and the extension).
196
- def filename_for(base_filename, ext)
196
+ def filename_for(_base_filename, _ext)
197
197
  raise NotImplementedError.new(
198
198
  "#{self.class} does not implement #filename_for"
199
199
  )
@@ -201,7 +201,7 @@ module Nanoc::DataSources
201
201
 
202
202
  # Returns the identifier that corresponds with the given filename, which
203
203
  # can be the content filename or the meta filename.
204
- def identifier_for_filename(filename)
204
+ def identifier_for_filename(_filename)
205
205
  raise NotImplementedError.new(
206
206
  "#{self.class} does not implement #identifier_for_filename"
207
207
  )
@@ -235,7 +235,7 @@ module Nanoc::DataSources
235
235
  # Parses the file named `filename` and returns an array with its first
236
236
  # element a hash with the file's metadata, and with its second element the
237
237
  # file content itself.
238
- def parse(content_filename, meta_filename, kind)
238
+ def parse(content_filename, meta_filename, _kind)
239
239
  # Read content and metadata from separate files
240
240
  if meta_filename
241
241
  content = content_filename ? read(content_filename) : ''
@@ -245,7 +245,7 @@ module Nanoc::DataSources
245
245
  rescue Exception => e
246
246
  raise "Could not parse YAML for #{meta_filename}: #{e.message}"
247
247
  end
248
- return [ meta, content ]
248
+ return [meta, content]
249
249
  end
250
250
 
251
251
  # Read data
@@ -253,7 +253,7 @@ module Nanoc::DataSources
253
253
 
254
254
  # Check presence of metadata section
255
255
  if data !~ /\A-{3,5}\s*$/
256
- return [ {}, data ]
256
+ return [{}, data]
257
257
  end
258
258
 
259
259
  # Split data
@@ -273,7 +273,7 @@ module Nanoc::DataSources
273
273
  content = pieces[4]
274
274
 
275
275
  # Done
276
- [ meta, content ]
276
+ [meta, content]
277
277
  end
278
278
 
279
279
  # Reads the content of the file with the given name and returns a string
@@ -303,7 +303,7 @@ module Nanoc::DataSources
303
303
  raise_encoding_error(filename, original_encoding)
304
304
  end
305
305
 
306
- if !data.valid_encoding?
306
+ unless data.valid_encoding?
307
307
  raise_encoding_error(filename, original_encoding)
308
308
  end
309
309
  end
@@ -71,7 +71,7 @@ module Nanoc::DataSources
71
71
 
72
72
  include Nanoc::DataSources::Filesystem
73
73
 
74
- private
74
+ private
75
75
 
76
76
  # See {Nanoc::DataSources::Filesystem#create_object}.
77
77
  def create_object(dir_name, content, attributes, identifier, params = {})
@@ -43,7 +43,7 @@ module Nanoc::DataSources
43
43
 
44
44
  include Nanoc::DataSources::Filesystem
45
45
 
46
- private
46
+ private
47
47
 
48
48
  # See {Nanoc::DataSources::Filesystem#create_object}.
49
49
  def create_object(dir_name, content, attributes, identifier, params = {})
@@ -53,7 +53,7 @@ module Nanoc::DataSources
53
53
  end
54
54
  end
55
55
 
56
- protected
56
+ protected
57
57
 
58
58
  def all_files_in(dir_name)
59
59
  Nanoc::Extra::FilesystemTools.all_files_in(dir_name)
@@ -51,7 +51,7 @@ module Nanoc::Extra
51
51
  if path =~ /\/$/
52
52
  possible_paths = site.config[:index_filenames].map { |f| path + f }
53
53
  else
54
- possible_paths = [ path ]
54
+ possible_paths = [path]
55
55
  end
56
56
 
57
57
  # Find matching file
@@ -79,7 +79,7 @@ module Nanoc::Extra
79
79
  raise e
80
80
  end
81
81
 
82
- private
82
+ private
83
83
 
84
84
  def build_site
85
85
  @site = Nanoc::Site.new(@site_path)
@@ -2,6 +2,12 @@
2
2
 
3
3
  module Nanoc::Extra::Checking
4
4
 
5
+ class OutputDirNotFoundError < Nanoc::Errors::Generic
6
+ def initialize(directory_path)
7
+ super("Unable to run check against output directory at “#{directory_path}”: directory does not exist.")
8
+ end
9
+ end
10
+
5
11
  class Check
6
12
 
7
13
  extend Nanoc::PluginRegistry::PluginMethods
@@ -25,7 +31,11 @@ module Nanoc::Extra::Checking
25
31
  end
26
32
 
27
33
  def output_filenames
28
- Dir[@site.config[:output_dir] + '/**/*'].select { |f| File.file?(f) }
34
+ output_dir = @site.config[:output_dir]
35
+ unless File.exist?(output_dir)
36
+ raise Nanoc::Extra::Checking::OutputDirNotFoundError.new(output_dir)
37
+ end
38
+ Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
29
39
  end
30
40
 
31
41
  end
@@ -71,11 +71,12 @@ module ::Nanoc::Extra::Checking::Checks
71
71
  loop do
72
72
  href = enum.next
73
73
  break if href.nil?
74
+
74
75
  res = validate(href)
75
- if res
76
- mutex.synchronize do
77
- invalid << res
78
- end
76
+ next unless res
77
+
78
+ mutex.synchronize do
79
+ invalid << res
79
80
  end
80
81
  end
81
82
  end
@@ -99,16 +100,19 @@ module ::Nanoc::Extra::Checking::Checks
99
100
 
100
101
  # Get status
101
102
  res = nil
103
+ last_err = nil
104
+ timeouts = [3, 5, 10, 30, 60]
102
105
  5.times do |i|
103
106
  begin
104
- Timeout.timeout(10) do
107
+ Timeout.timeout(timeouts[i]) do
105
108
  res = request_url_once(url)
106
109
  if res.code == '405'
107
110
  res = request_url_once(url, Net::HTTP::Get)
108
111
  end
109
112
  end
110
113
  rescue => e
111
- return Result.new(href, e.message)
114
+ last_err = e
115
+ next # can not allow
112
116
  end
113
117
 
114
118
  if res.code =~ /^3..$/
@@ -133,7 +137,11 @@ module ::Nanoc::Extra::Checking::Checks
133
137
  return Result.new(href, res.code)
134
138
  end
135
139
  end
136
- raise 'should not have gotten here'
140
+ if last_err
141
+ return Result.new(href, last_err.message)
142
+ else
143
+ raise 'should not have gotten here'
144
+ end
137
145
  end
138
146
 
139
147
  def path_for_url(url)
@@ -19,16 +19,16 @@ module Nanoc::Extra::Checking::Checks
19
19
  hrefs_with_filenames = ::Nanoc::Extra::LinkCollector.new(filenames, :internal).filenames_per_href
20
20
  hrefs_with_filenames.each_pair do |href, fns|
21
21
  fns.each do |filename|
22
- unless valid?(href, filename)
22
+ next if valid?(href, filename)
23
+
23
24
  add_issue(
24
25
  "broken reference to #{href}",
25
26
  :subject => filename)
26
- end
27
27
  end
28
28
  end
29
29
  end
30
30
 
31
- protected
31
+ protected
32
32
 
33
33
  def valid?(href, origin)
34
34
  # Skip hrefs that point to self
@@ -11,15 +11,15 @@ module Nanoc::Extra::Checking::Checks
11
11
 
12
12
  output_filenames.each do |f|
13
13
  next if pruner.filename_excluded?(f)
14
- if !item_rep_paths.include?(f)
15
- add_issue(
16
- 'file without matching item',
17
- :subject => f)
18
- end
14
+ next if item_rep_paths.include?(f)
15
+
16
+ add_issue(
17
+ 'file without matching item',
18
+ :subject => f)
19
19
  end
20
20
  end
21
21
 
22
- protected
22
+ protected
23
23
 
24
24
  def pruner
25
25
  exclude_config = @site.config.fetch(:prune, {}).fetch(:exclude, [])
@@ -20,9 +20,10 @@ module Nanoc::Extra::Checking
20
20
  end
21
21
 
22
22
  # @return [Boolean] true if a Checks file exists, false otherwise
23
- def has_dsl?
23
+ def dsl_present?
24
24
  checks_filename && File.file?(checks_filename)
25
25
  end
26
+ alias_method :has_dsl?, :dsl_present?
26
27
 
27
28
  # Lists all available checks on stdout.
28
29
  #
@@ -65,12 +66,12 @@ module Nanoc::Extra::Checking
65
66
  run_check_classes(check_classes_named(check_class_names))
66
67
  end
67
68
 
68
- protected
69
+ protected
69
70
 
70
71
  def load_dsl_if_available
71
72
  @dsl_loaded ||= false
72
- if !@dsl_loaded
73
- if self.has_dsl?
73
+ unless @dsl_loaded
74
+ if self.dsl_present?
74
75
  @dsl = Nanoc::Extra::Checking::DSL.from_file(checks_filename)
75
76
  else
76
77
  @dsl = nil
@@ -138,11 +139,11 @@ module Nanoc::Extra::Checking
138
139
  issues.group_by { |i| i.subject }.to_a.sort_by { |p| p.first }.each do |pair|
139
140
  subject = pair.first
140
141
  issues = pair.last
141
- unless issues.empty?
142
- puts " #{subject}:"
143
- issues.each do |i|
144
- puts " [ #{'ERROR'.red} ] #{i.check_class.identifier} - #{i.description}"
145
- end
142
+ next if issues.empty?
143
+
144
+ puts " #{subject}:"
145
+ issues.each do |i|
146
+ puts " [ #{'ERROR'.red} ] #{i.check_class.identifier} - #{i.description}"
146
147
  end
147
148
  end
148
149
  end
@@ -55,7 +55,7 @@ module Nanoc::Extra
55
55
  body_parts.each { |part| body << part }
56
56
 
57
57
  # Done
58
- [ status, headers, body ]
58
+ [status, headers, body]
59
59
  end
60
60
 
61
61
  end
@@ -115,7 +115,7 @@ module Nanoc::Extra
115
115
  return [
116
116
  response.code.to_i,
117
117
  response.to_hash.reduce({}) { |m, (k, v)| m.merge(k => v[0]) },
118
- [ response.body ]
118
+ [response.body]
119
119
  ]
120
120
  end
121
121
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Enumerable
4
4
 
5
- if !Enumerable.instance_methods.include?('group_by')
5
+ unless Enumerable.instance_methods.include?('group_by')
6
6
 
7
7
  # Returns a hash, which keys are evaluated result from the block, and
8
8
  # values are arrays of elements in enum corresponding to the key. This
@@ -62,7 +62,7 @@ module Nanoc::Extra::Deployers
62
62
  while truncated
63
63
  set = directory.files.all(:marker => files.last.key)
64
64
  truncated = set.is_truncated
65
- files = files + set
65
+ files += set
66
66
  end
67
67
  keys_to_destroy = files.all.map { |file| file.key }
68
68
 
@@ -89,7 +89,7 @@ module Nanoc::Extra::Deployers
89
89
  puts 'Done!'
90
90
  end
91
91
 
92
- private
92
+ private
93
93
 
94
94
  # Prints the given message on stderr and exits.
95
95
  def error(msg)
@@ -51,13 +51,13 @@ module Nanoc::Extra::Deployers
51
51
  # Run
52
52
  if dry_run
53
53
  warn 'Performing a dry-run; no actions will actually be performed'
54
- run_shell_cmd([ 'echo', 'rsync', options, src, dst ].flatten)
54
+ run_shell_cmd(['echo', 'rsync', options, src, dst].flatten)
55
55
  else
56
- run_shell_cmd([ 'rsync', options, src, dst ].flatten)
56
+ run_shell_cmd(['rsync', options, src, dst].flatten)
57
57
  end
58
58
  end
59
59
 
60
- private
60
+ private
61
61
 
62
62
  def run_shell_cmd(cmd)
63
63
  piper = Nanoc::Extra::Piper.new(:stdout => $stdout, :stderr => $stderr)