nanoc 4.14.5 → 4.14.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 144134bd424ad23220f0bc1527694345b207b175ec38fc884a88cd3906bdaff7
4
- data.tar.gz: ca18d0a87e38c71c67659198ee673e0b625a700e8b781000ecf30a59c813feeb
3
+ metadata.gz: fb3e276213934470b9ec1e292ded4b5c769744a1c5b084861fba868fc4c87415
4
+ data.tar.gz: 8d594094a161c616dc7597bd55cef9bf8d26d14297e1c5c625b3d277e1157c1c
5
5
  SHA512:
6
- metadata.gz: b449b2a07d814c92442810f7e0cba6493b33892804a53319087b4e8e7a4dda7f5942d4854b617db326c2a30870366738e5e4af618c2cce979f01e13c238c2333
7
- data.tar.gz: 76515529e1500e63560e13e7b577130d7fda41da81aec542e131ceeb7ce72a37c872cbb3b52b3cb7ae8904b97317b28c1cc0dda4a43bc95552acb34d9657f07a
6
+ metadata.gz: 528e5bfbda05a620de28cdf2b68990e3035491cadf8f68b6409f16a162de0c4347736eaef72f1879bf0117cfe8209da8617884f610b9be350c19c0c71cf52ff4
7
+ data.tar.gz: 6f2c34a506e7998338119c7e1272a42990affce644fe8485c09b6ecfe4bd314088a409938ff870dacd3cf4591d0b5ef47d1872bd647a065637aa1a26c9d8930c
data/NEWS.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.14.7 (2026-03-07)
4
+
5
+ Enhancements:
6
+
7
+ - Add default `robots.txt`
8
+ - Sped up incremental compilation
9
+ - Improved verbose compilation output
10
+
11
+ ## 4.14.6 (2025-12-31)
12
+
13
+ Enhancements:
14
+
15
+ - Sped up incremental compilation (#1776)
16
+
3
17
  ## 4.14.5 (2025-11-30)
4
18
 
5
19
  Identical to 4.14.4 but with corrected release notes.
data/bin/nanoc CHANGED
@@ -5,7 +5,8 @@ require 'nanoc'
5
5
  require 'nanoc/orig_cli'
6
6
 
7
7
  if File.file?('Gemfile') && !defined?(Bundler)
8
- warn 'A Gemfile was detected, but Bundler is not loaded. This is probably not what you want. To run Nanoc with Bundler, use `bundle exec nanoc`.'
8
+ warn 'A Gemfile was detected, but Bundler is not loaded. This is probably ' \
9
+ 'not what you want. To run Nanoc with Bundler, use `bundle exec nanoc`.'
9
10
  end
10
11
 
11
12
  Nanoc::CLI.run(ARGV)
@@ -26,7 +26,11 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
26
26
 
27
27
  class InvalidFormat < Generic
28
28
  def initialize(content_filename)
29
- super("The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.")
29
+ super(
30
+ "The file '#{content_filename}' appears to start with a metadata " \
31
+ 'section (three or five dashes at the top) but it does not seem ' \
32
+ 'to be in the correct format.'
33
+ )
30
34
  end
31
35
  end
32
36
 
@@ -15,7 +15,10 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
15
15
  # resolved before giving up
16
16
  def initialize(filename)
17
17
  @filename = filename
18
- super("Too many indirections while resolving symlinks. I gave up after finding out #{filename} was yet another symlink. Sorry!")
18
+ super(
19
+ 'Too many indirections while resolving symlinks. I gave up after ' \
20
+ "finding out #{filename} was yet another symlink. Sorry!",
21
+ )
19
22
  end
20
23
  end
21
24
 
@@ -29,7 +32,10 @@ class Nanoc::DataSources::Filesystem < Nanoc::DataSource
29
32
  # supported
30
33
  def initialize(filename)
31
34
  @filename = filename
32
- super("The file at #{filename} is of an unsupported type (expected file, directory or link, but it is #{File.ftype(filename)}")
35
+ super(
36
+ "The file at #{filename} is of an unsupported type (expected file, " \
37
+ "directory or link, but it is #{File.ftype(filename)}",
38
+ )
33
39
  end
34
40
  end
35
41
 
@@ -50,7 +50,10 @@ module Nanoc::DataSources
50
50
  class Filesystem < Nanoc::DataSource
51
51
  class AmbiguousMetadataAssociationError < ::Nanoc::Core::Error
52
52
  def initialize(content_filenames, meta_filename)
53
- super("There are multiple content files (#{content_filenames.sort.join(', ')}) that could match the file containing metadata (#{meta_filename}).")
53
+ super(
54
+ "There are multiple content files (#{content_filenames.sort.join(', ')}) " \
55
+ "that could match the file containing metadata (#{meta_filename}).",
56
+ )
54
57
  end
55
58
  end
56
59
 
@@ -118,7 +121,11 @@ module Nanoc::DataSources
118
121
  attr_reader :is_binary
119
122
  alias binary? is_binary
120
123
 
121
- def initialize(is_binary:, attributes:, content: nil, filename: nil, content_checksum_data: nil, attributes_checksum_data: nil)
124
+ def initialize(
125
+ is_binary:, attributes:, content: nil, filename: nil,
126
+ content_checksum_data: nil,
127
+ attributes_checksum_data: nil
128
+ )
122
129
  if content.nil? && filename.nil?
123
130
  raise ArgumentError, '#initialize needs at least content or filename'
124
131
  end
@@ -302,15 +309,14 @@ module Nanoc::DataSources
302
309
 
303
310
  by_basename =
304
311
  all_files_in(dir_name)
305
- .reject { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }
312
+ .grep_v(/(~|\.orig|\.rej|\.bak)$/)
306
313
  .group_by { |fn| basename_of(fn) }
307
314
 
308
315
  all = {}
309
316
 
310
317
  by_basename.each_pair do |basename, filenames|
311
318
  # Divide
312
- meta_filenames = filenames.select { |fn| ext_of(fn) == '.yaml' }
313
- content_filenames = filenames.reject { |fn| ext_of(fn) == '.yaml' }
319
+ meta_filenames, content_filenames = filenames.partition { |fn| ext_of(fn) == '.yaml' }
314
320
 
315
321
  # Check number of files per type
316
322
  unless [0, 1].include?(meta_filenames.size)
@@ -352,7 +358,7 @@ module Nanoc::DataSources
352
358
  elsif ext.empty?
353
359
  base_filename
354
360
  else
355
- base_filename + '.' + ext
361
+ "#{base_filename}.#{ext}"
356
362
  end
357
363
  end
358
364
 
@@ -364,10 +370,10 @@ module Nanoc::DataSources
364
370
  end
365
371
 
366
372
  regex =
367
- if /(^|\/)index(\.[^\/]+)?$/.match?(filename)
368
- allow_periods_in_identifiers? ? /\/?(index)?(\.[^\/.]+)?$/ : /\/?index(\.[^\/]+)?$/
373
+ if %r{(^|/)index(\.[^/]+)?$}.match?(filename)
374
+ allow_periods_in_identifiers? ? %r{/?(index)?(\.[^/.]+)?$} : %r{/?index(\.[^/]+)?$}
369
375
  else
370
- allow_periods_in_identifiers? ? /\.[^\/.]+$/ : /\.[^\/]+$/
376
+ allow_periods_in_identifiers? ? %r{\.[^/.]+$} : %r{\.[^/]+$}
371
377
  end
372
378
  Nanoc::Core::Identifier.new(filename.sub(regex, ''), type: :legacy)
373
379
  end
@@ -393,9 +399,9 @@ module Nanoc::DataSources
393
399
  # @return [Regex]
394
400
  def extension_regex
395
401
  if allow_periods_in_identifiers?
396
- /(\.[^\/.]+$)/
402
+ %r{(\.[^/.]+$)}
397
403
  else
398
- /(\.[^\/]+$)/
404
+ %r{(\.[^/]+$)}
399
405
  end
400
406
  end
401
407
 
@@ -56,9 +56,9 @@ module Nanoc::Filters
56
56
  has_class = true if language
57
57
  else
58
58
  # Get language from comment line
59
- match = element.inner_text.strip.split[0].match(/^#!([^\/][^\n]*)$/)
59
+ match = element.inner_text.strip.split[0].match(%r{^#!([^/][^\n]*)$})
60
60
  language = match[1] if match
61
- element.content = element.content.sub(/^#!([^\/][^\n]*)$\n/, '') if language
61
+ element.content = element.content.sub(%r{^#!([^/][^\n]*)$\n}, '') if language
62
62
  end
63
63
 
64
64
  language ? ExtractedLanguage.new(language, has_class) : nil
@@ -20,7 +20,7 @@ module Nanoc::Filters
20
20
 
21
21
  if warning_filters
22
22
  r = Regexp.union(warning_filters)
23
- warnings = document.warnings.reject { |warning| r =~ warning }
23
+ warnings = document.warnings.grep_v(r)
24
24
  else
25
25
  warnings = document.warnings
26
26
  end
@@ -30,7 +30,7 @@ module Nanoc::Filters
30
30
  imports.concat(content.scan(/^@import\s+(["'])([^\1]+?)\1;/))
31
31
  imports.concat(content.scan(/^@import\s+url\((["']?)([^)]+?)\1\);/))
32
32
 
33
- imports.map { |i| /\.(less|css)$/.match?(i[1]) ? i[1] : i[1] + '.less' }
33
+ imports.map { |i| /\.(less|css)$/.match?(i[1]) ? i[1] : "#{i[1]}.less" }
34
34
  end
35
35
 
36
36
  def imported_filenames_to_items(imported_filenames)
@@ -56,8 +56,8 @@ module Nanoc::Filters
56
56
  relativize_html_like(content, params)
57
57
  else
58
58
  raise 'The relativize_paths needs to know the type of content to ' \
59
- 'process. Pass a :type to the filter call (:html for HTML, ' \
60
- ':xhtml for XHTML, :xml for XML, or :css for CSS).'
59
+ 'process. Pass a :type to the filter call (:html for HTML, ' \
60
+ ':xhtml for XHTML, :xml for XML, or :css for CSS).'
61
61
  end
62
62
  end
63
63
 
@@ -65,14 +65,14 @@ module Nanoc::Filters
65
65
 
66
66
  def relativize_css(content, params)
67
67
  # FIXME: parse CSS the proper way using csspool or something
68
- content.gsub(/url\((['"]?)(\/(?:[^\/].*?)?)\1\)/) do
68
+ content.gsub(%r{url\((['"]?)(/(?:[^/].*?)?)\1\)}) do
69
69
  quote = Regexp.last_match[1]
70
70
  path = Regexp.last_match[2]
71
71
 
72
72
  if exclude?(path, params)
73
73
  Regexp.last_match[0]
74
74
  else
75
- 'url(' + quote + relative_path_to(path) + quote + ')'
75
+ "url(#{quote}#{relative_path_to(path)}#{quote})"
76
76
  end
77
77
  end
78
78
  end
@@ -84,7 +84,7 @@ module Nanoc::Filters
84
84
  when Regexp
85
85
  exclusion
86
86
  when String
87
- /\A#{exclusion}(\z|\/)/
87
+ %r{\A#{exclusion}(\z|/)}
88
88
  end
89
89
  end
90
90
  end
@@ -115,10 +115,7 @@ module Nanoc::Filters
115
115
  when :html5
116
116
  require 'nokogiri'
117
117
  ::Nokogiri::HTML5
118
- when :xml
119
- require 'nokogiri'
120
- ::Nokogiri::XML
121
- when :xhtml
118
+ when :xml, :xhtml
122
119
  require 'nokogiri'
123
120
  ::Nokogiri::XML
124
121
  end
@@ -193,7 +190,7 @@ module Nanoc::Filters
193
190
  end
194
191
 
195
192
  def nokogiri_process_comment(node, doc, selectors, namespaces, klass, type, params)
196
- content = node.content.dup.sub(%r{^(\s*\[.+?\]>\s*)(.+?)(\s*<!\[endif\])}m) do |_m|
193
+ content = node.content.dup.sub(/^(\s*\[.+?\]>\s*)(.+?)(\s*<!\[endif\])/m) do |_m|
197
194
  beginning = Regexp.last_match[1]
198
195
  body = Regexp.last_match[2]
199
196
  ending = Regexp.last_match[3]
@@ -211,7 +208,8 @@ module Nanoc::Filters
211
208
  when :srcset
212
209
  handle_srcset_node(node)
213
210
  else
214
- raise Nanoc::Core::Errors::InternalInconsistency, "Unsupported selector type #{selector_type.inspect} in #{self.class}"
211
+ raise Nanoc::Core::Errors::InternalInconsistency,
212
+ "Unsupported selector type #{selector_type.inspect} in #{self.class}"
215
213
  end
216
214
  end
217
215
 
@@ -220,7 +218,7 @@ module Nanoc::Filters
220
218
 
221
219
  if parsed.is_a?(Array)
222
220
  parsed.map do |pair|
223
- [relative_path_to(pair[:url]), pair[:rest]].join('')
221
+ [relative_path_to(pair[:url]), pair[:rest]].join
224
222
  end.join(',')
225
223
  else
226
224
  relative_path_to(parsed)
@@ -228,7 +226,7 @@ module Nanoc::Filters
228
226
  end
229
227
 
230
228
  def path_is_relativizable?(path, params)
231
- path.match?(/\A\s*\//) && !exclude?(path, params)
229
+ path.match?(%r{\A\s*/}) && !exclude?(path, params)
232
230
  end
233
231
  end
234
232
  end
@@ -45,7 +45,7 @@ module Nanoc::Filters::SassCommon
45
45
  end
46
46
 
47
47
  def key(identifier, _options)
48
- [self.class.name + ':' + root, identifier.to_s]
48
+ ["#{self.class.name}:#{root}", identifier.to_s]
49
49
  end
50
50
 
51
51
  def public_url(identifier, _sourcemap_directory)
@@ -64,7 +64,7 @@ module Nanoc::Filters::SassCommon
64
64
 
65
65
  def self.raw_filename_to_item_map_for_config(config, items)
66
66
  @raw_filename_to_item_map ||= {}
67
- @raw_filename_to_item_map[config.object_id] ||=
67
+ @raw_filename_to_item_map[[config, items]] ||=
68
68
  {}.tap do |map|
69
69
  items.each do |item|
70
70
  filename_without_registering_dependency = item._unwrap.content.filename
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nanoc::Filters
4
4
  module SassCommon
5
- REQUIRES = %w[sass nanoc/filters/sass/importer nanoc/filters/sass/functions].freeze
5
+ REQUIRES = ['sass', 'nanoc/filters/sass/importer', 'nanoc/filters/sass/functions'].freeze
6
6
 
7
7
  def css(filter, rep, content, params)
8
8
  css, = render(filter, rep, content, params)
@@ -39,10 +39,17 @@ module Nanoc::Filters
39
39
  sourcemap = sourcemap&.to_json(css_uri: css_path)
40
40
  encoded = "data:application/json;base64,#{Base64.urlsafe_encode64(sourcemap)}"
41
41
  [css.gsub(%r{^/\*#\s+sourceMappingURL=\s*#{sourcemap_path}\s*\*/$}, "/*# sourceMappingURL=#{encoded} */")]
42
- else
43
- sourcemap = sourcemap&.to_json(css_path:, sourcemap_path:, type: params[:sources_content] ? :inline : :auto)
44
- sourcemap = sourcemap&.split("\n")&.reject { |l| l =~ /^\s*"file":\s*"#{filter.object_id}"\s*$/ }&.join("\n")
42
+ elsif sourcemap
43
+ sourcemap =
44
+ sourcemap
45
+ .to_json(css_path:, sourcemap_path:, type: params[:sources_content] ? :inline : :auto)
46
+ .split("\n")
47
+ .grep_v(/^\s*"file":\s*"#{filter.object_id}"\s*$/)
48
+ .join("\n")
45
49
  [css, sourcemap]
50
+ else
51
+ [css, nil]
52
+
46
53
  end
47
54
  end
48
55
  end
@@ -110,7 +110,7 @@ module Nanoc::Helpers
110
110
  end
111
111
 
112
112
  def build_for_feed(xml)
113
- root_url = @config[:base_url] + '/'
113
+ root_url = "#{@config[:base_url]}/"
114
114
  xml.instruct!
115
115
  xml.feed(xmlns: 'http://www.w3.org/2005/Atom', 'xml:base' => root_url) do
116
116
  # Add primary attributes
@@ -241,7 +241,7 @@ module Nanoc::Helpers
241
241
  raise Nanoc::Core::TrivialError.new('Cannot build Atom feed: site configuration has no base_url')
242
242
  end
243
243
 
244
- @item[:feed_url] || @config[:base_url] + @item.path
244
+ @item[:feed_url] || (@config[:base_url] + @item.path)
245
245
  end
246
246
 
247
247
  # @return [String]
@@ -250,7 +250,7 @@ module Nanoc::Helpers
250
250
 
251
251
  formatted_date = attribute_to_time(item[:created_at]).__nanoc_to_iso8601_date
252
252
 
253
- 'tag:' + hostname + ',' + formatted_date + ':' + base_dir + (item.path || item.identifier.to_s)
253
+ "tag:#{hostname},#{formatted_date}:#{base_dir}#{item.path || item.identifier.to_s}"
254
254
  end
255
255
 
256
256
  # @param [String, Time, Date, DateTime] arg
@@ -5,13 +5,11 @@ module Nanoc::Helpers
5
5
  module Breadcrumbs
6
6
  class AmbiguousAncestorError < ::Nanoc::Core::Error
7
7
  def initialize(pattern, items)
8
+ super("expected only one item to match #{pattern}, but found #{items.size}")
9
+
8
10
  @pattern = pattern
9
11
  @items = items
10
12
  end
11
-
12
- def message
13
- "expected only one item to match #{@pattern}, but found #{@items.size}"
14
- end
15
13
  end
16
14
 
17
15
  # @api private
@@ -53,7 +51,7 @@ module Nanoc::Helpers
53
51
  new_prefix == old_prefix ? nil : new_prefix
54
52
  end
55
53
 
56
- prefixes.map { |pr| pr + '.*' }
54
+ prefixes.map { |pr| "#{pr}.*" }
57
55
  end
58
56
 
59
57
  def self.find_one(items, pat, tiebreaker)
@@ -105,14 +103,14 @@ module Nanoc::Helpers
105
103
 
106
104
  # e.g. ['', '/foo', '/foo/bar']
107
105
  components = item.identifier.components
108
- prefixes = components.inject(['']) { |acc, elem| acc + [acc.last + '/' + elem] }
106
+ prefixes = components.inject(['']) { |acc, elem| acc + ["#{acc.last}/#{elem}"] }
109
107
 
110
108
  tiebreaker = Int::ERROR_TIEBREAKER if tiebreaker == :error
111
109
 
112
110
  if @item.identifier.legacy?
113
- prefixes.map { |pr| @items[Nanoc::Core::Identifier.new('/' + pr, type: :legacy)] }
111
+ prefixes.map { |pr| @items[Nanoc::Core::Identifier.new("/#{pr}", type: :legacy)] }
114
112
  else
115
- ancestral_prefixes = prefixes.reject { |pr| pr =~ /^\/index\./ }[0..-2]
113
+ ancestral_prefixes = prefixes.grep_v(%r{^/index\.})[0..-2]
116
114
  ancestral_items =
117
115
  ancestral_prefixes.map do |pr|
118
116
  if pr == ''
@@ -20,7 +20,7 @@ module Nanoc::Helpers
20
20
  content_string = capture(&)
21
21
 
22
22
  # Get existing contents and prep for store
23
- compiled_content_store = @item._context.compiled_content_store
23
+ compiled_content_repo = @item._context.compiled_content_repo
24
24
  rep = @item.reps[:default]._unwrap
25
25
  capture_name = :"__capture_#{@name}"
26
26
  old_content_string =
@@ -28,10 +28,10 @@ module Nanoc::Helpers
28
28
  when :overwrite
29
29
  ''
30
30
  when :append
31
- c = compiled_content_store.get(rep, capture_name)
31
+ c = compiled_content_repo.get(rep, capture_name)
32
32
  c ? c.string : ''
33
33
  when :error
34
- contents = compiled_content_store.get(rep, capture_name)
34
+ contents = compiled_content_repo.get(rep, capture_name)
35
35
  if contents && contents.string != content_string
36
36
  # FIXME: get proper exception
37
37
  raise "a capture named #{@name.inspect} for #{@item.identifier} already exists"
@@ -39,13 +39,16 @@ module Nanoc::Helpers
39
39
  ''
40
40
  end
41
41
  else
42
- raise ArgumentError, 'expected :existing_behavior param to #content_for to be one of ' \
43
- ":overwrite, :append, or :error, but #{existing_behavior.inspect} was given"
42
+ raise(
43
+ ArgumentError,
44
+ 'expected :existing_behavior param to #content_for to be one of ' \
45
+ ":overwrite, :append, or :error, but #{existing_behavior.inspect} was given",
46
+ )
44
47
  end
45
48
 
46
49
  # Store
47
50
  new_content = Nanoc::Core::TextualContent.new(old_content_string + content_string)
48
- compiled_content_store.set(rep, capture_name, new_content)
51
+ compiled_content_repo.set(rep, capture_name, new_content)
49
52
  end
50
53
  end
51
54
 
@@ -59,21 +62,28 @@ module Nanoc::Helpers
59
62
  end
60
63
 
61
64
  def run
62
- rep = @requested_item.reps[:default]._unwrap
65
+ rep_view = @requested_item.reps[:default]
66
+ rep = rep_view._unwrap
63
67
 
64
68
  # Create dependency
65
69
  if @item.nil? || @requested_item != @item._unwrap
66
70
  dependency_tracker = @config._context.dependency_tracker
67
71
  dependency_tracker.bounce(@requested_item._unwrap, compiled_content: true)
68
72
 
73
+ unless rep.compiled?
74
+ rep_view._try_load_from_cache
75
+ end
76
+
77
+ # If the item rep still isn’t compiled by now, then it can’t be loaded
78
+ # from the cache and needs to compiled as usual.
69
79
  unless rep.compiled?
70
80
  # FIXME: is :last appropriate?
71
81
  raise Nanoc::Core::Errors::UnmetDependency.new(rep, :last)
72
82
  end
73
83
  end
74
84
 
75
- compiled_content_store = @config._context.compiled_content_store
76
- content = compiled_content_store.get(rep, :"__capture_#{@name}")
85
+ compiled_content_repo = @config._context.compiled_content_repo
86
+ content = compiled_content_repo.get(rep, :"__capture_#{@name}")
77
87
  content&.string
78
88
  end
79
89
  end
@@ -111,8 +121,11 @@ module Nanoc::Helpers
111
121
  when 2
112
122
  args[1]
113
123
  else
114
- raise ArgumentError, 'expected 1 or 2 argument (the name ' \
115
- "of the capture, and optionally params) but got #{args.size} instead"
124
+ raise(
125
+ ArgumentError,
126
+ 'expected 1 or 2 argument (the name ' \
127
+ "of the capture, and optionally params) but got #{args.size} instead",
128
+ )
116
129
  end
117
130
 
118
131
  SetContent.new(name, params, @item).run(&)
@@ -126,16 +139,22 @@ module Nanoc::Helpers
126
139
  when 3
127
140
  args[1]
128
141
  else
129
- raise ArgumentError, 'expected 2 or 3 arguments (the name ' \
130
- "of the capture, optionally params, and the content) but got #{args.size} instead"
142
+ raise(
143
+ ArgumentError,
144
+ 'expected 2 or 3 arguments (the name ' \
145
+ "of the capture, optionally params, and the content) but got #{args.size} instead",
146
+ )
131
147
  end
132
148
 
133
149
  _erbout = +'' # rubocop:disable Lint/UnderscorePrefixedVariableName
134
150
  SetContent.new(name, params, @item).run { _erbout << content }
135
151
  else # Get content
136
152
  if args.size != 2
137
- raise ArgumentError, 'expected 2 arguments (the item ' \
138
- "and the name of the capture) but got #{args.size} instead"
153
+ raise(
154
+ ArgumentError,
155
+ 'expected 2 arguments (the item ' \
156
+ "and the name of the capture) but got #{args.size} instead",
157
+ )
139
158
  end
140
159
  requested_item = args[0]
141
160
  name = args[1]
@@ -7,8 +7,8 @@ module Nanoc::Helpers
7
7
  if item.identifier.legacy?
8
8
  item.parent
9
9
  else
10
- path_without_last_component = item.identifier.to_s.sub(/[^\/]+$/, '').chop
11
- @items[path_without_last_component + '.*']
10
+ path_without_last_component = item.identifier.to_s.sub(%r{[^/]+$}, '').chop
11
+ @items["#{path_without_last_component}.*"]
12
12
  end
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ module Nanoc::Helpers
16
16
  if item.identifier.legacy?
17
17
  item.children
18
18
  else
19
- pattern = item.identifier.without_ext + '/*'
19
+ pattern = "#{item.identifier.without_ext}/*"
20
20
  @items.find_all(pattern)
21
21
  end
22
22
  end
@@ -20,8 +20,11 @@ module Nanoc::Helpers
20
20
  buffer << escaped_data
21
21
  elsif string
22
22
  unless string.is_a? String
23
- raise ArgumentError, 'The #html_escape or #h function needs either a ' \
24
- "string or a block to HTML-escape, but #{string.class} was given"
23
+ raise(
24
+ ArgumentError,
25
+ 'The #html_escape or #h function needs either a ' \
26
+ "string or a block to HTML-escape, but #{string.class} was given",
27
+ )
25
28
  end
26
29
 
27
30
  string
@@ -32,7 +35,7 @@ module Nanoc::Helpers
32
35
  .gsub("'", '&#39;')
33
36
  else
34
37
  raise 'The #html_escape or #h function needs either a ' \
35
- 'string or a block to HTML-escape, but neither a string nor a block was given'
38
+ 'string or a block to HTML-escape, but neither a string nor a block was given'
36
39
  end
37
40
  end
38
41
 
@@ -18,16 +18,21 @@ module Nanoc::Helpers
18
18
  when String
19
19
  target
20
20
  when Nanoc::Core::CompilationItemView, Nanoc::Core::BasicItemView, Nanoc::Core::BasicItemRepView
21
- raise "Cannot create a link to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if target.path.nil?
21
+ if target.path.nil?
22
+ raise "Cannot create a link to #{target.inspect} because this " \
23
+ 'target is not outputted (its routing rule returns nil)'
24
+ end
22
25
 
23
26
  target.path
24
27
  else
25
- raise ArgumentError, "Cannot link to #{target.inspect} (expected a string or an item, not a #{target.class.name})"
28
+ raise ArgumentError,
29
+ "Cannot link to #{target.inspect} (expected a string or an " \
30
+ "item, not a #{target.class.name})"
26
31
  end
27
32
 
28
33
  # Join attributes
29
34
  attributes = attributes.reduce('') do |memo, (key, value)|
30
- memo + key.to_s + '="' + h(value) + '" '
35
+ "#{memo}#{key}=\"#{h(value)}\" "
31
36
  end
32
37
 
33
38
  # Create link
@@ -60,7 +65,8 @@ module Nanoc::Helpers
60
65
  path = target.path
61
66
  if path.nil?
62
67
  # TODO: get proper error
63
- raise "Cannot get the relative path to #{target.inspect} because this target is not outputted (its routing rule returns nil)"
68
+ raise "Cannot get the relative path to #{target.inspect} because " \
69
+ 'this target is not outputted (its routing rule returns nil)'
64
70
  end
65
71
  end
66
72
 
@@ -73,7 +79,9 @@ module Nanoc::Helpers
73
79
  dst_path = Pathname.new(path)
74
80
  if @item_rep.path.nil?
75
81
  # TODO: get proper error
76
- raise "Cannot get the relative path to #{path} because the current item representation, #{@item_rep.inspect}, is not outputted (its routing rule returns nil)"
82
+ raise "Cannot get the relative path to #{path} because the current " \
83
+ "item representation, #{@item_rep.inspect}, is not outputted " \
84
+ '(its routing rule returns nil)'
77
85
  end
78
86
 
79
87
  src_path = Pathname.new(@item_rep.path)
@@ -20,7 +20,8 @@ module Nanoc::Helpers
20
20
 
21
21
  # Check for required attributes
22
22
  if @config[:base_url].nil?
23
- raise 'The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.'
23
+ raise 'The Nanoc::Helpers::XMLSitemap helper requires the site ' \
24
+ 'configuration to specify the base URL for the site.'
24
25
  end
25
26
 
26
27
  # Build sitemap
@@ -27,7 +27,7 @@ module Nanoc::OrigCLI::Commands
27
27
  end
28
28
 
29
29
  def explain_item(item, rules:, reps:)
30
- puts(fmt_heading("Item #{item.identifier}") + ':')
30
+ puts("#{fmt_heading("Item #{item.identifier}")}:")
31
31
 
32
32
  reps[item].each do |rep|
33
33
  rule = rules.compilation_rule_for(rep)
@@ -38,7 +38,7 @@ module Nanoc::OrigCLI::Commands
38
38
  end
39
39
 
40
40
  def explain_layout(layout, rules:)
41
- puts(fmt_heading("Layout #{layout.identifier}") + ':')
41
+ puts("#{fmt_heading("Layout #{layout.identifier}")}:")
42
42
 
43
43
  found = false
44
44
  rules.layout_filter_mapping.each_key do |pattern|
@@ -23,6 +23,8 @@ module Nanoc::RuleDSL
23
23
  end
24
24
 
25
25
  def initialize(rules_collection, action_sequence_calculator)
26
+ super()
27
+
26
28
  @rules_collection = rules_collection
27
29
  @action_sequence_calculator = action_sequence_calculator
28
30
  end
@@ -65,7 +67,7 @@ module Nanoc::RuleDSL
65
67
  items: site.items,
66
68
  dependency_tracker:,
67
69
  compilation_context: compiler.compilation_context(reps:),
68
- compiled_content_store: Nanoc::Core::CompiledContentStore.new,
70
+ compiled_content_repo: Nanoc::Core::CompiledContentRepo.new,
69
71
  )
70
72
  ctx = new_postprocessor_context(site, view_context)
71
73
 
@@ -22,7 +22,11 @@ module Nanoc::RuleDSL
22
22
 
23
23
  class PathWithoutInitialSlashError < ::Nanoc::Error
24
24
  def initialize(rep, basic_path)
25
- super("The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash.")
25
+ super(
26
+ "The path returned for the #{rep.inspect} item representation, " \
27
+ "“#{basic_path}”, does not start with a slash. Please ensure that " \
28
+ 'all routing rules return a path that starts with a slash.',
29
+ )
26
30
  end
27
31
  end
28
32
 
@@ -92,7 +96,7 @@ module Nanoc::RuleDSL
92
96
  def compact_snapshots(seq)
93
97
  actions = []
94
98
  seq.actions.each do |action|
95
- if [actions.last, action].all? { |a| a.is_a?(Nanoc::Core::ProcessingActions::Snapshot) }
99
+ if [actions.last, action].all?(Nanoc::Core::ProcessingActions::Snapshot)
96
100
  actions[-1] = actions.last.update(snapshot_names: action.snapshot_names, paths: action.paths)
97
101
  else
98
102
  actions << action
@@ -78,7 +78,7 @@ module Nanoc::RuleDSL
78
78
  when Hash
79
79
  if arg.key?(:ext)
80
80
  ext = arg[:ext].sub(/\A\./, '')
81
- path = @item.identifier.without_exts + '.' + ext
81
+ path = "#{@item.identifier.without_exts}.#{ext}"
82
82
  snapshot(snapshot_name, path:)
83
83
  else
84
84
  raise ArgumentError, 'Cannot call #write this way (need path or :ext)'
@@ -32,7 +32,7 @@ module Nanoc::RuleDSL
32
32
  def preprocess(&block)
33
33
  if @rules_collection.preprocessors[rules_filename]
34
34
  warn 'WARNING: A preprocess block is already defined. Defining ' \
35
- 'another preprocess block overrides the previously one.'
35
+ 'another preprocess block overrides the previously one.'
36
36
  end
37
37
  @rules_collection.preprocessors[rules_filename] = block
38
38
  end
@@ -177,15 +177,19 @@ module Nanoc::RuleDSL
177
177
  routing_block = proc do
178
178
  if item.identifier.full?
179
179
  item.identifier.to_s
180
+ elsif item[:extension].nil? || (item[:content_filename].nil? && item.identifier =~ %r{#{item[:extension]}/$})
181
+ item.identifier.chop
180
182
  else
181
183
  # This is a temporary solution until an item can map back to its data
182
- # source.
183
- # ATM item[:content_filename] is nil for items coming from the static
184
- # data source.
185
- item[:extension].nil? || (item[:content_filename].nil? && item.identifier =~ %r{#{item[:extension]}/$}) ? item.identifier.chop : item.identifier.chop + '.' + item[:extension]
184
+ # source. ATM item[:content_filename] is nil for items coming from the
185
+ # static data source.
186
+ "#{item.identifier.chop}.#{item[:extension]}"
186
187
  end
187
188
  end
188
- routing_rule = Nanoc::RuleDSL::RoutingRule.new(create_pattern(identifier), rep, routing_block, snapshot_name: :last)
189
+ routing_rule = Nanoc::RuleDSL::RoutingRule.new(
190
+ create_pattern(identifier), rep, routing_block,
191
+ snapshot_name: :last
192
+ )
189
193
  @rules_collection.add_item_routing_rule(routing_rule)
190
194
  end
191
195
 
@@ -245,7 +249,7 @@ module Nanoc::RuleDSL
245
249
  def postprocess(&block)
246
250
  if @rules_collection.postprocessors[rules_filename]
247
251
  warn 'WARNING: A postprocess block is already defined. Defining ' \
248
- 'another postprocess block overrides the previously one.'
252
+ 'another postprocess block overrides the previously one.'
249
253
  end
250
254
  @rules_collection.postprocessors[rules_filename] = block
251
255
  end
data/lib/nanoc/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.14.5'
5
+ VERSION = '4.14.7'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.14.5
4
+ version: 4.14.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -49,28 +49,28 @@ dependencies:
49
49
  requirements:
50
50
  - - '='
51
51
  - !ruby/object:Gem::Version
52
- version: 4.14.5
52
+ version: 4.14.7
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - '='
58
58
  - !ruby/object:Gem::Version
59
- version: 4.14.5
59
+ version: 4.14.7
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: nanoc-core
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - '='
65
65
  - !ruby/object:Gem::Version
66
- version: 4.14.5
66
+ version: 4.14.7
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - '='
72
72
  - !ruby/object:Gem::Version
73
- version: 4.14.5
73
+ version: 4.14.7
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: nanoc-deploying
76
76
  requirement: !ruby/object:Gem::Requirement
@@ -218,7 +218,7 @@ licenses:
218
218
  - MIT
219
219
  metadata:
220
220
  rubygems_mfa_required: 'true'
221
- source_code_uri: https://github.com/nanoc/nanoc/tree/4.14.5/nanoc
221
+ source_code_uri: https://github.com/nanoc/nanoc/tree/4.14.7/nanoc
222
222
  rdoc_options: []
223
223
  require_paths:
224
224
  - lib
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.6.9
236
+ rubygems_version: 4.0.3
237
237
  specification_version: 4
238
238
  summary: A static-site generator with a focus on flexibility.
239
239
  test_files: []