nanoc 4.13.5 → 4.14.1

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: 87183d6afcb52a7a0772f5859b5fa1899122a6e8297f4e169b4b544e9ec6211d
4
- data.tar.gz: f99716556f847c2e500bca8915446d1dbf470e63bca5229b94402b20b2563dd5
3
+ metadata.gz: 923381ebbdbafb7b60b0aa640c118e6983a59113b9e50836459684a31cbb101f
4
+ data.tar.gz: 7abde9f5c334c6a0a267d2ce5740f77c7f1c81cb53b0198ba123f944ee043352
5
5
  SHA512:
6
- metadata.gz: a7589f3ed5f56ac6655ed563387a63138d9f548bb49ea9dcd873a69b8362fc18650ab0e2c2367c842236112c5f11ee3b8b66fafc324b275c1f2a3a909766332f
7
- data.tar.gz: 981703fd7707a83303d9570e77265945522c4d75d02a2a7c41e4fe24643964f7e6dbc430a598d64dad4f945db92a11dc25bee69a3e6abd20c6a47103ea14643f
6
+ metadata.gz: e55e39e90ed7b02a65d3beb3c4b5e4d6ad5eb5698a5535411406d405759665f7ec452556b3e074f37303ac74f1b4f56e5951ad6ef802961bb969cacf8492f12e
7
+ data.tar.gz: 24d045ab848d41bcbba99dcbea0fc140659a2b938d6bea57c1c60267bc4ef31a86c827b6331fc0bd34c1eed5f8747bb25edffc801b9ac980b1a5661dbd7caf1e
data/NEWS.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.14.1 (2025-10-30)
4
+
5
+ Fixes:
6
+
7
+ - Fixed issue which would cause timings reported `--verbose --verbose` to be inaccurate (#1760, #1761)
8
+
9
+ Enhancements:
10
+
11
+ - Improved ERB filter performance through memoization (#1762)
12
+ - Improved performance (#1759, #1758, #1761)
13
+
14
+ ## 4.14.0 (2025-10-18)
15
+
16
+ Features:
17
+
18
+ - Added support for TOML in frontmatter (with `+++` separators rather than `---`) and in the configuration file (`nanoc.toml`) (#1757)
19
+
3
20
  ## 4.13.5 (2025-04-21)
4
21
 
5
22
  Fixes:
data/bin/nanoc CHANGED
@@ -2,13 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'nanoc'
5
-
6
- begin
7
- require 'nanoc-rust'
8
- NanocRust.activate!
9
- rescue LoadError
10
- end
11
-
12
5
  require 'nanoc/orig_cli'
13
6
 
14
7
  if File.file?('Gemfile') && !defined?(Bundler)
@@ -3,7 +3,7 @@
3
3
  # @api private
4
4
  class Nanoc::DataSources::Filesystem
5
5
  class Parser
6
- SEPARATOR = /(-{5}|-{3})/.source
6
+ SEPARATOR = /(-{5}|-{3}|\+{3})/.source
7
7
 
8
8
  class ParseResult
9
9
  attr_reader :content
@@ -34,7 +34,7 @@ class Nanoc::DataSources::Filesystem
34
34
  def parse_with_separate_meta_filename(content_filename, meta_filename)
35
35
  content = content_filename ? Tools.read_file(content_filename, config: @config) : ''
36
36
  meta_raw = Tools.read_file(meta_filename, config: @config)
37
- meta = parse_metadata(meta_raw, meta_filename)
37
+ meta = parse_metadata(meta_raw, meta_filename, :yaml)
38
38
  ParseResult.new(content:, attributes: meta, attributes_data: meta_raw)
39
39
  end
40
40
 
@@ -42,28 +42,39 @@ class Nanoc::DataSources::Filesystem
42
42
  def parse_with_frontmatter(content_filename)
43
43
  data = Tools.read_file(content_filename, config: @config)
44
44
 
45
- unless /\A#{SEPARATOR}\s*$/.match?(data)
45
+ separator = /\A#{SEPARATOR}\s*$/.match(data)
46
+ unless separator
46
47
  return ParseResult.new(content: data, attributes: {}, attributes_data: '')
47
48
  end
48
49
 
50
+ frontmatter_language =
51
+ case separator[1]
52
+ when '+++'
53
+ :toml
54
+ else
55
+ :yaml
56
+ end
57
+
49
58
  pieces = data.split(/^#{SEPARATOR}[ \t]*\r?\n?/, 3)
50
59
  if pieces.size < 4
51
60
  raise Errors::InvalidFormat.new(content_filename)
52
61
  end
53
62
 
54
- meta = parse_metadata(pieces[2], content_filename)
63
+ meta = parse_metadata(pieces[2], content_filename, frontmatter_language)
55
64
  content = pieces[4].sub(/\A\n/, '')
56
65
 
57
66
  ParseResult.new(content:, attributes: meta, attributes_data: pieces[2])
58
67
  end
59
68
 
60
69
  # @return [Hash]
61
- def parse_metadata(data, filename)
62
- begin
63
- meta = Nanoc::Core::YamlLoader.load(data) || {}
64
- rescue => e
65
- raise Errors::UnparseableMetadata.new(filename, e)
66
- end
70
+ def parse_metadata(data, filename, frontmatter_language)
71
+ loader = Nanoc::Core::StructuredDataLoader.for_language(frontmatter_language)
72
+ meta =
73
+ begin
74
+ loader.load(data) || {}
75
+ rescue => e
76
+ raise Errors::UnparseableMetadata.new(filename, e)
77
+ end
67
78
 
68
79
  verify_meta(meta, filename)
69
80
 
@@ -152,6 +152,7 @@ module Nanoc::DataSources
152
152
  is_binary = content_filename && !@site_config[:text_extensions].include?(File.extname(content_filename)[1..])
153
153
 
154
154
  if is_binary && klass == Nanoc::Core::Item
155
+ # NOTE: TOML support is explicitly not added here, in case there are existing sites with `.toml` files.
155
156
  meta = (meta_filename && Nanoc::Core::YamlLoader.load_file(meta_filename)) || {}
156
157
 
157
158
  ProtoDocument.new(is_binary: true, filename: content_filename, attributes: meta)
@@ -7,6 +7,12 @@ module Nanoc::Filters
7
7
 
8
8
  requires 'erb'
9
9
 
10
+ class << self
11
+ attr_accessor :_erb_cache
12
+ end
13
+
14
+ self._erb_cache = {}
15
+
10
16
  # Runs the content through [ERB](http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html).
11
17
  #
12
18
  # @param [String] content The content to filter
@@ -27,9 +33,19 @@ module Nanoc::Filters
27
33
 
28
34
  # Get result
29
35
  trim_mode = params[:trim_mode]
30
- erb = ::ERB.new(content, trim_mode:)
31
- erb.filename = filename
32
- erb.result(assigns_binding)
36
+ erb_for(content, trim_mode:).result(assigns_binding)
37
+ end
38
+
39
+ private
40
+
41
+ def erb_for(content, trim_mode:)
42
+ cache_key = [content, trim_mode]
43
+ self.class._erb_cache.fetch(cache_key) do
44
+ erb = ::ERB.new(content, trim_mode:)
45
+ erb.filename = filename
46
+ self.class._erb_cache[cache_key] = erb
47
+ erb
48
+ end
33
49
  end
34
50
  end
35
51
  end
@@ -21,10 +21,8 @@ module Nanoc::Filters
21
21
 
22
22
  # Add filename to load path
23
23
  paths = [File.dirname(@item[:content_filename])]
24
- on_main_fiber do
25
- parser = ::Less::Parser.new(paths:)
26
- parser.parse(content).to_css(params)
27
- end
24
+ parser = ::Less::Parser.new(paths:)
25
+ parser.parse(content).to_css(params)
28
26
  end
29
27
 
30
28
  def imported_filenames_from(content)
@@ -51,6 +51,7 @@ module Nanoc::Filters
51
51
  identifier :sass
52
52
 
53
53
  include SassCommon
54
+
54
55
  requires(*SassCommon::REQUIRES)
55
56
 
56
57
  def run(content, params = {})
@@ -62,6 +63,7 @@ module Nanoc::Filters
62
63
  identifier :sass_sourcemap
63
64
 
64
65
  include SassCommon
66
+
65
67
  requires(*SassCommon::REQUIRES)
66
68
 
67
69
  def run(content, params = {})
@@ -68,8 +68,7 @@ module Nanoc::Helpers
68
68
 
69
69
  unless rep.compiled?
70
70
  # FIXME: is :last appropriate?
71
- Fiber.yield(Nanoc::Core::Errors::UnmetDependency.new(rep, :last))
72
- return run
71
+ raise Nanoc::Core::Errors::UnmetDependency.new(rep, :last)
73
72
  end
74
73
  end
75
74
 
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.13.5'
5
+ VERSION = '4.14.1'
6
6
  end
data/lib/nanoc.rb CHANGED
@@ -20,7 +20,6 @@ require 'net/http'
20
20
  require 'net/https'
21
21
  require 'open3'
22
22
  require 'pathname'
23
- require 'set'
24
23
  require 'singleton'
25
24
  require 'stringio'
26
25
  require 'tempfile'
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.13.5
4
+ version: 4.14.1
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.13.5
52
+ version: 4.14.1
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.13.5
59
+ version: 4.14.1
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.13.5
66
+ version: 4.14.1
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.13.5
73
+ version: 4.14.1
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.13.5/nanoc
221
+ source_code_uri: https://github.com/nanoc/nanoc/tree/4.14.1/nanoc
222
222
  rdoc_options: []
223
223
  require_paths:
224
224
  - lib
@@ -226,14 +226,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - ">="
228
228
  - !ruby/object:Gem::Version
229
- version: '3.1'
229
+ version: '3.2'
230
230
  required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  requirements:
232
232
  - - ">="
233
233
  - !ruby/object:Gem::Version
234
234
  version: '0'
235
235
  requirements: []
236
- rubygems_version: 3.6.7
236
+ rubygems_version: 3.7.2
237
237
  specification_version: 4
238
238
  summary: A static-site generator with a focus on flexibility.
239
239
  test_files: []