pubid 2.0.6 → 2.0.8

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +16 -0
  3. data/lib/pubid/ansi/pubid_urn_schema.rb +44 -0
  4. data/lib/pubid/ansi.rb +1 -0
  5. data/lib/pubid/api/pubid_urn_schema.rb +29 -0
  6. data/lib/pubid/api.rb +1 -0
  7. data/lib/pubid/ashrae/pubid_urn_schema.rb +37 -0
  8. data/lib/pubid/ashrae.rb +1 -0
  9. data/lib/pubid/asme/pubid_urn_schema.rb +34 -0
  10. data/lib/pubid/asme.rb +1 -0
  11. data/lib/pubid/astm/CLAUDE.md +8 -0
  12. data/lib/pubid/astm/pubid_urn_schema.rb +47 -0
  13. data/lib/pubid/astm.rb +1 -0
  14. data/lib/pubid/identifier.rb +15 -0
  15. data/lib/pubid/iec/pubid_urn_schema.rb +32 -0
  16. data/lib/pubid/iec.rb +1 -0
  17. data/lib/pubid/ieee/CLAUDE.md +2 -0
  18. data/lib/pubid/ieee/pubid_urn_schema.rb +150 -0
  19. data/lib/pubid/ieee.rb +1 -0
  20. data/lib/pubid/iso/pubid_urn_schema.rb +61 -0
  21. data/lib/pubid/iso.rb +1 -0
  22. data/lib/pubid/itu/CLAUDE.md +15 -0
  23. data/lib/pubid/itu/pubid_urn_schema.rb +82 -0
  24. data/lib/pubid/itu.rb +1 -0
  25. data/lib/pubid/jcgm/pubid_urn_schema.rb +29 -0
  26. data/lib/pubid/jcgm.rb +1 -0
  27. data/lib/pubid/nist/CLAUDE.md +13 -0
  28. data/lib/pubid/nist/pubid_urn_schema.rb +108 -0
  29. data/lib/pubid/nist.rb +1 -0
  30. data/lib/pubid/oiml/pubid_urn_schema.rb +46 -0
  31. data/lib/pubid/oiml.rb +1 -0
  32. data/lib/pubid/pubid_urn/decoder.rb +156 -0
  33. data/lib/pubid/pubid_urn/encoder.rb +175 -0
  34. data/lib/pubid/pubid_urn/escape.rb +60 -0
  35. data/lib/pubid/pubid_urn/paths.rb +87 -0
  36. data/lib/pubid/pubid_urn/schema.rb +184 -0
  37. data/lib/pubid/pubid_urn.rb +226 -0
  38. data/lib/pubid/type_resolver.rb +12 -0
  39. data/lib/pubid/version.rb +1 -1
  40. data/lib/pubid.rb +18 -0
  41. metadata +20 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a55050f14ad3cf19fd2e3d3a00faf0d2258cf761d71515716cdf61a172ce0484
4
- data.tar.gz: 9c150c6b494788ad7b3f158ed0bd9132d8ae970089e182d9f5cef7885d22a7de
3
+ metadata.gz: 8013a826102b555c7067ce39bb01b1b3a4d43a6ec09ba6092ae4fe80ce364c8e
4
+ data.tar.gz: 9e7ebbfa50e70911201bc5800438ed661c1d03116c85e7f96f164bfc4089b615
5
5
  SHA512:
6
- metadata.gz: 665bddc99ab7da91c7f67c045655b0b55ef86b500469efdca15a7215ec89479f1fa0c1046fbad88ea3683ed664a3c6d01d54a6fe4800d681ec1b758d73b5b01f
7
- data.tar.gz: 6fada1851bb8adbbc936ca69167336f6ddd88dfcce72dbeeb9a73a035449547a8cd6324d5b1240ed3aaa71ddadceb9dff89d5efe22e9f62df0a775055f4110f0
6
+ metadata.gz: f3d0739c523091e44a03e9c4796696a046dbbad30b6681cc4d19e69df785fff10a8bfb83912bff0d3215def503a1d28d48e1f1ca5f76335424cf9f7782c672bd
7
+ data.tar.gz: ae1b998769f90c7ea9463cd11c66f0374bf4598d2c7a425bb2f615c5acf592652f2a98fba9bf3b8c1db5c10d4f7b24952c516ca994de58f2f8c55b17db42919b
data/README.adoc CHANGED
@@ -88,6 +88,22 @@ id.to_urn # => "urn:iso:std:iso:9001:amd:2020:v1"
88
88
  * ✅ Multi-level supplement support with correct nesting order
89
89
  * ✅ Round-trip parsing (parse_urn -> to_urn) for ISO and IEC
90
90
 
91
+ === The pubid-scheme URN
92
+
93
+ `#to_urn` follows the registered grammar of the organization, which can
94
+ drop values (RFC 5141 has no year). `#to_pubid_urn` is pubid's own URN: it
95
+ carries every value, always round-trips through `Pubid.parse_urn`, and is
96
+ safe to use as an HTTP path. ISO, IEEE, ANSI, ITU, NIST and ASTM support it now; the other flavors follow
97
+ (link:docs/URN-SCHEMES.adoc[URN schemes]).
98
+
99
+ [source,ruby]
100
+ ----
101
+ id = Pubid::Iso.parse("ISO 9001:2015/Amd 1:2016")
102
+ id.to_pubid_urn
103
+ # => "urn:pubid:iso:is:9001:year-2015:amd:1:year-2016"
104
+ Pubid.parse_urn(id.to_pubid_urn).to_s # => "ISO 9001:2015/Amd 1:2016"
105
+ ----
106
+
91
107
  === Key Difference: ISO vs IEC Part Numbering
