nanoc 4.14.5 → 4.14.6

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: 381f9b78be0bd850ae42b2166d8d12c59d6dca22bdbbecc0638ef3e4569288aa
4
+ data.tar.gz: 89da1dea5adea2239cde2af78182f593b66e003bc170acb01b309d9ca9e36e5f
5
5
  SHA512:
6
- metadata.gz: b449b2a07d814c92442810f7e0cba6493b33892804a53319087b4e8e7a4dda7f5942d4854b617db326c2a30870366738e5e4af618c2cce979f01e13c238c2333
7
- data.tar.gz: 76515529e1500e63560e13e7b577130d7fda41da81aec542e131ceeb7ce72a37c872cbb3b52b3cb7ae8904b97317b28c1cc0dda4a43bc95552acb34d9657f07a
6
+ metadata.gz: '0910d3ef0fd6ba12e12cfb6c9feb554e414575898cc34392ad8f311df5d26de7b4f5b59164b79378a8d90e170371e461f8440ce5c9329959baecd6890621520a'
7
+ data.tar.gz: ea616d1d317bd5ee94693f9c1ffe4f5a469e15e586014f0981ab02205bc7adb957da60d6586d46f0f8b0c26dc17d869cab8c9e7fa91afdb67aef394637c26580
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.14.6 (2025-12-31)
4
+
5
+ Enhancements:
6
+
7
+ - Sped up incremental compilation (#1776)
8
+
3
9
  ## 4.14.5 (2025-11-30)
4
10
 
5
11
  Identical to 4.14.4 but with corrected release notes.
@@ -302,7 +302,7 @@ module Nanoc::DataSources
302
302
 
303
303
  by_basename =
304
304
  all_files_in(dir_name)
305
- .reject { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }
305
+ .grep_v(/(~|\.orig|\.rej|\.bak)$/)
306
306
  .group_by { |fn| basename_of(fn) }
307
307
 
308
308
  all = {}
@@ -364,10 +364,10 @@ module Nanoc::DataSources
364
364
  end
365
365
 
366
366
  regex =
367
- if /(^|\/)index(\.[^\/]+)?$/.match?(filename)
368
- allow_periods_in_identifiers? ? /\/?(index)?(\.[^\/.]+)?$/ : /\/?index(\.[^\/]+)?$/
367
+ if %r{(^|/)index(\.[^/]+)?$}.match?(filename)
368
+ allow_periods_in_identifiers? ? %r{/?(index)?(\.[^/.]+)?$} : %r{/?index(\.[^/]+)?$}
369
369
  else
370
- allow_periods_in_identifiers? ? /\.[^\/.]+$/ : /\.[^\/]+$/
370
+ allow_periods_in_identifiers? ? %r{\.[^/.]+$} : %r{\.[^/]+$}
371
371
  end
372
372
  Nanoc::Core::Identifier.new(filename.sub(regex, ''), type: :legacy)
373
373
  end
@@ -393,9 +393,9 @@ module Nanoc::DataSources
393
393
  # @return [Regex]
394
394
  def extension_regex
395
395
  if allow_periods_in_identifiers?
396
- /(\.[^\/.]+$)/
396
+ %r{(\.[^/.]+$)}
397
397
  else
398
- /(\.[^\/]+$)/
398
+ %r{(\.[^/]+$)}
399
399
  end
400
400
  end
401
401
 
@@ -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
@@ -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,7 +65,7 @@ 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
 
@@ -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
@@ -193,7 +193,7 @@ module Nanoc::Filters
193
193
  end
194
194
 
195
195
  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|
196
+ content = node.content.dup.sub(/^(\s*\[.+?\]>\s*)(.+?)(\s*<!\[endif\])/m) do |_m|
197
197
  beginning = Regexp.last_match[1]
198
198
  body = Regexp.last_match[2]
199
199
  ending = Regexp.last_match[3]
@@ -220,7 +220,7 @@ module Nanoc::Filters
220
220
 
221
221
  if parsed.is_a?(Array)
222
222
  parsed.map do |pair|
223
- [relative_path_to(pair[:url]), pair[:rest]].join('')
223
+ [relative_path_to(pair[:url]), pair[:rest]].join
224
224
  end.join(',')
225
225
  else
226
226
  relative_path_to(parsed)
@@ -228,7 +228,7 @@ module Nanoc::Filters
228
228
  end
229
229
 
230
230
  def path_is_relativizable?(path, params)
231
- path.match?(/\A\s*\//) && !exclude?(path, params)
231
+ path.match?(%r{\A\s*/}) && !exclude?(path, params)
232
232
  end
233
233
  end
234
234
  end
@@ -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
@@ -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]
@@ -112,7 +112,7 @@ module Nanoc::Helpers
112
112
  if @item.identifier.legacy?
113
113
  prefixes.map { |pr| @items[Nanoc::Core::Identifier.new('/' + pr, type: :legacy)] }
114
114
  else
115
- ancestral_prefixes = prefixes.reject { |pr| pr =~ /^\/index\./ }[0..-2]
115
+ ancestral_prefixes = prefixes.grep_v(%r{^/index\.})[0..-2]
116
116
  ancestral_items =
117
117
  ancestral_prefixes.map do |pr|
118
118
  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"
@@ -40,12 +40,12 @@ module Nanoc::Helpers
40
40
  end
41
41
  else
42
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"
43
+ ":overwrite, :append, or :error, but #{existing_behavior.inspect} was given"
44
44
  end
45
45
 
46
46
  # Store
47
47
  new_content = Nanoc::Core::TextualContent.new(old_content_string + content_string)
48
- compiled_content_store.set(rep, capture_name, new_content)
48
+ compiled_content_repo.set(rep, capture_name, new_content)
49
49
  end
50
50
  end
51
51
 
@@ -59,21 +59,28 @@ module Nanoc::Helpers
59
59
  end
60
60
 
61
61
  def run
62
- rep = @requested_item.reps[:default]._unwrap
62
+ rep_view = @requested_item.reps[:default]
63
+ rep = rep_view._unwrap
63
64
 
64
65
  # Create dependency
65
66
  if @item.nil? || @requested_item != @item._unwrap
66
67
  dependency_tracker = @config._context.dependency_tracker
67
68
  dependency_tracker.bounce(@requested_item._unwrap, compiled_content: true)
68
69
 
70
+ unless rep.compiled?
71
+ rep_view._try_load_from_cache
72
+ end
73
+
74
+ # If the item rep still isn’t compiled by now, then it can’t be loaded
75
+ # from the cache and needs to compiled as usual.
69
76
  unless rep.compiled?
70
77
  # FIXME: is :last appropriate?
71
78
  raise Nanoc::Core::Errors::UnmetDependency.new(rep, :last)
72
79
  end
73
80
  end
74
81
 
75
- compiled_content_store = @config._context.compiled_content_store
76
- content = compiled_content_store.get(rep, :"__capture_#{@name}")
82
+ compiled_content_repo = @config._context.compiled_content_repo
83
+ content = compiled_content_repo.get(rep, :"__capture_#{@name}")
77
84
  content&.string
78
85
  end
79
86
  end
@@ -112,7 +119,7 @@ module Nanoc::Helpers
112
119
  args[1]
113
120
  else
114
121
  raise ArgumentError, 'expected 1 or 2 argument (the name ' \
115
- "of the capture, and optionally params) but got #{args.size} instead"
122
+ "of the capture, and optionally params) but got #{args.size} instead"
116
123
  end
117
124
 
118
125
  SetContent.new(name, params, @item).run(&)
@@ -127,7 +134,7 @@ module Nanoc::Helpers
127
134
  args[1]
128
135
  else
129
136
  raise ArgumentError, 'expected 2 or 3 arguments (the name ' \
130
- "of the capture, optionally params, and the content) but got #{args.size} instead"
137
+ "of the capture, optionally params, and the content) but got #{args.size} instead"
131
138
  end
132
139
 
133
140
  _erbout = +'' # rubocop:disable Lint/UnderscorePrefixedVariableName
@@ -135,7 +142,7 @@ module Nanoc::Helpers
135
142
  else # Get content
136
143
  if args.size != 2
137
144
  raise ArgumentError, 'expected 2 arguments (the item ' \
138
- "and the name of the capture) but got #{args.size} instead"
145
+ "and the name of the capture) but got #{args.size} instead"
139
146
  end
140
147
  requested_item = args[0]
141
148
  name = args[1]
@@ -7,7 +7,7 @@ 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
10
+ path_without_last_component = item.identifier.to_s.sub(%r{[^/]+$}, '').chop
11
11
  @items[path_without_last_component + '.*']
12
12
  end
13
13
  end
@@ -21,7 +21,7 @@ module Nanoc::Helpers
21
21
  elsif string
22
22
  unless string.is_a? String
23
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"
24
+ "string or a block to HTML-escape, but #{string.class} was given"
25
25
  end
26
26
 
27
27
  string
@@ -32,7 +32,7 @@ module Nanoc::Helpers
32
32
  .gsub("'", '&#39;')
33
33
  else
34
34
  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'
35
+ 'string or a block to HTML-escape, but neither a string nor a block was given'
36
36
  end
37
37
  end
38
38
 
@@ -65,7 +65,7 @@ module Nanoc::RuleDSL
65
65
  items: site.items,
66
66
  dependency_tracker:,
67
67
  compilation_context: compiler.compilation_context(reps:),
68
- compiled_content_store: Nanoc::Core::CompiledContentStore.new,
68
+ compiled_content_repo: Nanoc::Core::CompiledContentRepo.new,
69
69
  )
70
70
  ctx = new_postprocessor_context(site, view_context)
71
71
 
@@ -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
@@ -245,7 +245,7 @@ module Nanoc::RuleDSL
245
245
  def postprocess(&block)
246
246
  if @rules_collection.postprocessors[rules_filename]
247
247
  warn 'WARNING: A postprocess block is already defined. Defining ' \
248
- 'another postprocess block overrides the previously one.'
248
+ 'another postprocess block overrides the previously one.'
249
249
  end
250
250
  @rules_collection.postprocessors[rules_filename] = block
251
251
  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.6'
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.6
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.6
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.6
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.6
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.6
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.6/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: []