pubid 2.0.3 → 2.0.5

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.
@@ -27,7 +27,7 @@ module Pubid
27
27
  source = all_parts ? input.sub(ALL_PARTS_PATTERN, "") : input
28
28
  hash = Artifact.for(flavor).parse_and_bind(entry, source)
29
29
  all_parts ? Backend.mark_all_parts(hash) : hash
30
- rescue Parsanol::ParseFailed => e
30
+ rescue *ENGINE_ERRORS => e
31
31
  parse_error(e, input, flavor)
32
32
  end
33
33
 
@@ -38,12 +38,17 @@ module Pubid
38
38
  register(flavor, model_class, entry)
39
39
  model, all_parts = materialize(flavor, model_class, input)
40
40
  all_parts ? model.to_all_parts : model
41
- rescue Parsanol::ParseFailed => e
41
+ rescue *ENGINE_ERRORS => e
42
42
  parse_error(e, input, flavor)
43
43
  end
44
44
 
45
45
  private
46
46
 
47
+ # The uniform error contract (CLAUDE.md "One error namespace"):
48
+ # every grammar/binding failure surfaces as Pubid::Errors::ParseError
49
+ # so `rescue Pubid::Errors::Error` stays exhaustive. Binding failures
50
+ # raise Parsanol::PARG::BindError (< PARG::Error, NOT ParseFailed) —
51
+ # left unrescued it escaped Pubid.parse raw (issue #646).
47
52
  def parse_error(error, input, flavor)
48
53
  raise Pubid::Errors::ParseError.new(
49
54
  error.message,
data/lib/pubid/parg.rb CHANGED
@@ -1,9 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "parsanol"
4
+
3
5
  module Pubid
4
6
  module Parg
5
7
  autoload :Artifact, "pubid/parg/artifact"
6
8
  autoload :Backend, "pubid/parg/backend"
7
9
  autoload :Model, "pubid/parg/model"
10
+
11
+ # The engine errors a PG artifact can raise while parsing or binding an
12
+ # input. Every one of them must surface as Pubid::Errors::ParseError —
13
+ # the uniform error contract (CLAUDE.md "One error namespace") makes
14
+ # `rescue Pubid::Errors::Error` exhaustive, and a raw Parsanol class
15
+ # escaping Pubid.parse bypasses every such guard (issue #646: the JIS
16
+ # year forms raised Parsanol::PARG::BindError raw, which is NOT a
17
+ # Parsanol::ParseFailed). PARG::Error carries BindError
18
+ # (< ArtifactError < Error) and the PARG Parse/Compile/Artifact errors;
19
+ # Parsanol::ParseFailed is the ruby reference engine's parse failure.
20
+ ENGINE_ERRORS = [Parsanol::ParseFailed, Parsanol::PARG::Error].freeze
8
21
  end
9
22
  end
@@ -41,3 +41,5 @@ keeps `#matches?(other, ignore:)`.
41
41
  paths and the strict comparison treats that `[]` and a nil alike — the
42
42
  same asymmetry the `initialize_empty` note above is about, seen from the
43
43
  matching side. relaton had two committed specs breaking on this.
44
+
45
+ - **The flavor key is `:"3gpp"`, not the derived `:tgpp` (pubid#644)**: `PrefixesSupport#prefix_flavor_key` derives the key from the Ruby constant's name (`Pubid::Tgpp` → `:tgpp`), but the external key is "3gpp" — the registry registration, the `pubid:3gpp:*` `_type` namespace and the `urn:3gpp:` URN namespace all spell it with the digit. The derived mismatch made `Pubid.prefix_flavors` attribute the "3GPP" prefix to a key **nothing is registered under**, so the router's routing table resolved `Registry.get(:tgpp)` to `nil`, `candidates_by_prefix`'s `compact` silently dropped the owner, and `Pubid.parse("3GPP TS 38.101")` — which `Pubid::Tgpp.parse` handles fine (the prefixed spelling is a normalizing parse; canonical render drops the publisher, `with_publisher: true` puts it back) — lost its prefix-owner fallback and raised. The fix is a one-line `prefix_flavor_key` override in `lib/pubid/tgpp.rb` returning `:"3gpp"`; `Pubid.prefix_flavors["3GPP"]` now reads `[:\"3gpp\"]` and `Registry.canonical_name(Pubid::Tgpp)` answers the real key. The registry-driven tripwire `spec/pubid/parse_routing_spec.rb` ("resolves every prefix table entry to a registered flavor module") is the guard that turns any future key/registry mismatch of this shape red at the table level.
data/lib/pubid/tgpp.rb CHANGED
@@ -16,6 +16,17 @@ module Pubid
16
16
  # excluded. The parser still accepts an optional leading "3GPP ".
17
17
  PREFIXES = ["3GPP"].freeze
18
18
 
19
+ # The external flavor key is "3gpp" (the registry key, the `pubid:3gpp:*`
20
+ # `_type` namespace and the `urn:3gpp:` URN namespace), but the default
21
+ # derivation spells it from the Ruby constant as :tgpp. That mismatch made
22
+ # {Pubid.prefix_flavors} attribute "3GPP" to a key nothing is registered
23
+ # under, so {Pubid}'s routing table resolved the prefix to no module and
24
+ # the "3GPP TS …" printed form lost its prefix-owner status (pubid#644).
25
+ # Return the real external key, matching the registry registration below.
26
+ def self.prefix_flavor_key
27
+ :"3gpp"
28
+ end
29
+
19
30
  autoload :Builder, "#{__dir__}/tgpp/builder"
20
31
  autoload :Identifier, "#{__dir__}/tgpp/identifier"
21
32
  autoload :Identifiers, "#{__dir__}/tgpp/identifiers"
data/lib/pubid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pubid
4
- VERSION = "2.0.3"
4
+ VERSION = "2.0.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-02 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: parsanol
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.3.114
34
- - - "<"
31
+ - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: '1.4'
33
+ version: 1.3.122
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.3.114
44
- - - "<"
38
+ - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '1.4'
40
+ version: 1.3.122
47
41
  description: PubID is a Ruby library for parsing and generating international publication
48
42
  identifiers (PubIDs). It provides a simple and flexible API for working with PubIDs,
49
43
  allowing developers to easily create, manipulate, and validate PubIDs in their applications.
@@ -99,6 +93,7 @@ files:
99
93
  - data/parg/ieee.json
100
94
  - data/parg/ietf.json
101
95
  - data/parg/iho.json
96
+ - data/parg/iho.parg
102
97
  - data/parg/ire.json
103
98
  - data/parg/ire.parg
104
99
  - data/parg/isbn.json
@@ -115,6 +110,7 @@ files:
115
110
  - data/parg/oiml.json
116
111
  - data/parg/omg.json
117
112
  - data/parg/parg.json
113
+ - data/parg/parg.parg
118
114
  - data/parg/plateau.json
119
115
  - data/parg/sae.json
120
116
  - data/parg/tables/bipm_groups.yaml