92
108
 
93
109
  ISO URNs (RFC 5141): part number is a separate colon-separated field:
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Ansi
5
+ # The pubid-scheme URN of ANSI (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # ANSI 802.3-2012
8
+ # urn:pubid:ansi:std:802.3:pub-ANSI:part-2012
9
+ #
10
+ # Landed with the IEEE wave, which nests ANSI ids ("IEEE Std 144-1971
11
+ # (ANSI C37.24-1971)"). Note that ANSI stores the year of
12
+ # "ANSI 802.3-2012" in +part+ ("2012"); the URN keeps it as it is.
13
+ #
14
+ # A component attribute maps through its identifying field only
15
+ # (+type.abbr+, +stage.abbr+, +edition.number+ …). The registry fields of
16
+ # a stage or a type (+name+, +harmonized_stages+) are deliberately not
17
+ # placed, so a value there makes #to_pubid_urn raise rather than write
18
+ # registry data into the URN. The corpus sets none of them.
19
+ PubidUrnSchema = Pubid::PubidUrn.define("ansi") do
20
+ atom "publisher.body", "pub"
21
+ atom "copublishers.*.body", "co"
22
+ atom "type.abbr", "type"
23
+ atom "part", "part"
24
+ atom "subpart", "subpart"
25
+ atom "year", "year"
26
+ atom "date.year", "dateyear"
27
+ atom "date.month", "datemonth"
28
+ atom "date.day", "dateday"
29
+ atom "date.undated", "undated", kind: :bool
30
+ atom "edition.number", "ed"
31
+ atom "stage.abbr", "stage"
32
+ atom "stage_iteration.number", "iter"
33
+ atom "languages.*.code", "lang"
34
+ atom "locality.value", "loc"
35
+
36
+ facet "languages.*.original_code", "langsrc"
37
+ facet "edition.original_text", "edsrc"
38
+
39
+ type "pubid:ansi:standard", "std"
40
+ type "pubid:ansi:american-national-standard", "ans"
41
+ type "pubid:ansi:identifier", "id"
42
+ end
43
+ end
44
+ end
data/lib/pubid/ansi.rb CHANGED
@@ -14,6 +14,7 @@ module Pubid
14
14
  autoload :Identifier, "#{__dir__}/ansi/identifier"
15
15
  autoload :Identifiers, "#{__dir__}/ansi/identifiers"
16
16
  autoload :Parser, "#{__dir__}/ansi/parser"
17
+ autoload :PubidUrnSchema, "#{__dir__}/ansi/pubid_urn_schema"
17
18
  autoload :Renderer, "#{__dir__}/ansi/renderer"
18
19
  autoload :SingleIdentifier, "#{__dir__}/ansi/single_identifier"
19
20
  autoload :UrnGenerator, "#{__dir__}/ansi/urn_generator"
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Api
5
+ # The pubid-scheme URN of API (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # API MPMS Ch. 10.10 -> urn:pubid:api:mpms:10.10:subsec-...
8
+ #
9
+ # The number is the core of every type; +part+, +section+ and
10
+ # +subsection+ are atoms, in the doc's canonical order.
11
+ PubidUrnSchema = Pubid::PubidUrn.define("api") do
12
+ atom "part", "part"
13
+ atom "section", "section"
14
+ atom "subsection", "subsection"
15
+
16
+ type "pubid:api:base", "base"
17
+ type "pubid:api:bulletin", "bulletin"
18
+ type "pubid:api:continuous-operations-standard", "cos"
19
+ type "pubid:api:identifier", "id"
20
+ type "pubid:api:mpms", "mpms"
21
+ type "pubid:api:publication", "pub"
22
+ type "pubid:api:recommended-practice", "rp"
23
+ type "pubid:api:specification", "spec"
24
+ type "pubid:api:standard", "std"
25
+ type "pubid:api:technical-report", "tr"
26
+ type "pubid:api:typeless-standard", "ts"
27
+ end
28
+ end
29
+ end
data/lib/pubid/api.rb CHANGED
@@ -16,6 +16,7 @@ module Pubid
16
16
  autoload :SingleIdentifier, "#{__dir__}/api/single_identifier"
17
17
  autoload :UrnGenerator, "#{__dir__}/api/urn_generator"
18
18
  autoload :UrnParser, "#{__dir__}/api/urn_parser"
19
+ autoload :PubidUrnSchema, "#{__dir__}/api/pubid_urn_schema"
19
20
 
20
21
  def self.parse(input)
