andromeda_cms 0.6.3-x86_64-linux → 0.7.1-x86_64-linux

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: 855263206dc24ebe87ce292d2bfd3c9c96d7927ae23eafed8ddb8e7c39cbf601
4
- data.tar.gz: d1b5dbd227c3406c9f27495be1d11147c4a29b172f05694870494aad5b8aff83
3
+ metadata.gz: 37217a20b76903b85f456a94435176aa64ac1600c2f49ca3aec06a60ba8f144d
4
+ data.tar.gz: cee807e8a431423e015539343ad854b66b2aeb1749cf568f86c1d325f958a537
5
5
  SHA512:
6
- metadata.gz: a81f2ac3c3404fab70619a1b010c2e6819c341b0c04aa29dbc65a4a7ad419129b4a1b28f412947d95747d7ae3973f5859efd830ea7018307281006aa6fe9bb2c
7
- data.tar.gz: c172675fb835d11c25e5e597fbe7bccd21d7c488ffb214b6386ed38c5e36d53b7a70772a8e005d627fbb5c8140fbb905b27d37c081f6a4538da1ab2f1df9006a
6
+ metadata.gz: 9a3da1f52eaf5144a1e2de3291ca735bc22e3b855597283e87a3cae65bb93cb3848bf8df61342ab581bbabefcb29b135d2dfdb5b3cf9d25ff65b71b355efda98
7
+ data.tar.gz: 8466f36a95cdcd695bfe780b413dd0cbb4d5b6d7beffd102730af22e3dc79d6985abb340451349136dae61e1d347b05e3e8dbfb5967c35216beea5017b8cb4e6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,39 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.7.1] - 2026-11-08
9
+
10
+ ### Changed
11
+
12
+ - The gem no longer restricts `json` to `< 3`, so applications can use
13
+ json 3. The bound worked around Rails 8.1 failing to decrypt session
14
+ cookies under json 3, which no longer happens: with json 3.1.0 the test
15
+ suite passes on Rails 8.0.5.1 and 8.1.4.1, and session cookies are
16
+ written and read back correctly on Rails 8.1.4.1.
17
+
18
+ ### Removed
19
+
20
+ - The README's Troubleshooting entry, which recommended pinning `json` to
21
+ 2.x, is gone.
22
+
23
+ ## [0.7.0] - 2026-10-16
24
+
25
+ ### Changed
26
+
27
+ - YAML frontmatter is now read the way Astro 7.3.6 and later read it. Astro
28
+ replaced js-yaml with the `yaml` package (core schema, timestamps, merge
29
+ keys), and Andromeda follows. Plain scalars that only YAML 1.1 or Psych
30
+ treat as numbers are now strings, as they are in Astro: values with
31
+ underscores (`1_000`, `0x1_F`), the `0b` prefix, and signed hexadecimal
32
+ or octal (`-0x1F`). Numbers in the core schema are unchanged, including
33
+ `010` (10), `0o17`, `0x1F` and `1e3`.
34
+ - A mapping that repeats a key now raises `Andromeda::SyntaxError` at the
35
+ second key, with its line and column, as Astro does. It used to keep the
36
+ last value silently. Keys are compared after resolution, so `1` and `01`
37
+ collide while `1` and `"1"` do not; repeated `<<` merge keys are allowed.
38
+ Content that repeats a key will fail to build until the duplicate is
39
+ removed.
40
+
8
41
  ## [0.6.3] - 2026-10-16
9
42
 
10
43
  ### Fixed
@@ -208,6 +241,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
208
241
  - Generators: `andromeda:install`, `andromeda:collection`,
209
242
  `andromeda:component` and `andromeda:import_astro`.
210
243
 
244
+ [0.7.1]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.7.1
245
+ [0.7.0]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.7.0
211
246
  [0.6.3]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.6.3
212
247
  [0.6.2]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.6.2
213
248
  [0.6.1]: https://github.com/AndromedaCMS/andromeda_cms/releases/tag/v0.6.1
data/README.md CHANGED
@@ -304,20 +304,6 @@ bundle exec rake # compiles the Rust extension, then runs the tests
304
304
  bundle exec rake test:corpus # after test/fetch_corpus.sh: parse ~370 real Astro files
