pubid 2.0.45 → 2.0.47
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 +4 -4
- data/conformance/pending.yaml +173 -0
- data/data/parg/ansi.json +1 -1
- data/data/parg/itu.json +1 -1
- data/lib/pubid/ansi/CLAUDE.md +59 -0
- data/lib/pubid/ansi/builder.rb +14 -0
- data/lib/pubid/ansi/identifier.rb +16 -0
- data/lib/pubid/ansi/identifiers/american_national_standard.rb +2 -1
- data/lib/pubid/ansi/pubid_urn_schema.rb +4 -3
- data/lib/pubid/ansi/renderer.rb +9 -1
- data/lib/pubid/ansi.rb +8 -2
- data/lib/pubid/eu/CLAUDE.md +33 -0
- data/lib/pubid/eu/builder.rb +22 -8
- data/lib/pubid/eu/identifier.rb +75 -4
- data/lib/pubid/eu/pubid_urn_schema.rb +3 -1
- data/lib/pubid/itu/CLAUDE.md +29 -1
- data/lib/pubid/itu/builder.rb +6 -1
- data/lib/pubid/itu/identifiers/resolution.rb +38 -0
- data/lib/pubid/itu/identifiers.rb +1 -0
- data/lib/pubid/itu/pubid_urn_schema.rb +1 -0
- data/lib/pubid/itu/urn_generator.rb +3 -0
- data/lib/pubid/itu/urn_parser.rb +10 -11
- data/lib/pubid/prefixes_support.rb +11 -0
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid.rb +18 -1
- metadata +3 -1
data/lib/pubid/ansi.rb
CHANGED
|
@@ -6,10 +6,16 @@ module Pubid
|
|
|
6
6
|
extend Pubid::PrefixesSupport
|
|
7
7
|
|
|
8
8
|
# ANSI publisher token; ANSI/ASHRAE and ANSI/AMCA joint forms come from
|
|
9
|
-
# Pubid::JOINT_PREFIXES.
|
|
10
|
-
#
|
|
9
|
+
# Pubid::JOINT_PREFIXES. Co-publisher acronyms are not leading ANSI
|
|
10
|
+
# tokens, so they are excluded.
|
|
11
11
|
PREFIXES = ["ANSI"].freeze
|
|
12
12
|
|
|
13
|
+
# ANSI parses any "ANSI/<ACRONYM> ..." (relaton#45), so a co-publisher
|
|
14
|
+
# with a flavor of its own (AMCA, ASHRAE) keeps the route.
|
|
15
|
+
def self.routing_umbrella?
|
|
16
|
+
true
|
|
17
|
+
end
|
|
18
|
+
|
|
13
19
|
autoload :Builder, "#{__dir__}/ansi/builder"
|
|
14
20
|
autoload :Identifier, "#{__dir__}/ansi/identifier"
|
|
15
21
|
autoload :Identifiers, "#{__dir__}/ansi/identifiers"
|
data/lib/pubid/eu/CLAUDE.md
CHANGED
|
@@ -12,6 +12,7 @@ flavor, whose `Relaton::Db` cache keys on this pubid.
|
|
|
12
12
|
| Official Journal long form | `Regulation (EU) No 1227/2011`, `Directive 2010/75/EU` | canonical; sets `family` |
|
|
13
13
|
| CELEX | `32011R1227`, `CELEX 32011R1227`, `CELEX:32011R1227` | canonical |
|
|
14
14
|
| ELI | `http(s)://data.europa.eu/eli/reg/2011/1227[/oj]` | canonical |
|
|
15
|
+
| ELI with a subtype | `http://data.europa.eu/eli/reg_impl/2016/1356/oj` | canonical; sets `subtype` |
|
|
15
16
|
|
|
16
17
|
`#to_celex` and `#to_eli` give the two official identifiers back. `to_urn`
|
|
17
18
|
(`urn:eu:reg:2011:1227`) is pubid-invented: the EU has no URN namespace.
|
|
@@ -55,6 +56,38 @@ Commission act). From 2015 every act prints `<year>/<number>`.
|
|
|
55
56
|
0 is rejected. The bracketed family and the suffixed one are separate
|
|
56
57
|
captures; two different ones (`Regulation (EU) No 1227/2011/EC`) raise.
|
|
57
58
|
|
|
59
|
+
## ELI type subtypes are not identity
|
|
60
|
+
|
|
61
|
+
CELLAR gives sector-3 works the ELI segments `<type>_<subtype>` with the
|
|
62
|
+
subtypes `impl` (implementing), `del` (delegated) and `financ` (financial
|
|
63
|
+
regulation): `reg_impl` 14,782 works, `dec_impl` 5,358, `reg_del` 2,975
|
|
64
|
+
(counts 2026-11-18, relaton/relaton#44). Such an act shares the numbering of
|
|
65
|
+
its type — the Official Journal cites `Commission Implementing Regulation
|
|
66
|
+
(EU) 2016/1356` — so it parses as the base type and the subtype goes in the
|
|
67
|
+
`subtype` attribute. `subtype` is `equality_ignored` and a URN facet, so
|
|
68
|
+
`EU Regulation 2016/1356` equals the `reg_impl` ELI. `#to_eli` reads it and
|
|
69
|
+
gives the ELI back; `to_s`, `to_celex`, `to_urn` and the MR string do not.
|
|
70
|
+
|
|
71
|
+
`Identifier.parse` removes the `_<subtype>` with `ELI_SUBTYPE` before the
|
|
72
|
+
baked grammar, which knows only `reg`/`dir`/`dec` (the BSI/IETF Ruby-side
|
|
73
|
+
strip). So `data/parg/eu.json` did not change. Only a subtype listed for
|
|
74
|
+
its type in `ELI_SUBTYPES` is removed (`financ` only on `reg`, as CELLAR
|
|
75
|
+
gives it); `reg_foo` and `dir_financ` stay in the input and fail in the
|
|
76
|
+
grammar. When the grammar rejects a stripped input, the `ParseError` is
|
|
77
|
+
raised again with the caller's `input`; its message names the stripped text,
|
|
78
|
+
because the reported position is in that text. `subtype` is not validated on
|
|
79
|
+
`new`/`from_hash`, as `family` is not.
|
|
80
|
+
|
|
81
|
+
## A CELEX number is read by convention
|
|
82
|
+
|
|
83
|
+
The CELEX sequence number is CELLAR's own, and it is not always the act
|
|
84
|
+
number: `32016D0002` is ECB `Decision (EU) 2016/245`. The CELEX parse takes
|
|
85
|
+
the sequence number as the act number, so it reads `32016D0002` as
|
|
86
|
+
`EU Decision 2016/2`, and `#to_celex` gives `32016D0245` for Decision
|
|
87
|
+
2016/245. Both are the *conventional* CELEX, right only when CELLAR numbered
|
|
88
|
+
the work with the act number. Key an act by its ELI, not by `#to_celex`
|
|
89
|
+
(relaton does so). CELEX parsing stays, because callers use it.
|
|
90
|
+
|
|
58
91
|
## Identity and matching
|
|
59
92
|
|
|
60
93
|
Identity is the leaf class, `date` (year) and `number` (leading CELEX zeros
|
data/lib/pubid/eu/builder.rb
CHANGED
|
@@ -27,12 +27,15 @@ module Pubid
|
|
|
27
27
|
# One parsed act before it becomes an identifier.
|
|
28
28
|
Act = Struct.new(:klass, :year, :number, :number_first)
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
# @param subtype [String, nil] the ELI type subtype that
|
|
31
|
+
# Identifier.parse removed before the grammar ("impl", "del" …)
|
|
32
|
+
def self.build(data, input = nil, subtype: nil)
|
|
33
|
+
new(input, subtype).build(data)
|
|
32
34
|
end
|
|
33
35
|
|
|
34
|
-
def initialize(input)
|
|
36
|
+
def initialize(input, subtype = nil)
|
|
35
37
|
@input = input
|
|
38
|
+
@subtype = subtype
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
# Which of two printed numbers is the year, when the input has no
|
|
@@ -61,17 +64,28 @@ module Pubid
|
|
|
61
64
|
number = strip_zeros(act.number)
|
|
62
65
|
fail!("number 0") if number == "0"
|
|
63
66
|
|
|
64
|
-
id = Identifiers.const_get(act.klass)
|
|
65
|
-
|
|
66
|
-
date: ::Pubid::Components::Date.new(year: act.year),
|
|
67
|
-
family: family(data),
|
|
68
|
-
)
|
|
67
|
+
id = Identifiers.const_get(act.klass)
|
|
68
|
+
.new(**attributes(act, number, data))
|
|
69
69
|
keep_order(id, act.number_first)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
private
|
|
73
73
|
|
|
74
|
+
def attributes(act, number, data)
|
|
75
|
+
{
|
|
76
|
+
number: number,
|
|
77
|
+
date: ::Pubid::Components::Date.new(year: act.year),
|
|
78
|
+
family: family(data),
|
|
79
|
+
subtype: @subtype,
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
74
83
|
# CELEX and ELI: the year and the number have fixed places.
|
|
84
|
+
#
|
|
85
|
+
# A CELEX number is read by convention: its sequence number is taken
|
|
86
|
+
# as the act number. CELLAR numbers most works so, but not all of them
|
|
87
|
+
# (32016D0002 is ECB Decision 2016/245, and this reads it as Decision
|
|
88
|
+
# 2016/2). See Identifier#to_celex.
|
|
75
89
|
def positional(data)
|
|
76
90
|
klass = if data[:celex_letter]
|
|
77
91
|
TYPES_BY_CELEX.fetch(data[:celex_letter])
|
data/lib/pubid/eu/identifier.rb
CHANGED
|
@@ -22,6 +22,29 @@ module Pubid
|
|
|
22
22
|
# CELEX number 32013D1082 name one act.
|
|
23
23
|
equality_ignored :number_first
|
|
24
24
|
|
|
25
|
+
# The ELI type subtype: "impl" (implementing act), "del" (delegated
|
|
26
|
+
# act) or "financ" (financial regulation), from an ELI such as
|
|
27
|
+
# http://data.europa.eu/eli/reg_impl/2016/1356/oj. Such an act shares
|
|
28
|
+
# the numbering of its type (the Official Journal cites it as
|
|
29
|
+
# "Commission Implementing Regulation (EU) 2016/1356"), so the subtype
|
|
30
|
+
# is not identity: "EU Regulation 2016/1356" is the same act. #to_eli
|
|
31
|
+
# reads it to give the ELI back.
|
|
32
|
+
attribute :subtype, :string
|
|
33
|
+
equality_ignored :subtype
|
|
34
|
+
|
|
35
|
+
# The subtypes CELLAR gives each ELI type: implementing and delegated
|
|
36
|
+
# acts of every type, and the financial regulation.
|
|
37
|
+
ELI_SUBTYPES = {
|
|
38
|
+
"reg" => %w[impl del financ],
|
|
39
|
+
"dir" => %w[impl del],
|
|
40
|
+
"dec" => %w[impl del],
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
43
|
+
# The subtype of an ELI input, removed before the baked grammar (which
|
|
44
|
+
# knows only reg/dir/dec), as BSI and IETF strip their prefixes.
|
|
45
|
+
ELI_SUBTYPE =
|
|
46
|
+
%r{\A(https?://data\.europa\.eu/eli/(reg|dir|dec))_([a-z]+)/}
|
|
47
|
+
|
|
25
48
|
EU_TYPE_MAP = {
|
|
26
49
|
"pubid:eu:regulation" => "Pubid::Eu::Identifiers::Regulation",
|
|
27
50
|
"pubid:eu:directive" => "Pubid::Eu::Identifiers::Directive",
|
|
@@ -34,6 +57,7 @@ module Pubid
|
|
|
34
57
|
map "date", to: :date
|
|
35
58
|
map "family", to: :family
|
|
36
59
|
map "number_first", to: :number_first
|
|
60
|
+
map "subtype", to: :subtype
|
|
37
61
|
end
|
|
38
62
|
|
|
39
63
|
PUBLISHER = "EU"
|
|
@@ -71,14 +95,25 @@ module Pubid
|
|
|
71
95
|
[PUBLISHER]
|
|
72
96
|
end
|
|
73
97
|
|
|
74
|
-
# The CELEX number: sector 3, year, type letter, number
|
|
98
|
+
# The conventional CELEX number: sector 3, year, type letter, number
|
|
99
|
+
# padded to 4 (EU Regulation 1227/2011 -> 32011R1227).
|
|
100
|
+
#
|
|
101
|
+
# This is the CELEX of the act only when CELLAR numbered the work with
|
|
102
|
+
# the act number, which is the usual case but not a rule: the CELEX
|
|
103
|
+
# sequence number is CELLAR's own. ECB Decision (EU) 2016/245 is
|
|
104
|
+
# 32016D0002, and this method gives 32016D0245 for it. Do not use the
|
|
105
|
+
# result as a CELLAR key; key an act by its ELI (#to_eli).
|
|
106
|
+
#
|
|
107
|
+
# @return [String]
|
|
75
108
|
def to_celex
|
|
76
109
|
"3#{year}#{self.class.type[:celex]}#{number.rjust(4, '0')}"
|
|
77
110
|
end
|
|
78
111
|
|
|
79
112
|
# The ELI of the act as published in the Official Journal.
|
|
80
113
|
def to_eli
|
|
81
|
-
|
|
114
|
+
eli = self.class.type[:eli]
|
|
115
|
+
eli = "#{eli}_#{subtype}" if subtype
|
|
116
|
+
"http://data.europa.eu/eli/#{eli}/#{year}/#{number}/oj"
|
|
82
117
|
end
|
|
83
118
|
|
|
84
119
|
# The EU has no registered URN namespace (the ELI is its official
|
|
@@ -109,9 +144,45 @@ module Pubid
|
|
|
109
144
|
|
|
110
145
|
identifier = ::Pubid.utf8_input(identifier)
|
|
111
146
|
|
|
112
|
-
parsed =
|
|
113
|
-
Builder.build(parsed, identifier)
|
|
147
|
+
parsed, subtype = bound_without_subtype(identifier)
|
|
148
|
+
Builder.build(parsed, identifier, subtype: subtype)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Runs the grammar on the input without its ELI subtype.
|
|
152
|
+
#
|
|
153
|
+
# @return [Array(Hash, String|nil)] the bound captures, and the
|
|
154
|
+
# subtype ("impl" …) or nil
|
|
155
|
+
def self.bound_without_subtype(identifier)
|
|
156
|
+
subtype = eli_subtype(identifier)
|
|
157
|
+
input = subtype ? identifier.sub(ELI_SUBTYPE, '\\1/') : identifier
|
|
158
|
+
[Pubid::Parg::Model.bound(:eu, input), subtype]
|
|
159
|
+
rescue Pubid::Errors::ParseError => e
|
|
160
|
+
raise unless subtype
|
|
161
|
+
|
|
162
|
+
raise subtype_parse_error(e, identifier, input, subtype)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# A known subtype of a known ELI type, or nil. An unknown one stays in
|
|
166
|
+
# the input, so the grammar rejects it.
|
|
167
|
+
def self.eli_subtype(identifier)
|
|
168
|
+
match = ELI_SUBTYPE.match(identifier)
|
|
169
|
+
return nil unless match
|
|
170
|
+
|
|
171
|
+
subtype = match[3]
|
|
172
|
+
subtype if ELI_SUBTYPES.fetch(match[2]).include?(subtype)
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# The grammar saw the input without "_<subtype>"; report what the
|
|
176
|
+
# caller passed (the position in the message is in the shorter text).
|
|
177
|
+
def self.subtype_parse_error(error, identifier, input, subtype)
|
|
178
|
+
Pubid::Errors::ParseError.new(
|
|
179
|
+
"#{error.message} (in #{input.inspect}, the input without " \
|
|
180
|
+
"\"_#{subtype}\")", error.parse_failure_cause,
|
|
181
|
+
input: identifier, flavor: error.flavor
|
|
182
|
+
)
|
|
114
183
|
end
|
|
184
|
+
private_class_method :eli_subtype, :subtype_parse_error
|
|
185
|
+
private_class_method :bound_without_subtype
|
|
115
186
|
end
|
|
116
187
|
end
|
|
117
188
|
end
|
|
@@ -10,10 +10,12 @@ module Pubid
|
|
|
10
10
|
#
|
|
11
11
|
# Every act has a year and a number, so both are the positional core,
|
|
12
12
|
# year first (the CELEX and ELI order). The legal family is an atom; the
|
|
13
|
-
# number-order flag records only the spelling,
|
|
13
|
+
# number-order flag records only the spelling, and the ELI subtype
|
|
14
|
+
# (reg_impl …) names no other act, so both are facets.
|
|
14
15
|
PubidUrnSchema = Pubid::PubidUrn.define("eu") do
|
|
15
16
|
atom "family", "family"
|
|
16
17
|
facet "number_first", "numberfirst", kind: :bool
|
|
18
|
+
facet "subtype", "subtype"
|
|
17
19
|
|
|
18
20
|
type "pubid:eu:regulation", "reg", core: %w[year number]
|
|
19
21
|
type "pubid:eu:directive", "dir", core: %w[year number]
|
data/lib/pubid/itu/CLAUDE.md
CHANGED
|
@@ -20,6 +20,34 @@ These notes were part of the root `CLAUDE.md`. Read them before you change `lib/
|
|
|
20
20
|
|
|
21
21
|
- **ITU-R Reports (`Identifiers::Report`) and the class-strict `Identifier#==`**: ITU-R **Reports** are a publication series that numbers **independently** of Recommendations, so `ITU-R BT.2020-1` names *two* real, both-current documents (Report BT.2020-1, objective quality assessment, 2000; Recommendation BT.2020-1, UHDTV parameter values, 06/2014). 984 of 1,001 report records in `relaton-data-itu` were indexed as `pubid:itu:recommendation`, and 52 editions across 30 numbers (BT.2020, M.2083, M.2134 …) collided outright — the dataset keys files by identifier, so whichever was crawled last silently overwrote the other. ITU disambiguates with the leading word, so the identifier must too. **The leaf** `Identifiers::Report` (`_type: pubid:itu:report`) is shaped exactly like `Recommendation` — same attributes, same `StandardSerialization` flat block, so only `_type` distinguishes the two hashes — and adds just `render_base` (`"Report #{super}"`) and `mr_type` (`[super, "report"].join(".")` → `itu.r.report.bt-2020-1`). **Grammar**: a captured `report_word` marker (unlike `itu_prefix`'s decorative, *uncaptured* `"Recommendation "` literal, which stays as it is) plus a single `report_body` whose `(series >> dot).maybe` covers the with- and without-series shapes at once; `base_report` accepts **both** spellings (`Report ITU-R BT.2020-1` and the downstream `ITU-R Report BT.2020-1`), and `to_s` renders ITU's own leading form for either — so the infix spelling lives in `report_spec.rb` with an explicit expectation, **not** in the byte-exact pass fixtures. Two deliberate exclusions from `report_body`: **no `combined_suffixes`** (a joint `Report X/Y` would reach `Builder#build`'s `combined` branch, build a `CombinedIdentifier` and *silently drop the marker* — a clean parse failure is better), and a **`(str("OB") >> dot).absent?` guard** (an Operational Bulletin is cross-bureau; without it `Report ITU-T OB.1` routes to `SpecialPublication`, marker dropped, or trips `validate_ob_no_sector!`, whose `ArgumentError` escapes `Identifier.parse`'s `Parslet::ParseFailed` rescue). `base_report` is **first** in `rule(:base)` — which is what lets a supplement/annex/appendix *wrap* a Report — and order-free there because `itu_prefix` admits only `Recommendation `/`ITU` and `letter` is `[A-Z]`, so neither `series` nor `series_code_body` can consume `Report`; `report_identifier` sits in `rule(:identifier)` **after** supplement/annex/appendix (which match the longer wrapped form) and **before** `with_series`/`without_series` (which would match the infix spelling's `ITU-R` prefix and then fail on the unconsumed tail). The builder picks the class from `data[:report_marker]` in the existing Recommendation fallthrough; `build_supplement`/`build_annex_of_recommendation` need **no** change, since they recurse via `build(data[:base])`. **`Pubid::Itu::Identifier#==` is now class-strict** (`other.instance_of?(self.class)`, the rule `Supplement#==` already used) — the ITU *type* is part of the identity, not just sector/series/number. `self.class` rather than a hard-coded class keeps it **symmetric in both directions** (an `is_a?` guard would have made a Recommendation equal a Report one-way, and `#matches?` — which is `exclude(*ignore) == other.exclude(*ignore)` — resolve one to the other). Strictly stricter, so it can only turn `true` into `false`; it also closes the pre-existing one-way holes against `CombinedIdentifier` and `SpecialPublication`. **Consequences of the shared guard, both pinned by `spec/pubid/itu/type_strict_equality_spec.rb`:** comparisons that used to be *asymmetric* are now consistently false — most notably a bare primary designation vs its joint recommendation (`ITU-T G.780` vs `ITU-T G.780/Y.1351`, which was `true` one way and `false` the other on `main`, so no caller could rely on it either way). A caller matching a bare primary against a joint document must narrow on `root.number` (which still agrees) rather than on `==`. Per the cross-cutting ITU lesson, the marker reaches **all** identity surfaces: `to_s`, `generate_base_urn` (a `report` segment right after the sector — `urn:itu:r:report:BT.2020-1:2000`, which `UrnParser` also reads back), and the MR slug — including **`Supplement#mr_type`**, which is load-bearing and easy to miss: a supplement has no `mr_supplement_suffix`, so the shared MR renderer slugs it **flat** from the sector/series/code `build_supplement` copied up from its base and *never consults the base's class*, which made `Report ITU-R BT.2020-1 Suppl. 1` and `ITU-R BT.2020-1 Suppl. 1` share one slug (i.e. one output filename — the very overwrite this type prevents). It appends `report` when **`root`** is a Report, so a supplement of an *annex* of a Report is covered too. **`PREFIXES` stays `["ITU"]`** — the leading `Report` token is deliberately not registered for prefix routing (a generic English word; the mixin's ambiguous-token exclusion), and the infix spelling routes on `ITU` as before. **Backwards compatibility is exact**: a bare `ITU-R BT.2020-1` still builds a `Recommendation` with an unchanged hash/`to_s`/URN — nothing in the grammar or the builder fires without the marker, so none of the 20,728 published index rows move. Locked by `spec/pubid/itu/identifiers/report_spec.rb`, a `distinctness_spec.rb` pair, rows in `root_number_spec.rb`/`serialization_spec.rb`/`urn_parser_spec.rb`, and `spec/fixtures/itu/identifiers/pass/report.txt`. **Out of scope (relaton's side, sequenced after this):** `DataParserR`/`DataCrawlerR` emitting the new docid form, `Relaton::Itu::Pubid`'s reference parser learning a `report` rule, and the `relaton-data-itu` filename-namespace migration + re-crawl that actually recovers the 34 missing Recommendations and 18 missing Reports. (hand-off: itu-r-report-identifier-type.)
|
|
22
22
|
|
|
23
|
+
- **ITU-R Resolutions (`Identifiers::Resolution`, `_type: pubid:itu:resolution`)**:
|
|
24
|
+
`Resolution ITU-R 1-9 (2023)` (ITU page id `R-RES-R.1-9-2023`). Built like
|
|
25
|
+
`Report`: the same flat `StandardSerialization` block, `render_base` adds
|
|
26
|
+
the leading word, `mr_type` adds `resolution` (`itu.r.resolution.1-9`), and
|
|
27
|
+
the URN gets a `resolution` segment (`urn:itu:r:resolution:1-9:2023`),
|
|
28
|
+
which `UrnParser::TYPE_SEGMENTS` reads back. The revision is `code.parts`,
|
|
29
|
+
so `matches?(…, ignore: %i[parts year])` finds every revision and
|
|
30
|
+
`root.number` is the bare number (`1` does not bucket with `10`). Grammar:
|
|
31
|
+
a captured `resolution_word` (`Resolution` or `Res.`), a `resolution_body`
|
|
32
|
+
of `code [document_date]` only — **no series**, so `Resolution ITU-R BT.1`
|
|
33
|
+
fails — and both the leading and the infix spelling (`ITU-R Res. 1-9`),
|
|
34
|
+
which render the leading form (`Pubid.parse` does not route
|
|
35
|
+
`Res. ITU-R 1-9`: no registered prefix and no exact round trip; a spec
|
|
36
|
+
locks this). `resolution_identifier` sits after
|
|
37
|
+
`report_identifier`, before `with_series`. It is **not** in `rule(:base)`:
|
|
38
|
+
no corpus has a wrapped Resolution, so a supplement of one fails to parse
|
|
39
|
+
rather than drop the marker. **The legacy `ITU-R R.1-9`** (the
|
|
40
|
+
relaton-data-itu spelling until the re-crawl, 245 rows) carries no marker
|
|
41
|
+
and stays a Recommendation of series `R`, unchanged. Verified: all 2,752
|
|
42
|
+
earlier ITU fixture ids byte-identical on `to_s`/`to_hash`/`to_urn`/MR/
|
|
43
|
+
pubid URN, and all 245 dataset numbers pass the relaton gate as
|
|
44
|
+
`Resolution ITU-R <n>`. **The grammar was baked here ahead of
|
|
45
|
+
pubid-grammar** (hand-off `pubid__pubid-grammar__itu-resolution-grammar`):
|
|
46
|
+
the `source` of `data/parg/itu.json` is the only copy of the change until
|
|
47
|
+
pubid-grammar adopts it. To rebake: `jq -j .source data/parg/itu.json >
|
|
48
|
+
itu.parg`, edit, `parsanol _1.5.1.0_ parg compile itu.parg -o
|
|
49
|
+
data/parg/itu.json`, `parsanol _1.5.1.0_ parg test data/parg/itu.json`.
|
|
50
|
+
|
|
23
51
|
## From the root note "Parse-failure error contract — uniform across every flavor"
|
|
24
52
|
|
|
25
53
|
**ITU's length guard was an early `return`, not a raise, and its comment blamed the wrong caller.** `Identifier.normalize_whitespace` (`lib/pubid/itu/identifiers/base.rb`) carried
|
|
@@ -127,7 +155,7 @@ a replay of all 24,382 rows and every ITU pass fixture showed 0 changes.
|
|
|
127
155
|
|
|
128
156
|
## pubid-scheme URN (issue #656)
|
|
129
157
|
|
|
130
|
-
`lib/pubid/itu/pubid_urn_schema.rb` covers all
|
|
158
|
+
`lib/pubid/itu/pubid_urn_schema.rb` covers all 18 types; design and rulings
|
|
131
159
|
in `docs/URN-SCHEMES.adoc` (`[[urn-itu]]`). **A new rendering flag needs a
|
|
132
160
|
place in that schema, or `#to_pubid_urn` raises for every id that sets it.**
|
|
133
161
|
Declare it as a `:bool` *facet* when it is spelling only (the
|
data/lib/pubid/itu/builder.rb
CHANGED
|
@@ -129,7 +129,12 @@ module Pubid
|
|
|
129
129
|
# Recommendation — only the leading word, captured as :report_marker,
|
|
130
130
|
# tells the two apart, and it has to, because the two series number
|
|
131
131
|
# independently and the same series/number is two real documents.
|
|
132
|
-
|
|
132
|
+
# A Resolution ("Resolution ITU-R 1-9") is told apart the same way,
|
|
133
|
+
# by its captured :resolution_marker.
|
|
134
|
+
klass = if data[:report_marker] then Identifiers::Report
|
|
135
|
+
elsif data[:resolution_marker] then Identifiers::Resolution
|
|
136
|
+
else Identifiers::Recommendation
|
|
137
|
+
end
|
|
133
138
|
|
|
134
139
|
klass.new(
|
|
135
140
|
sector: sector,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Itu
|
|
5
|
+
module Identifiers
|
|
6
|
+
# ITU-R Resolution, adopted by the Radiocommunication Assembly.
|
|
7
|
+
# Format: Resolution ITU-{SECTOR} {NUMBER}[-REVISION] [(YEAR)]
|
|
8
|
+
# Example: Resolution ITU-R 1-9 (2023)
|
|
9
|
+
#
|
|
10
|
+
# A Resolution has a number and a revision (`code.parts`, as for a
|
|
11
|
+
# Recommendation edition), never a series. Resolutions number
|
|
12
|
+
# independently of Recommendations, so the leading word is part of the
|
|
13
|
+
# identity: it reaches `to_s`, `to_urn` and `to_mr_string`, and the
|
|
14
|
+
# class-strict `Identifier#==` keeps "Resolution ITU-R 1-9" unequal to
|
|
15
|
+
# "ITU-R 1-9" in both directions.
|
|
16
|
+
#
|
|
17
|
+
# The grammar also reads "ITU-R Res. 1-9", "ITU-R Resolution 1-9" and
|
|
18
|
+
# "Res. ITU-R 1-9"; all render ITU's leading form. (`Pubid.parse` does
|
|
19
|
+
# not route "Res. ITU-R …": no registered prefix, no exact round trip.
|
|
20
|
+
# `Pubid::Itu.parse` reads it.) The legacy
|
|
21
|
+
# relaton-data-itu spelling "ITU-R R.1-9" carries no marker and stays a
|
|
22
|
+
# Recommendation of series R.
|
|
23
|
+
class Resolution < Identifier
|
|
24
|
+
include StandardSerialization
|
|
25
|
+
|
|
26
|
+
def render_base(**_opts)
|
|
27
|
+
"Resolution #{super}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# "itu.r.resolution.1-9": without the marker, the slug (an output
|
|
31
|
+
# filename) equals the one of Recommendation "ITU-R 1-9".
|
|
32
|
+
def mr_type
|
|
33
|
+
[super, "resolution"].compact.join(".")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -19,6 +19,7 @@ module Pubid
|
|
|
19
19
|
autoload :RadioRegulations, "#{__dir__}/identifiers/radio_regulations"
|
|
20
20
|
autoload :Recommendation, "#{__dir__}/identifiers/recommendation"
|
|
21
21
|
autoload :Report, "#{__dir__}/identifiers/report"
|
|
22
|
+
autoload :Resolution, "#{__dir__}/identifiers/resolution"
|
|
22
23
|
autoload :SpecialPublication, "#{__dir__}/identifiers/special_publication"
|
|
23
24
|
autoload :StandardSerialization, "#{__dir__}/identifiers/standard_serialization"
|
|
24
25
|
autoload :Supplement, "#{__dir__}/identifiers/supplement"
|
|
@@ -30,6 +30,9 @@ module Pubid
|
|
|
30
30
|
# well as `to_s` and the MR slug, or the two documents share an
|
|
31
31
|
# identifier on that surface.
|
|
32
32
|
parts << "report" if identifier.is_a?(Identifiers::Report)
|
|
33
|
+
# A Resolution numbers independently too ("1-9" is also a
|
|
34
|
+
# Recommendation number), so it gets its own segment.
|
|
35
|
+
parts << "resolution" if identifier.is_a?(Identifiers::Resolution)
|
|
33
36
|
|
|
34
37
|
if identifier.series
|
|
35
38
|
series = identifier.series.to_s
|
data/lib/pubid/itu/urn_parser.rb
CHANGED
|
@@ -12,19 +12,18 @@ module Pubid
|
|
|
12
12
|
# - urn:itu:t:BO.1073-1 → ITU-T BO.1073-1
|
|
13
13
|
# - urn:itu:r:BO.500 → ITU-R BO.500
|
|
14
14
|
class UrnParser < Pubid::UrnParser::Base
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
# UrnGenerator emits a type segment between the sector and the code for
|
|
16
|
+
# the series that number independently of the Recommendation series:
|
|
17
|
+
# urn:itu:r:report:BT.2020-1, urn:itu:r:resolution:1-9.
|
|
18
|
+
TYPE_SEGMENTS = { "report" => "Report", "resolution" => "Resolution" }
|
|
19
|
+
.freeze
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return flavor_parse("Report ITU-#{sector.upcase} #{parts[2]}")
|
|
25
|
-
end
|
|
21
|
+
def parse_urn(urn)
|
|
22
|
+
sector, *rest = split_parts(strip_namespace(urn))
|
|
23
|
+
word = TYPE_SEGMENTS[rest.first]
|
|
24
|
+
return flavor_parse("#{word} ITU-#{sector.upcase} #{rest[1]}") if word
|
|
26
25
|
|
|
27
|
-
flavor_parse("ITU-#{sector.upcase} #{
|
|
26
|
+
flavor_parse("ITU-#{sector.upcase} #{rest.first}")
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
end
|
|
@@ -48,5 +48,16 @@ module Pubid
|
|
|
48
48
|
name.split("::").last
|
|
49
49
|
.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym
|
|
50
50
|
end
|
|
51
|
+
|
|
52
|
+
# True for a flavor that accredits other publishers' documents and so
|
|
53
|
+
# parses their joint prefix too (ANSI reads +ANSI/AMCA 210-16+). When
|
|
54
|
+
# it shares a prefix with a co-publisher's own flavor, {Pubid.parse}
|
|
55
|
+
# tries it last and prefers the co-publisher's parse, even a
|
|
56
|
+
# normalizing one. Default false.
|
|
57
|
+
#
|
|
58
|
+
# @return [Boolean]
|
|
59
|
+
def routing_umbrella?
|
|
60
|
+
false
|
|
61
|
+
end
|
|
51
62
|
end
|
|
52
63
|
end
|
data/lib/pubid/version.rb
CHANGED
data/lib/pubid.rb
CHANGED
|
@@ -502,6 +502,14 @@ module Pubid
|
|
|
502
502
|
|
|
503
503
|
prefix_owners = candidates_by_prefix(string)
|
|
504
504
|
(prefix_owners + other_candidates(prefix_owners)).each do |mod|
|
|
505
|
+
# An umbrella flavor (ANSI) also parses the joint prefix of a
|
|
506
|
+
# co-publisher that has its own flavor; that flavor's parse wins.
|
|
507
|
+
# Only as a prefix owner: in the exhaustive pass the umbrella is one
|
|
508
|
+
# flavor among the others, and stopping there would skip the rest.
|
|
509
|
+
if fallback && routing_umbrella?(mod) && prefix_owners.include?(mod)
|
|
510
|
+
return fallback
|
|
511
|
+
end
|
|
512
|
+
|
|
505
513
|
begin
|
|
506
514
|
parsed = mod.parse(string)
|
|
507
515
|
rescue Pubid::Errors::ParseError => e
|
|
@@ -565,10 +573,19 @@ module Pubid
|
|
|
565
573
|
routing_table.each do |prefix, modules|
|
|
566
574
|
ordered.concat(modules) if prefix_match?(string, prefix)
|
|
567
575
|
end
|
|
568
|
-
|
|
576
|
+
# An umbrella flavor goes after the other owners (stable partition).
|
|
577
|
+
ordered.compact.uniq.partition { |mod| !routing_umbrella?(mod) }.flatten
|
|
569
578
|
end
|
|
570
579
|
private_class_method :candidates_by_prefix
|
|
571
580
|
|
|
581
|
+
# @param mod [Module] a flavor module
|
|
582
|
+
# @return [Boolean] see {PrefixesSupport#routing_umbrella?}
|
|
583
|
+
# @api private
|
|
584
|
+
def self.routing_umbrella?(mod)
|
|
585
|
+
mod.respond_to?(:routing_umbrella?) && mod.routing_umbrella?
|
|
586
|
+
end
|
|
587
|
+
private_class_method :routing_umbrella?
|
|
588
|
+
|
|
572
589
|
# Every other registered flavor, for the exhaustive second pass.
|
|
573
590
|
#
|
|
574
591
|
# @param exclude [Array<Module>] modules already tried
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pubid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.47
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -188,6 +188,7 @@ files:
|
|
|
188
188
|
- lib/pubid/amca/urn_generator.rb
|
|
189
189
|
- lib/pubid/amca/urn_parser.rb
|
|
190
190
|
- lib/pubid/ansi.rb
|
|
191
|
+
- lib/pubid/ansi/CLAUDE.md
|
|
191
192
|
- lib/pubid/ansi/builder.rb
|
|
192
193
|
- lib/pubid/ansi/identifier.rb
|
|
193
194
|
- lib/pubid/ansi/identifiers.rb
|
|
@@ -915,6 +916,7 @@ files:
|
|
|
915
916
|
- lib/pubid/itu/identifiers/radio_regulations.rb
|
|
916
917
|
- lib/pubid/itu/identifiers/recommendation.rb
|
|
917
918
|
- lib/pubid/itu/identifiers/report.rb
|
|
919
|
+
- lib/pubid/itu/identifiers/resolution.rb
|
|
918
920
|
- lib/pubid/itu/identifiers/special_publication.rb
|
|
919
921
|
- lib/pubid/itu/identifiers/standard_serialization.rb
|
|
920
922
|
- lib/pubid/itu/identifiers/supplement.rb
|