21
22
  Identifier.parse(input)
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Ashrae
5
+ # The pubid-scheme URN of ASHRAE (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # ASHRAE Standard 15-2007 (RA 2010)
8
+ # urn:pubid:ashrae:std:15:year-2007:reaffirmed-2010
9
+ #
10
+ # The number is the core of every type (the base-anchored ones emit
11
+ # it as NULL when absent — the errata and the package carry their
12
+ # identity in the base chain). The atoms follow the doc's canonical
13
+ # order; the date internals stay placed until the Components::Code
14
+ # reduction lands (docs/URN-SCHEMES.adoc, ashrae finding).
15
+ PubidUrnSchema = Pubid::PubidUrn.define("ashrae") do
16
+ atom "copublisher", "co"
17
+ atom "year", "year"
18
+ atom "date.day", "dateday"
19
+ atom "date.month", "datemonth"
20
+ atom "date.year", "dateyear"
21
+ atom "addendum_code", "addendumcode"
22
+ atom "addendum_codes", "addendumcodes"
23
+ atom "package_description", "packagedescription"
24
+ atom "reaffirmed", "reaffirmed"
25
+ atom "suffix", "suffix"
26
+
27
+ type "pubid:ashrae:addenda-package", "ap"
28
+ type "pubid:ashrae:addendum", "add"
29
+ type "pubid:ashrae:combined-addenda", "ca"
30
+ type "pubid:ashrae:errata", "err"
31
+ type "pubid:ashrae:guideline", "g"
32
+ type "pubid:ashrae:identifier", "id"
33
+ type "pubid:ashrae:interpretation", "interp"
34
+ type "pubid:ashrae:standard", "std"
35
+ end
36
+ end
37
+ end
data/lib/pubid/ashrae.rb CHANGED
@@ -18,6 +18,7 @@ module Pubid
18
18
  autoload :SupplementIdentifier, "#{__dir__}/ashrae/supplement_identifier"
19
19
  autoload :UrnGenerator, "#{__dir__}/ashrae/urn_generator"
20
20
  autoload :UrnParser, "#{__dir__}/ashrae/urn_parser"
21
+ autoload :PubidUrnSchema, "#{__dir__}/ashrae/pubid_urn_schema"
21
22
 
22
23
  def self.parse(identifier)
23
24
  unless identifier.is_a?(String)
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Asme
5
+ # The pubid-scheme URN of ASME (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # ASME B30.3-20XX (Revision of ASME B30.1-2020)
8
+ # urn:pubid:asme:std:B30.3:pub-ASME:draftyear-20XX
9
+ # :parentheticalrevision-...
10
+ #
11
+ # The number is the core; the atoms follow the doc's canonical order.
12
+ # +parenthetical_revision+ and +revision_note+ are the two verbatim
13
+ # bracket notes, case-kept.
14
+ PubidUrnSchema = Pubid::PubidUrn.define("asme") do
15
+ atom "publisher", "pub"
16
+ atom "year", "year"
17
+ atom "language", "lang"
18
+ atom "csa_number", "csanumber"
19
+ atom "draft_year", "draftyear"
20
+ atom "first_code", "firstcode"
21
+ atom "first_publisher", "firstpublisher"
22
+ atom "handbook", "handbook", kind: :bool
23
+ atom "joint_publisher", "jointpublisher"
24
+ atom "parenthetical_revision", "parentheticalrevision"
25
+ atom "ptc_suffix", "ptcsuffix"
26
+ atom "revision_note", "revisionnote"
27
+ atom "second_publisher", "secondpublisher"
28
+
29
+ type "pubid:asme:base", "base"
30
+ type "pubid:asme:identifier", "id"
31
+ type "pubid:asme:standard", "std"
32
+ end
33
+ end
34
+ end
data/lib/pubid/asme.rb CHANGED
@@ -17,6 +17,7 @@ module Pubid
17
17
  autoload :SingleIdentifier, "#{__dir__}/asme/single_identifier"
18
18
  autoload :UrnGenerator, "#{__dir__}/asme/urn_generator"
19
19
  autoload :UrnParser, "#{__dir__}/asme/urn_parser"
20
+ autoload :PubidUrnSchema, "#{__dir__}/asme/pubid_urn_schema"
20
21
 
21
22
  def self.parse(str)
22
23
  Identifier.parse(str)
@@ -7,3 +7,11 @@ These notes were part of the root `CLAUDE.md`. Read them before you change `lib/
7
7
  ## From the root note "AMCA / ASME / ASTM index key (`root.number`): three flavors, three different shapes"
8
8
 
9
9
  **(3) ASTM — the mixin, on EVERY concrete class.** `Astm::Components::Code` is a five-field taxonomy (`letter`/`number`/`suffix`/`subseries`/`dual_m`) that the renderer reads field-by-field, so it keeps its structure: `Identifiers::CodeNumber` installs the five columns plus a derived `#code`. **It is included by `Standard` AND by `IsoDualPublished`, which inherits `Standard` — deliberately, not redundantly**: a class that is itself inherited from must still declare the columns so its subclass holds its own snapshot rather than relying on a parent table. `Adjunct` has no code at all, so its designation IS its number: the `designation` attribute was **removed** and the value stored in `number` directly, because keeping both made `to_hash` emit the same string twice and a `def number` shadowing the attribute is the construct CLAUDE.md forbids.