305
305
  ```
306
306
 
307
- ## Troubleshooting
308
-
309
- **`ArgumentError: wrong number of arguments (given 2, expected 1)` from `JSON.parse`.**
310
- Not this gem's code: Rails 8.1 calls `JSON.parse` with a positional options hash,
311
- which version 3 of the `json` gem no longer accepts, and decrypting a session
312
- cookie hits that path, so pages fail only once a session exists. The gem
313
- restricts `json` to `< 3` to avoid this. If you are on an older andromeda_cms,
314
- pin it in your own `Gemfile` until Rails ships a fix:
315
-
316
- ```ruby
317
- # Gemfile
318
- gem "json", "~> 2.9"
319
- ```
320
-
321
307
  ## Testing
322
308
 
323
309
  To run model tests against entries that are not files under `app/content`,
@@ -25,45 +25,53 @@ module Andromeda
25
25
  # a non-blank line is seen, no `---`/`+++` after it is a fence.
26
26
  LEADING_RE = /\A\uFEFF?(?:[ \t]*\r?\n)*/
27
27
 
28
- # Psych resolves plain scalars by YAML 1.1 rules; js-yaml, which Astro
29
- # uses, follows YAML 1.2's core schema. The two disagree on values that
30
- # really do appear in hand-written frontmatter, and a silent disagreement
31
- # is worse than an error: `time: 12:30` becoming the integer 45000 passes
32
- # every schema check and then displays nonsense. Each rule below mirrors
33
- # what js-yaml 4 does with the same plain scalar.
28
+ # Psych resolves plain scalars by YAML 1.1 rules; Astro 7.3.6 and later
29
+ # read frontmatter with the `yaml` package (core schema, `timestamp` tag,
30
+ # merge keys), which follows YAML 1.2's core schema. The two disagree on
31
+ # values that really do appear in hand-written frontmatter, and a silent
32
+ # disagreement is worse than an error: `time: 12:30` becoming the integer
33
+ # 45000 passes every schema check and then displays nonsense. Each rule
34
+ # below mirrors what that parser does with the same plain scalar.
34
35
  class ScalarScanner < Psych::ScalarScanner
35
36
  # 1.1-only booleans; 1.2 keeps them as strings.
36
37
  YAML_1_1_ONLY_BOOL = /\A(?:[Yy]es|YES|[Nn]o|NO|[Oo]n|ON|[Oo]ff|OFF|[Yy]|[Nn])\z/
37
38
  # 1.1 base-60 (`1:30`) and comma-grouped (`1,000`) numbers; 1.2 has
38
39
  # neither, so these stay strings.
39
40
  YAML_1_1_ONLY_NUMBER = /\A[-+]?[0-9][0-9_]*(?:(?::[0-5]?[0-9])+|(?:,[0-9_]+)+)(?:\.[0-9_]*)?\z/
40
- # 1.1 reads a leading zero as octal (`010` is 8); 1.2 reads it as decimal.
41
- LEADING_ZERO_DECIMAL = /\A[-+]?0[0-9_]+\z/
42
- # 1.2's explicit octal prefix, unknown to Psych.
43
- OCTAL = /\A[-+]?0o[0-7_]+\z/
44
- # 1.2 accepts an exponent without a decimal point (`1e3`); Psych does not.
45
- EXPONENT_FLOAT = /\A[-+]?(?:[0-9][0-9_]*(?:\.[0-9_]*)?|\.[0-9_]+)[eE][-+]?[0-9]+\z/
41
+ # The core schema's integers. A leading zero is plain decimal (`010` is
42
+ # 10, where 1.1 reads octal); `0o` octal and `0x` hex take no sign.
43
+ INTEGER = /\A[-+]?[0-9]+\z/
44
+ OCTAL = /\A0o[0-7]+\z/
45
+ HEX = /\A0x[0-9a-fA-F]+\z/
46
+ # The core schema's floats, including an exponent without a decimal
47
+ # point (`1e3`), which Psych rejects. `.inf`/`.nan` are left to Psych.
48
+ FLOAT = /\A[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+)?\z/
49
+ # Number-like spellings Psych accepts but the core schema does not
50
+ # (`1_000`, `0b1010`, `-0x1F`, `0o1_7`); they stay strings.
51
+ NON_CORE_NUMBER = /\A[-+]?(?:0[xXbBoO][0-9a-fA-F_]+|(?:[0-9][0-9_]*(?:\.[0-9_]*)?|\.[0-9_]+)(?:[eE][-+]?[0-9_]+)?)\z/
46
52
 
47
53
  def tokenize(string)
48
54
  case string
49
55
  when YAML_1_1_ONLY_BOOL, YAML_1_1_ONLY_NUMBER then string
50
- when LEADING_ZERO_DECIMAL then Integer(string.delete("_"), 10)
51
- when OCTAL then Integer(string.delete("_"))
52
- when EXPONENT_FLOAT then Float(normalize_float(string.delete("_")))
56
+ when INTEGER then Integer(string, 10)
57
+ when OCTAL then Integer(string[2..], 8)
58
+ when HEX then Integer(string, 16)
59
+ when FLOAT then Float(normalize_float(string))
60
+ when NON_CORE_NUMBER then string
53
61
  else super
54
62
  end
55
63
  end
56
64
 
57
65
  private
58
66
 
59
- # Ruby's Float() rejects the `1.e3` and `.5e3` spellings YAML allows.
67
+ # Ruby's Float() rejects the `1.`, `1.e3` and `.5e3` spellings YAML allows.
60
68
  def normalize_float(string)
61
- string.sub(/\.(?=[eE])/, ".0").sub(/\A([-+]?)\./, "\\10.")
69
+ string.sub(/\.(?=[eE]|\z)/, ".0").sub(/\A([-+]?)\./, "\\10.")
62
70
  end
63
71
  end
64
72
 
65
- # Restricts `!!` tags to Date/Time (matching js-yaml's default schema,
66
- # which also has no notion of arbitrary Ruby classes) while still
73
+ # Restricts `!!` tags to Date/Time (matching the `yaml` package's core
74
+ # schema, which also has no notion of arbitrary Ruby classes) while still
67
75
  # permitting the two classes plain `YYYY-MM-DD`/timestamp scalars resolve
68
76
  # to, so unquoted dates round-trip instead of raising
69
77
  # Psych::DisallowedClass.
@@ -76,7 +84,7 @@ module Andromeda
76
84
  end
77
85
 
78
86
  # Plain (non-"safe") visitor so anchors/aliases resolve instead of
79
- # raising -- js-yaml allows them by default, and copied Astro content may
87
+ # raising -- the `yaml` package resolves them by default, and copied Astro content may
80
88
  # rely on them.
81
89
  class ToRuby < Psych::Visitors::ToRuby
82
90
  def initialize
@@ -199,6 +207,8 @@ module Andromeda
199
207
  return {} if node.nil?
200
208
 
201
209
  reject_alias_explosion!(node, path: path, content_start_line: content_start_line)
210
+ reject_duplicate_keys!(node, ScalarScanner.new(ClassLoader.new), path: path,
211
+ content_start_line: content_start_line)
202
212
  ToRuby.new.accept(node) || {}
203
213
  rescue Psych::SyntaxError => e
204
214
  # Psych's own #line/#column are 0-based and relative to `text` (the
@@ -305,6 +315,36 @@ module Andromeda
305
315
  end
306
316
  private_class_method :expanded_size
307
317
 
318
+ # Astro's `yaml` parser reports a repeated mapping key as an error, where
319
+ # Psych silently keeps the last value. Keys are compared after resolution,
320
+ # so `1` and `01` collide while `1` and `"1"` do not. Plain `<<` merge
321
+ # keys, alias keys and collection keys are left out.
322
+ def reject_duplicate_keys!(node, scanner, path:, content_start_line:)
323
+ if node.is_a?(Psych::Nodes::Mapping)
324
+ seen = {}
325
+ node.children.each_slice(2) do |key, _value|
326
+ next unless key.is_a?(Psych::Nodes::Scalar)
327
+ next if key.plain && key.value == "<<"
328
+
329
+ resolved = key.plain ? scanner.tokenize(key.value) : key.value
330
+ resolved = resolved.to_f if resolved.is_a?(Numeric)
331
+ if seen.key?(resolved)
332
+ raise syntax_error("duplicate key #{key.value.inspect}", path: path,
333
+ content_start_line: content_start_line,
334
+ relative_line: key.start_line,
335
+ relative_column: key.start_column)
336
+ end
337
+
338
+ seen[resolved] = true
339
+ end
340
+ end
341
+
342
+ node.children.to_a.each do |child|
343
+ reject_duplicate_keys!(child, scanner, path: path, content_start_line: content_start_line)
344
+ end
345
+ end
346
+ private_class_method :reject_duplicate_keys!
347
+
308
348
  def syntax_error(message, path:, content_start_line:, relative_line:, relative_column:)
309
349
  Andromeda::SyntaxError.new(
310
350
  message,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Andromeda
4
- VERSION = "0.6.3"
4
+ VERSION = "0.7.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: andromeda_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.1
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - LIMHAUS Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-16 00:00:00.000000000 Z
11
+ date: 2026-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "<"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3'
75
+ version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "<"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '3'
82
+ version: '0'
83
83
  description: |
84
84
  Andromeda brings Astro's content collections to an ordinary Ruby on Rails
85
85
  app. Markdown and MDX files copied from an Astro project are validated