10
+
11
+ ## pubid-scheme URN (issue #656)
12
+
13
+ `lib/pubid/astm/pubid_urn_schema.rb` covers all 12 types; rulings in
14
+ `docs/URN-SCHEMES.adoc` (`[[urn-astm]]`). Every suffix marker (`-EB`, `-EA`,
15
+ `DVD`, the metric `M`, `TP`) names a different catalogue record, so all are
16
+ atoms and ASTM has no facet. A new marker attribute needs an atom there, or
17
+ `#to_pubid_urn` raises for every id that sets it.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Astm
5
+ # The pubid-scheme URN of ASTM (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # ASTM E2938-15(2023)
8
+ # urn:pubid:astm:std:2938:letter-E:year-2015:reapproval-2023
9
+ #
10
+ # The core is the document number; every other value is an optional
11
+ # prefixed atom. Each suffix marker ("-EB", "-EA", "DVD", the metric
12
+ # "M", the "TP" of a manual) names a different catalogue record, so all
13
+ # are atoms and none is a facet. The current urn:astm: form of #to_urn
14
+ # is pubid-invented and stays as it is.
15
+ PubidUrnSchema = Pubid::PubidUrn.define("astm") do
16
+ atom "publisher", "pub"
17
+ atom "committee", "committee"
18
+ atom "letter", "letter"
19
+ atom "subseries", "subseries"
20
+ atom "suffix", "suffix"
21
+ atom "dual_m", "metric", kind: :bool
22
+ atom "year", "year"
23
+ atom "sub_year", "subyear"
24
+ atom "reapproval", "reapproval"
25
+ atom "edition", "ed"
26
+ atom "supplement", "sup", kind: :bool
27
+ atom "tp_designation", "tp"
28
+ atom "format_suffix", "format"
29
+ atom "ea_suffix", "ea", kind: :bool
30
+ atom "dvd_suffix", "dvd", kind: :bool
31
+ atom "hol_suffix", "hol", kind: :bool
32
+
33
+ type "pubid:astm:identifier", "id"
34
+ type "pubid:astm:single-identifier", "single"
35
+ type "pubid:astm:base", "base"
36
+ type "pubid:astm:standard", "std"
37
+ type "pubid:astm:iso-dual-published", "isodual"
38
+ type "pubid:astm:adjunct", "adj"
39
+ type "pubid:astm:data-series", "ds"
40
+ type "pubid:astm:manual", "mnl"
41
+ type "pubid:astm:monograph", "mono"
42
+ type "pubid:astm:research-report", "rr"
43
+ type "pubid:astm:technical-report", "tr"
44
+ type "pubid:astm:work-in-progress", "wk"
45
+ end
46
+ end
47
+ end
data/lib/pubid/astm.rb CHANGED
@@ -13,6 +13,7 @@ module Pubid
13
13
  autoload :Identifiers, "#{__dir__}/astm/identifiers"
14
14
  autoload :SingleIdentifier, "#{__dir__}/astm/single_identifier"
15
15
  autoload :Parser, "#{__dir__}/astm/parser"
16
+ autoload :PubidUrnSchema, "#{__dir__}/astm/pubid_urn_schema"
16
17
  autoload :Builder, "#{__dir__}/astm/builder"
17
18
  autoload :Renderer, "#{__dir__}/astm/renderer"
18
19
  autoload :UrnGenerator, "#{__dir__}/astm/urn_generator"
@@ -1114,6 +1114,21 @@ module Pubid
1114
1114
  resolve_urn_generator.new(self).generate
1115
1115
  end
1116
1116
 
1117
+ # The lossless pubid-scheme URN ("urn:pubid:…").
1118
+ #
1119
+ # It is in pubid's own namespace (issue #656), carries every value of
1120
+ # #to_hash and always round-trips through Pubid.parse_urn. Not the
1121
+ # same as #to_urn, the official, possibly lossy URN of the
1122
+ # organization. Defined once, here, from #to_hash and the flavor's
1123
+ # PubidUrnSchema; flavors do not override it.
1124
+ #
1125
+ # @return [String]
1126
+ # @raise [Pubid::Errors::InvalidInputError] when the flavor has no
1127
+ # pubid-scheme schema yet
1128
+ def to_pubid_urn
1129
+ Pubid::PubidUrn.generate(self)
1130
+ end
1131
+
1117
1132
  def resolve_urn_generator
1118
1133
  flavor = self.class.name.split("::")[1]
1119
1134
  Object.const_get("Pubid::#{flavor}::UrnGenerator")
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Iec
5
+ # The pubid-scheme URN of IEC — PARTIAL (issue #656;
6
+ # docs/URN-SCHEMES.adoc).
7
+ #
8
+ # Only +pubid:iec:international-standard+ is declared, because IEEE
9
+ # identifiers nest it (IEC/IEEE co-publications). IEC's own wave declares
10
+ # the rest of the flavor; until then IEC stays pending in the contract
11
+ # spec. The official RFC 5141-style urn:iec:std: form stays on #to_urn.
12
+ PubidUrnSchema = Pubid::PubidUrn.define("iec") do
13
+ atom "publisher", "pub"
14
+ atom "copublishers", "co", kind: :list
15
+ atom "part", "part"
16
+ atom "subpart", "subpart"
17
+ atom "year", "year"
18
+ atom "month", "month"
19
+ atom "day", "day"
20
+ atom "undated", "undated", kind: :bool
21
+ atom "edition", "ed"
22
+ atom "stage", "stage"
23
+ atom "stage_iteration", "iter"
24
+ atom "database", "database"
25
+ atom "languages.*.code", "lang"
26
+
27
+ facet "languages.*.original_code", "langsrc"
28
+
29
+ type "pubid:iec:international-standard", "is"
30
+ end
31
+ end
32
+ end
data/lib/pubid/iec.rb CHANGED
@@ -17,6 +17,7 @@ module Pubid
17
17
  autoload :SingleIdentifier, "#{__dir__}/iec/single_identifier"
18
18
  autoload :SupplementIdentifier, "#{__dir__}/iec/supplement_identifier"
19
19
  autoload :Parser, "#{__dir__}/iec/parser"
20
+ autoload :PubidUrnSchema, "#{__dir__}/iec/pubid_urn_schema"
20
21
  autoload :Builder, "#{__dir__}/iec/builder"
21
22
  autoload :UrnParser, "#{__dir__}/iec/urn_parser"
22
23
  autoload :UrnGenerator, "#{__dir__}/iec/urn_generator"
@@ -99,3 +99,5 @@ The lesson BSI paid for: a wrapper's hand-written `#number` delegation makes the
99
99
  - **Joint stage-first forms are lead ISO, and the ISO face is lossless (pubid#477)**: a stage word printed in the ISO position (`IEEE FCD 15026.3:2010`, `IEEE/IEC CD2 P62582-2017-05`) parses as printed (#469): `Builder#build_joint_development` sets `lead_party "ISO"` whatever the publisher order, so `canonical_format` is `:iso`. PR #472 had made the lead the first printed publisher and rendered an IEEE-first form in the `D=` face — but the grammar artifact cannot parse most of those renders (`D=FCD`, `D=CD.2`, a non-P number, a month), and `D=CD-2020` parses into a *different* id (`ieee_draft`, no `iso_stage`), so 19 published `relaton-data-ieee` rows stopped matching themselves. The `D=` face now prints only for an id that carries a `D=` designator, or on an explicit `to_s(format: :ieee)`. `JointDevelopment#to_iso_format` prints `iso_stage` as stored (`DIS2`, `CD4` — #472's bare `CD` lost the iteration) and the date in the spelling that parses back (`#iso_date_suffix`: `:2018`, `-2018-05`, `, April 2019`). **The test is `parse(to_s) == id`, not a stable `to_s`**: a lossy render reaches a fixed point and round-trips its *hash* (`iso_stage_spellings_spec` held both while dropping `CD4`→`CD`), yet the reparse is a different identifier. Measured over the 118 joint stage rows of `relaton-data-ieee`: `to_s` stable 100 → 118, `==` 51 → 106; the other 12 carry an `ieee_draft` or an edition that the ISO face still drops. **PARG separator-in-capture, again (#471)**: the draft `revision` capture is `".12"`, and `Draft#to_s` adds its own dot, so `handle_draft` strips the leading dot (`D2022.10.12` rendered `D2022.10..12`). Check every capture a renderer re-joins with a separator. Locked by `spec/pubid/ieee/joint_stage_roundtrip_spec.rb` (stored index hashes → `parse(to_s) == row`).
100
100
 
101
101
  - **IEEE parses through the edition-2 artifact's typed model bindings (the last converter wave)**: the three `Backend.parse` sites (`identifiers/base.rb` `parse_single`, `Aiee::Identifier.parse`, `Ire::Identifier.parse`) route through `Pubid::Parg::Model.bound` — the grammar's `bindings` block produces the builder-ready hash at the engine, replacing the tree normalization. The grammar side (pubid-grammar `grammars/{ieee,nesc}.parg` edition 2 + bindings, plus a class-ref inlining pass over the merged `aiee.parg`/`ire.parg`) keeps every capture the builder reads: leaf scalars bind `(string)`; the branch/wrapper captures the builder dispatches on (`draft`, `parameters`, `publishers`, `base`, `relationship_type`, `related_ids`, the aiee/ire/nesc wrappers, …) bind `(raw)` — raw subtrees carry `Parsanol::Slice` leaves whose `to_s`/`==` behave like strings, so `extract_value` and the `.is_a?(Hash)` probes are unchanged. **Load-bearing grammar deviations** (documented in the `.parg` headers): the zero-width markers are re-spelled as real-token captures (`printed_dash_year`/`printed_month_year` capture their branch's leading separator, `iec_label_dash` the dash, `iso_published` the whole joint head choice — every read sits behind a nil-`iso_stage` gate, so the wider presence set is inert exactly where v1's was narrow); the `([dash]) as draft_dash` / `([rev_sep] as rev_sep)` capture-over-OPTIONAL landmines are `[ (x) as y ]` (parsanol-ruby#394); nested-only captures that collide with a top-level name rename with the builder (`draft_date_month/year/day`, `draft_version_dash_*`, `fdraft_month/year`, and `reaffirmed_year` — unbound, because binding it would have surfaced the reaffirmation year v1 kept absent). **Class RULE refs (`digit`/`lower`/`upper`, and multi-char ones like `alnum_char`/`identifier_string`'s `non_nl`) materialize per-token named nodes inside captures when the runtime recompiles the `use`-importing source — the vendored `data/parg/{aiee,ire,nesc}.parg` copies are the live import sources, so they must be re-vendored together with the artifacts** (a stale `.parg` beside a fresh `.json` silently parses through the old grammar). **Builder accommodations** (all dual-key with the v1 spellings as fallback, so HEAD trees and bound maps read alike): the renamed nested keys; and the multi-segment draft-version normalization at the top of `build_single_identifier` — edition-2 trees materialize a "D2.1.1" designator as per-token nodes with no `:draft_version`, where v1 degraded to a whole-clause leaf (reconstructed: the leaf string → `Draft.parse` inverse) or to a date-only hash when a draft date follows (no draft built). **Measured**: fixture-corpus parity (old artifact + tree backend + builder vs new artifact + bound + builder) over all 9,054 pass-fixture inputs → 1 diff, and standalone aiee/ire/nesc sweeps → 0 diffs each. **The one residue is an engine wall, documented not chased**: `IEC/IEEE PC37.60/P62271-111_D6.1` (testsuite case `ieee.project_draft_identifier.0946`, one corpus input, one `draft_compact_convergence` example) — v1's edition-1 tree degraded its whole draft clause ("DP62271-111_D6.1, Aug 2016", two P-numbers plus date) into a single leaf, and edition-2's fully-named trees cannot reproduce that collapse at any binding spelling (isolated rule probes + programmatic branch bisect); the row is one of the two-P-number joint one-offs already recorded as deferred above. The conversion also **fixed** two testsuite rows (`ieee.project_draft_identifier.9263` "ISO/IEC/IEEE P42010.2019/D4" / "P42010.WD4:2019(E)" — the lettered `draft_iso_iteration` capture now binds, so the D= face composes), at the cost of the 0946 residue above.
102
+
103
+ - **The pubid-scheme URN (`#to_pubid_urn`, issue #656) — IEEE wave.** Schema: `lib/pubid/ieee/pubid_urn_schema.rb`; design and rulings: the `[[urn-ieee]]` section of `docs/URN-SCHEMES.adoc`. All 9,049 parseable pass ids emit, round-trip by `to_hash`, are path-safe and collision-free; the contract row is `spec/pubid/pubid_urn_contract_spec.rb`, the per-family examples `spec/pubid/ieee/pubid_urn_spec.rb`. **No `to_hash` change, so no `relaton-data-ieee` re-crawl.** Three things to know before editing: **(1)** the wrappers whose parent slot is not `base` (`ieee_identifier`, `first_identifier`, `primary_identifier` …, see "The parent slot is never called `base` in IEEE" above) write that document as a nested atom, so they do NOT share its slug prefix — renaming a slot to `base` moves every such URN; **(2)** IEEE nests ANSI and IEC ids, so ANSI landed whole with this wave and `lib/pubid/iec/pubid_urn_schema.rb` is a partial schema for the one IEC type the corpus nests — a new nested foreign type (an adopted `IEC TR`, `TS`, `AMD`, `CSV`) makes `#to_pubid_urn` raise until its flavor's schema declares it; **(3)** the schema must place every `to_hash` key, so a new IEEE attribute fails the contract row until its atom is declared — add it in the shared-vocabulary group it belongs to, never at the end out of habit, because atom order is part of every published slug. **The URN inherits two `to_hash` gaps, pinned rather than fixed**: `csa_identifier` is a plain accessor, so the CSA half of a `CsaDualPublished` is lost (4 corpus ids, and two such documents with the same IEEE half share a hash and a URN); and one `separator` serves every part, so `IEEE Std 7-4.3.2-2016` comes back as `7.4.3.2` (14 ids). A third: `SupplementIdentifier#to_hash` drops the delegated `publisher` only on a top-level wrapper, so for a non-IEEE supplement nested in an adoption (`IEEE Std 1234-2010 (ISO 1234/Amd 1:2001)`) `from_hash(to_hash)` is not idempotent and `parse_urn` refuses the emitted URN as not canonical (none in the corpus). Fixing any of the three changes `to_hash`. Separately, `IEC/IEEE P62582-6, FDIS May 2019` and `ISO/IEC/IEEE P21840, DIS-2019` raise `Parsanol::PARG::BindError` from `parse` — the parse-error contract expects `Pubid::Errors::ParseError`.
@@ -0,0 +1,150 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Ieee
5
+ # The pubid-scheme URN of IEEE (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # IEEE Std 802.11-2016
8
+ # urn:pubid:ieee:std:802:stage-Std:part-11:year-2016:f:0.sep-.
9
+ #
10
+ # The core is the document number. Every other value is an optional
11
+ # prefixed atom, in the order below: the shared vocabulary first (who,
12
+ # what, which part, when, which edition, which state), then the IEEE
13
+ # flags, then the identifiers an IEEE id nests.
14
+ #
15
+ # The wrappers that name their wrapped document something other than
16
+ # +base+ (+ieee_identifier+, +first_identifier+, +primary_identifier+ …)
17
+ # write it as a nested atom, not as a root-first chain node, so they do
18
+ # not share the slug prefix of that document. Renaming them to +base+
19
+ # would change #to_hash and needs a relaton-data-ieee re-crawl.
20
+ #
21
+ # The official urn:ieee:std: form (RFC 8069) stays on #to_urn.
22
+ PubidUrnSchema = Pubid::PubidUrn.define("ieee") do
23
+ # Who.
24
+ atom "publisher", "pub"
25
+ atom "publishers", "pubs", kind: :list
26
+ atom "lead_party", "lead"
27
+ atom "copublisher", "co", kind: :list
28
+ atom "copublishers.*.body", "copubs"
29
+ # What.
30
+ atom "prefix", "prefix"
31
+ atom "type", "type"
32
+ atom "variant", "variant"
33
+ # Which part.
34
+ atom "parts", "part", kind: :list
35
+ atom "part", "pt"
36
+ atom "subpart", "subpart"
37
+ # When.
38
+ atom "year", "year"
39
+ atom "month", "month"
40
+ atom "day", "day"
41
+ atom "date.year", "dateyear"
42
+ atom "date.month", "datemonth"
43
+ atom "date.day", "dateday"
44
+ atom "date.undated", "undated", kind: :bool
45
+ atom "date_info", "dateinfo"
46
+ atom "iec_year", "iecyear"
47
+ # Which edition or revision.
48
+ atom "edition", "ed"
49
+ atom "edition_month", "edmonth"
50
+ atom "revision", "rev"
51
+ atom "reaffirmed", "reaff"
52
+ # Which state.
53
+ atom "stage", "stage"
54
+ atom "stage_iteration", "iter"
55
+ atom "iso_stage", "isostage"
56
+ atom "ieee_draft", "ieeedraft"
57
+ atom "draft", "draft"
58
+ atom "draft_info", "draftinfo"
59
+ atom "draft_status", "draftstatus"
60
+ atom "typed_stage.abbr", "tsabbr", kind: :list
61
+ atom "typed_stage.stage_code", "tsstage"
62
+ atom "typed_stage.type_code", "tstype"
63
+ atom "typed_stage.iso_stage_equivalent", "tsiso"
64
+ atom "typed_stage.ieee_draft_equivalent", "tsieee"
65
+ atom "typed_stage.approval_status", "tsapproval"
66
+ atom "typed_stage.project_status", "tsproject", kind: :bool
67
+ # Which language and locality.
68
+ atom "languages.*.code", "lang"
69
+ atom "locality.value", "loc"
70
+ # IEEE flags and free-text designations.
71
+ atom "project_marker", "project", kind: :bool
72
+ atom "redline", "redline", kind: :bool
73
+ atom "interpretation", "interp", kind: :bool
74
+ atom "registered", "registered", kind: :bool
75
+ atom "abbr_suffix", "abbrsuffix", kind: :bool
76
+ atom "abbr_suffix_registered", "abbrsuffixreg", kind: :bool
77
+ atom "rev_bare", "revbare", kind: :bool
78
+ atom "space_before_draft", "spacedraft", kind: :bool
79
+ atom "month_glued", "monthglued", kind: :bool
80
+ atom "ashrae_number", "ashrae"
81
+ atom "ashrae_year", "ashraeyear"
82
+ atom "iso_identifier", "isoid"
83
+ atom "adoption", "adoption"
84
+ atom "amendment_to", "amendmentto"
85
+ atom "crossref", "crossref"
86
+ atom "nickname", "nick"
87
+ atom "note", "note"
88
+ atom "parenthetical_content", "paren"
89
+ atom "relationships.*.relationship_type", "rel"
90
+ # Identifiers an IEEE id nests.
91
+ atom "ieee_identifier", "ieeeid", kind: :id
92
+ atom "iec_identifier", "iecid", kind: :id
93
+ atom "first_identifier", "first", kind: :id
94
+ atom "second_identifier", "second", kind: :id
95
+ atom "primary_identifier", "primary", kind: :id
96
+ atom "secondary_identifier", "secondary", kind: :id
97
+ atom "parenthetical_identifier", "parenid", kind: :id
98
+ atom "adopted_identifiers", "adopted", kind: :ids
99
+ atom "revision_of", "revof", kind: :id
100
+ atom "supplement_to", "supto", kind: :id
101
+ atom "amendments", "amds", kind: :ids
102
+ atom "corrigenda", "cors", kind: :ids
103
+ atom "incorporates", "incl", kind: :ids
104
+ atom "supersedes", "supersedes", kind: :ids
105
+
106
+ # Spelling only.
107
+ facet "separator", "sep"
108
+ facet "separators.*", "seps"
109
+ facet "rev_sep", "revsep"
110
+ facet "year_sep", "yearsep"
111
+ facet "date_separator", "datesep"
112
+ facet "original_format", "format"
113
+ facet "languages.*.original_code", "langsrc"
114
+
115
+ type "pubid:ieee:standard", "std"
116
+ type "pubid:ieee:project-draft-identifier", "proj"
117
+ type "pubid:ieee:si-standard", "si"
118
+ type "pubid:ieee:redlined-standard", "redlined"
119
+ type "pubid:ieee:joint-development", "joint"
120
+ type "pubid:ieee:iec-ieee-copublished", "iecieee"
121
+ type "pubid:ieee:dual-identifier", "dual"
122
+ type "pubid:ieee:dual-published", "dualpub"
123
+ type "pubid:ieee:csa-dual-published", "csadual"
124
+ type "pubid:ieee:multi-numbered-identifier", "multi"
125
+ type "pubid:ieee:adopted-standard", "adopted"
126
+ type "pubid:ieee:parenthetical-identifier", "paren"
127
+
128
+ type "pubid:ieee:amendment", "amd"
129
+ type "pubid:ieee:corrigendum", "cor"
130
+ type "pubid:ieee:interpretation-identifier", "int"
131
+ type "pubid:ieee:conformance-identifier", "conf"
132
+ type "pubid:ieee:supplement-identifier", "sup"
133
+
134
+ type "pubid:ieee:aiee", "aiee"
135
+ type "pubid:ieee:ire", "ire"
136
+
137
+ type "pubid:ieee:nesc-standard", "nesc"
138
+ type "pubid:ieee:nesc-edition", "nescedition"
139
+ type "pubid:ieee:nesc-handbook", "nescbook"
140
+ type "pubid:ieee:nesc-draft", "nescdraft"
141
+ type "pubid:ieee:nesc-preprint", "nescpre"
142
+ type "pubid:ieee:nesc-redline", "nescredline"
143
+
144
+ # The base class. The builder makes one for a parenthetical inside a
145
+ # relationship, whose related ids #to_hash does not serialize today;
146
+ # declared so that one in any other slot still emits.
147
+ type "pubid:ieee:identifier", "id"
148
+ end
149
+ end
150
+ end
data/lib/pubid/ieee.rb CHANGED
@@ -18,6 +18,7 @@ module Pubid
18
18
  autoload :Ire, "#{__dir__}/ieee/ire"
19
19
  autoload :Nesc, "#{__dir__}/ieee/nesc"
20
20
  autoload :Parser, "#{__dir__}/ieee/parser"
21
+ autoload :PubidUrnSchema, "#{__dir__}/ieee/pubid_urn_schema"
21
22
  autoload :PreParser, "#{__dir__}/ieee/pre_parser"
22
23
  autoload :Compaction, "#{__dir__}/ieee/compaction"
23
24
  autoload :ProjectRenderer, "#{__dir__}/ieee/project_renderer"
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Iso
5
+ # The pubid-scheme URN of ISO (issue #656; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # ISO/IEC 13818-1:2015/Amd 3:2016
8
+ # urn:pubid:iso:is:13818:co-IEC:part-1:year-2015:amd:3:co-IEC:year-2016
9
+ #
10
+ # The type tokens follow the RFC 5141 type codes where one exists. The
11
+ # core is the document number; every other value is an optional prefixed
12
+ # atom, in the order below. The official urn:iso:std: form stays on
13
+ # #to_urn (Pubid::Iso::UrnGenerator).
14
+ PubidUrnSchema = Pubid::PubidUrn.define("iso") do
15
+ atom "publisher", "pub"
16
+ atom "copublishers", "co", kind: :list
17
+ atom "part", "part"
18
+ atom "subpart", "subpart"
19
+ atom "year", "year"
20
+ atom "month", "month"
21
+ atom "day", "day"
22
+ atom "undated", "undated", kind: :bool
23
+ atom "edition.number", "ed"
24
+ atom "stage", "stage"
25
+ atom "stage_iteration", "iter"
26
+ atom "supplement_version", "v"
27
+ atom "languages.*.code", "lang"
28
+ atom "locality.value", "loc"
29
+
30
+ facet "languages.*.original_code", "langsrc"
31
+ facet "edition.original_text", "edsrc"
32
+
33
+ type "pubid:iso:international-standard", "is"
34
+ type "pubid:iso:technical-report", "tr"
35
+ type "pubid:iso:technical-specification", "ts"
36
+ type "pubid:iso:guide", "guide"
37
+ type "pubid:iso:pas", "pas"
38
+ type "pubid:iso:recommendation", "r"
39
+ type "pubid:iso:international-standardized-profile", "isp"
40
+ type "pubid:iso:international-workshop-agreement", "iwa"
41
+ type "pubid:iso:technology-trends-assessments", "tta"
42
+ type "pubid:iso:data", "data"
43
+ type "pubid:iso:tc-document", "tcdoc",
44
+ atoms: [%w[tc_type tctype], %w[tc_number tc],
45
+ %w[sc_type sctype], %w[sc_number sc],
46
+ %w[wg_type wgtype], %w[wg_number wg]]
47
+ type "pubid:iso:directives", "dir", atoms: [%w[subgroup subgroup]]
48
+ type "pubid:iso:directives-supplement", "dirsup"
49
+
50
+ type "pubid:iso:amendment", "amd"
51
+ type "pubid:iso:corrigendum", "cor"
52
+ type "pubid:iso:addendum", "add"
53
+ type "pubid:iso:extract", "ext"
54
+ type "pubid:iso:supplement", "sup"
55
+
56
+ type "pubid:iso:all-parts", "all", atoms: [["identifiers", "ids", :ids]]
57
+ type "pubid:iso:bundled-identifier", "bundle",
58
+ atoms: [["supplements", "sups", :ids]]
59
+ end
60
+ end
61
+ end
data/lib/pubid/iso.rb CHANGED
@@ -20,6 +20,7 @@ module Pubid
20
20
  autoload :Identifiers, "#{__dir__}/iso/identifiers"
21
21
  autoload :Normalizer, "#{__dir__}/iso/normalizer"
22
22
  autoload :Parser, "#{__dir__}/iso/parser"
23
+ autoload :PubidUrnSchema, "#{__dir__}/iso/pubid_urn_schema"
23
24
  autoload :RenderingStyle, "#{__dir__}/iso/rendering_style"
24
25
  autoload :SingleIdentifier, "#{__dir__}/iso/single_identifier"
25
26
  autoload :SupplementIdentifier, "#{__dir__}/iso/supplement_identifier"
@@ -113,3 +113,18 @@ a replay of all 24,382 rows and every ITU pass fixture showed 0 changes.
113
113
  **Not done:** an RR supplement (`ITU-R RR (2020) Amd 1` fails; the
114
114
  base-less `ITU-R RR Amd 1` still builds an Amendment on series `RR`), and
115
115
  `ITU-R RR-E` is still a Recommendation numbered `E` — both as on `main`.
116
+
117
+ ## pubid-scheme URN (issue #656)
118
+
119
+ `lib/pubid/itu/pubid_urn_schema.rb` covers all 17 types; design and rulings
120
+ in `docs/URN-SCHEMES.adoc` (`[[urn-itu]]`). **A new rendering flag needs a
121
+ place in that schema, or `#to_pubid_urn` raises for every id that sets it.**
122
+ Declare it as a `:bool` *facet* when it is spelling only (the
123
+ `number_glued`/`series_suffix_spaced` kind — "the same document") and as a
124
+ `:bool` *atom* when it names a different document (`technical`,
125
+ `attachment`, `series_word`). The facet/atom choice is what decides whether
126
+ a slug without its `f` group keeps two ids apart. Not placed today:
127
+ `combined.*.parts` (a list inside a list; no pass fixture has one).
128
+ `imp_marker` (`G.Imp712`) and `common_text_twin` (`| ISO/IEC …`, an `:id`
129
+ atom) are in no pass fixture either; the contract spec reads only `pass/`,
130
+ so sweep `full/` and the spec literals as well after a schema change.