pubid 2.0.58 → 2.0.60
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/README.adoc +6 -0
- data/data/parg/ieee.json +1 -1
- data/lib/pubid/bsi/CLAUDE.md +2 -0
- data/lib/pubid/bsi/identifiers/consolidated_identifier.rb +3 -0
- data/lib/pubid/bsi/pubid_urn_schema.rb +3 -0
- data/lib/pubid/bsi/urn.adoc +1 -1
- data/lib/pubid/bsi_pfs/identifiers/consolidated_identifier.rb +4 -0
- data/lib/pubid/bsi_pfs/pubid_urn_schema.rb +3 -0
- data/lib/pubid/bsi_pfs/urn.adoc +4 -1
- data/lib/pubid/builder/base.rb +5 -0
- data/lib/pubid/cen_cenelec/CLAUDE.md +2 -0
- data/lib/pubid/cen_cenelec/identifiers/consolidated_identifier.rb +4 -0
- data/lib/pubid/cen_cenelec/pubid_urn_schema.rb +3 -0
- data/lib/pubid/cen_cenelec/urn.adoc +1 -1
- data/lib/pubid/cen_pfs/identifiers/consolidated_identifier.rb +4 -0
- data/lib/pubid/cen_pfs/pubid_urn_schema.rb +3 -0
- data/lib/pubid/cen_pfs/urn.adoc +4 -1
- data/lib/pubid/components/relation.rb +290 -0
- data/lib/pubid/components.rb +1 -0
- data/lib/pubid/errors.rb +12 -1
- data/lib/pubid/identifier.rb +66 -0
- data/lib/pubid/iec/CLAUDE.md +2 -0
- data/lib/pubid/iec/identifier.rb +3 -0
- data/lib/pubid/iec/identifiers/consolidated_identifier.rb +4 -0
- data/lib/pubid/iec/pubid_urn_schema.rb +3 -0
- data/lib/pubid/iec/urn.adoc +3 -1
- data/lib/pubid/ieee/CLAUDE.md +6 -0
- data/lib/pubid/ieee/builder.rb +83 -7
- data/lib/pubid/ieee/identifiers/adopted_standard.rb +9 -0
- data/lib/pubid/ieee/identifiers/base.rb +6 -0
- data/lib/pubid/ieee/identifiers/corrigendum.rb +5 -1
- data/lib/pubid/ieee/identifiers/dual_published.rb +9 -0
- data/lib/pubid/ieee/identifiers/joint_development.rb +12 -0
- data/lib/pubid/ieee/parser.rb +6 -2
- data/lib/pubid/ieee/pubid_urn_schema.rb +4 -0
- data/lib/pubid/ieee/renderer.rb +2 -0
- data/lib/pubid/ieee/urn.adoc +6 -1
- data/lib/pubid/iso/CLAUDE.md +2 -0
- data/lib/pubid/iso/identifier.rb +3 -0
- data/lib/pubid/iso/identifiers/amendment.rb +12 -0
- data/lib/pubid/iso/pubid_urn_schema.rb +2 -0
- data/lib/pubid/iso/urn.adoc +6 -2
- data/lib/pubid/pubid_urn/decoder.rb +46 -0
- data/lib/pubid/pubid_urn/encoder.rb +43 -0
- data/lib/pubid/pubid_urn/schema.rb +4 -2
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid.rb +245 -3
- metadata +3 -2
data/lib/pubid/ieee/CLAUDE.md
CHANGED
|
@@ -101,3 +101,9 @@ The lesson BSI paid for: a wrapper's hand-written `#number` delegation makes the
|
|
|
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
102
|
|
|
103
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`.
|
|
104
|
+
|
|
105
|
+
- **A dotted draft with a relaton dash date rendered its tail twice (relaton/relaton-data-ieee#10).** `IEEE P1547/D-6.7.2-2017-05` rendered `IEEE P1547/D6.7.2-2017-05.7.2`, and relaton stored that string as the primary docidentifier, which pubid then could not parse — 20 documents missing from the index. The bound tree carries one draft element per version segment (`"-6"`, `".7.2"`) plus the date element. `Builder#build_single_identifier` writes the joined version plus `-YYYY[-MM]` onto the first element (`host`); it left `".7.2"` on the second, so the version was joined a second time. Three branches embed a date this way — the dash month, the dash year beside a base year (`IEEE Std 1547-2011/D-6.7.2-2017`), and the numeric month (`IEEE P1547/D-6.7.2, 05 2017`, which also used only the host's own `"-6"` and rendered `D6-2017-05.7.2`). All three now take `joined_draft_version(drafts)` and call `drop_joined_draft_segments`, which deletes `:draft_version` from every other element. The IEEE pass fixtures hold no such input (0 `to_s`/`to_hash` changes over 9,105 inputs). The release coupling this fix had (the canonical `IEEE P1547/D6.7.2-2017-05` re-parsed draft-less) is closed by the grammar captures below. The crawler-junk rows of the issue stay with relaton (hand-off `relaton__relaton__ieee-issue10-renderer-junk`).
|
|
106
|
+
|
|
107
|
+
- **The relaton-data-ieee#10 grammar captures (pubid-grammar `f7b2842`, artifact checksum `sha256:c4fa66bd…fa11`).** Three captures, three different amounts of gem work. **(1) Dotted-triple draft** — `draft_version_composite` now holds `"6.7.2"`; no builder change. 23 IEEE corpus drafts that rendered with the draft dropped (`IEEE P1547/D6.7.2, May 2017` → `IEEE P1547`) or cut to one segment (`IEEE Unapproved P754/D1`) now keep it. Two of the 23 were pinned lossy by specs: `catalogue_alias_spec.rb`'s "fabricated D1 for a date-only Draft Std" really was a triple draft the grammar had dropped. **(2) Corrigendum month `cor_month`** — the grammar captures it in the nested `corrigendum:` hash and at top level for `corrigendum_identifier`; the builder reads it at all three corrigendum sites plus `rename_supplement_keys`, onto the `month` that `Corrigendum` already inherits (so `exclude(:year)`, the pubid URN atom `month` and the official URN's `month_day_component` needed no change). The renderer prints `-MM` after the corrigendum year, and `mr_supplement_suffix` writes `cor.1.2019-05` so two monthly corrigenda do not share a slug. Before, `IEEE Std 802.3-2018/Cor 1-2019-05` parsed and silently dropped `05`. **(3) Bare-IEEE colon year** — the grammar rule `ieee_colon_year_identifier` was unreachable: `Parser.normalize_input`'s "add missing Std" rewrite turned `IEEE 8802-1AE:2013` into `IEEE Std 8802-1AE:2013`, which the grammar rejects by design. The rewrite now skips a number followed by `:YYYY`. The rendered face is the canonical dash form, `IEEE Std 8802-1AE-2013/Amd 1-2015` (a ruling: no spelling flag, same as `IEEE Std 24748-3:2012` → `-2012`). A colon year with a corrigendum (`IEEE 8802-1AE:2013/Cor 1-2014`) still fails. Locked by `dotted_draft_dash_date_spec.rb`, `corrigendum_month_spec.rb`, `colon_year_spec.rb`.
|
|
108
|
+
|
|
109
|
+
- **The document graph (issue #806)**: the parsed relationship faces become typed edges on the additive `relations` wire key — `Components::Relation` (type + targets + the face's `intermediate_amendments`/`approved_amendments_flag`), derived once at the construction tail (`Identifier#derive_relations!`; IEEE's hand-rolled `initialize` calls it after its assignment loop). Face types: `supersedes`/`revision_of`/`amendment_to` map to the canonical verbs `supersedes`/`revises`/`amends`; every other attested type (reaffirmation_of, redesignation_of, the draft variants) rides verbatim. Two repairs the edges forced: **(1)** the "and its approved amendments" / "including all approved amendments" tail of a face used to degrade into a junk parenthetical target (`IEEE Std (its approved amendments)`) — `Builder#parse_related_identifiers` now cuts the tail into the `approved_amendments_flag` the Relationship already modeled (`to_s` and `to_hash` are unchanged: the narrative was never rendered and only `relationship_type` serialized); **(2)** the derivation filters two kinds of target that cannot sit on the wire — the degraded parenthetical stand-ins of comma-list faces, and targets whose shape lutaml's collection cast resolves onto another class — so the edge states only restorable documents and the face keeps everything on `relationships`, exactly as before. Equality skips `relations` (`equality_ignored`), so a parsed face and a stored row that keeps only the face type stay one document to a search; the URN carries the edges as the `edges-` atom (`:edges` kind — `edges-<type>-(<targets>)[-(<intermediates>)][-approved]`, bracket-nested one level deeper than the other nested atoms).
|
data/lib/pubid/ieee/builder.rb
CHANGED
|
@@ -377,7 +377,9 @@ module Pubid
|
|
|
377
377
|
if m.to_s.match?(/\A\d{1,2}\z/) && y
|
|
378
378
|
host = drafts.find { |d| d.is_a?(Hash) && d[:draft_version] }
|
|
379
379
|
if host
|
|
380
|
-
host[:draft_version] =
|
|
380
|
+
host[:draft_version] =
|
|
381
|
+
[joined_draft_version(drafts), y, m].compact.join("-")
|
|
382
|
+
drop_joined_draft_segments(drafts, host)
|
|
381
383
|
parsed_hash.delete(:month)
|
|
382
384
|
parsed_hash.delete(:year)
|
|
383
385
|
parsed_hash.delete(:trailing_month)
|
|
@@ -390,8 +392,7 @@ module Pubid
|
|
|
390
392
|
# is the base's year, the 2015-07 the draft's); only the
|
|
391
393
|
# root-year assignment waits for an unoccupied year slot.
|
|
392
394
|
if dash
|
|
393
|
-
joined = drafts
|
|
394
|
-
.map { |v| v.is_a?(Hash) ? v[:value] : v.to_s }.join
|
|
395
|
+
joined = joined_draft_version(drafts)
|
|
395
396
|
# dash is either the top-level spine (dash_year/dash_month) or the
|
|
396
397
|
# draft's own hash (draft_date_dash_year/month on the edition-2
|
|
397
398
|
# grammar, dash_year/month on v1) — read both spellings.
|
|
@@ -411,6 +412,7 @@ module Pubid
|
|
|
411
412
|
# normalizes onto it (pubid ruling 2026-10-13).
|
|
412
413
|
host[:draft_version] =
|
|
413
414
|
[joined, dash_y, dash_m].compact.join("-")
|
|
415
|
+
drop_joined_draft_segments(drafts, host)
|
|
414
416
|
dash.delete(:dash_year)
|
|
415
417
|
dash.delete(:dash_month)
|
|
416
418
|
dash.delete(:draft_date_dash_year)
|
|
@@ -430,6 +432,7 @@ module Pubid
|
|
|
430
432
|
# "D2, 04 2015" comma spelling normalizes onto it.
|
|
431
433
|
host[:draft_version] =
|
|
432
434
|
[joined, dash_y, dash_m].compact.join("-")
|
|
435
|
+
drop_joined_draft_segments(drafts, host)
|
|
433
436
|
dash.delete(:dash_year)
|
|
434
437
|
dash.delete(:dash_month)
|
|
435
438
|
dash.delete(:draft_date_dash_year)
|
|
@@ -571,6 +574,8 @@ module Pubid
|
|
|
571
574
|
year = attributes.delete(:cor_year) || attributes.delete(:amd_year) ||
|
|
572
575
|
attributes.delete(:conf_year) || attributes.delete(:int_year)
|
|
573
576
|
attributes[:year] = year if year
|
|
577
|
+
month = attributes.delete(:cor_month)
|
|
578
|
+
attributes[:month] = month if month
|
|
574
579
|
end
|
|
575
580
|
|
|
576
581
|
# Reconstruct the base identifier string from a parsed `:base` subtree
|
|
@@ -663,12 +668,16 @@ module Pubid
|
|
|
663
668
|
# identifier stores them as the uniform `number`/`year`).
|
|
664
669
|
cor_number = extract_value(parsed_hash[:cor_number])
|
|
665
670
|
cor_year = extract_value(parsed_hash[:cor_year])
|
|
671
|
+
# The numeric month after the corrigendum year ("…/Cor 1-2019-05").
|
|
672
|
+
cor_month = parsed_hash[:cor_month] &&
|
|
673
|
+
extract_value(parsed_hash[:cor_month])
|
|
666
674
|
|
|
667
675
|
# Create Corrigendum with parsed base
|
|
668
676
|
Identifiers::Corrigendum.new(
|
|
669
677
|
base: base,
|
|
670
678
|
number: cor_number,
|
|
671
679
|
year: cor_year,
|
|
680
|
+
month: cor_month,
|
|
672
681
|
)
|
|
673
682
|
end
|
|
674
683
|
|
|
@@ -683,6 +692,7 @@ module Pubid
|
|
|
683
692
|
cor_data = parsed_hash[:corrigendum]
|
|
684
693
|
cor_number = extract_value(cor_data[:cor_number])
|
|
685
694
|
cor_year = extract_value(cor_data[:cor_year]) if cor_data[:cor_year]
|
|
695
|
+
cor_month = extract_value(cor_data[:cor_month]) if cor_data[:cor_month]
|
|
686
696
|
|
|
687
697
|
base_hash = parsed_hash.reject { |key, _| key == :corrigendum }
|
|
688
698
|
base = build_single_identifier(base_hash)
|
|
@@ -691,6 +701,7 @@ module Pubid
|
|
|
691
701
|
base: base,
|
|
692
702
|
number: cor_number,
|
|
693
703
|
year: cor_year,
|
|
704
|
+
month: cor_month,
|
|
694
705
|
)
|
|
695
706
|
end
|
|
696
707
|
|
|
@@ -1628,6 +1639,27 @@ module Pubid
|
|
|
1628
1639
|
end
|
|
1629
1640
|
end
|
|
1630
1641
|
|
|
1642
|
+
# The draft version spread over the segment elements, joined back.
|
|
1643
|
+
# @param drafts [Array] the draft elements of the parse tree
|
|
1644
|
+
# @return [String]
|
|
1645
|
+
def joined_draft_version(drafts)
|
|
1646
|
+
drafts.filter_map { |d| d.is_a?(Hash) ? d[:draft_version] : nil }
|
|
1647
|
+
.map { |v| v.is_a?(Hash) ? v[:value] : v.to_s }.join
|
|
1648
|
+
end
|
|
1649
|
+
|
|
1650
|
+
# The grammar splits a dotted draft version into one element per
|
|
1651
|
+
# segment ("/D-6.7.2" -> "-6", ".7.2"). Once the host element holds the
|
|
1652
|
+
# joined version with its embedded dash date, the other segments are
|
|
1653
|
+
# already in it; left in place they are joined a second time and the
|
|
1654
|
+
# version reads "6.7.2-2017-05.7.2" (relaton/relaton-data-ieee#10).
|
|
1655
|
+
# @param drafts [Array] the draft elements of the parse tree
|
|
1656
|
+
# @param host [Hash] the element that now holds the joined version
|
|
1657
|
+
def drop_joined_draft_segments(drafts, host)
|
|
1658
|
+
drafts.each do |d|
|
|
1659
|
+
d.delete(:draft_version) if d.is_a?(Hash) && !d.equal?(host)
|
|
1660
|
+
end
|
|
1661
|
+
end
|
|
1662
|
+
|
|
1631
1663
|
# Extract and normalize attributes from parsed data
|
|
1632
1664
|
# @param parsed [Hash] the parsed data
|
|
1633
1665
|
# @return [Hash] normalized attributes for identifier
|
|
@@ -2228,6 +2260,9 @@ extract_optional(parsed, attributes, :rev_sep) unless attributes[:revision] =~ /
|
|
|
2228
2260
|
attributes[:cor_year] =
|
|
2229
2261
|
extract_value(cor_data[:cor_year])
|
|
2230
2262
|
end
|
|
2263
|
+
if cor_data[:cor_month]
|
|
2264
|
+
attributes[:cor_month] = extract_value(cor_data[:cor_month])
|
|
2265
|
+
end
|
|
2231
2266
|
elsif parsed[:corrigendum]
|
|
2232
2267
|
attributes[:corrigendum] = extract_value(parsed[:corrigendum])
|
|
2233
2268
|
end
|
|
@@ -2351,11 +2386,13 @@ extract_optional(parsed, attributes, :rev_sep) unless attributes[:revision] =~ /
|
|
|
2351
2386
|
# Main relationship
|
|
2352
2387
|
if parsed_hash[:relationship_type]
|
|
2353
2388
|
rel_type = extract_relationship_type(parsed_hash[:relationship_type])
|
|
2354
|
-
related =
|
|
2389
|
+
related, tail_flag = parse_related_identifiers(
|
|
2390
|
+
parsed_hash[:related_ids],
|
|
2391
|
+
)
|
|
2355
2392
|
|
|
2356
2393
|
# Handle "as amended by" clause
|
|
2357
2394
|
amendments = nil
|
|
2358
|
-
approved_flag =
|
|
2395
|
+
approved_flag = tail_flag
|
|
2359
2396
|
|
|
2360
2397
|
if parsed_hash[:amendments]
|
|
2361
2398
|
# Check if it's the "and its approved amendments" flag
|
|
@@ -2381,11 +2418,13 @@ extract_optional(parsed, attributes, :rev_sep) unless attributes[:revision] =~ /
|
|
|
2381
2418
|
|
|
2382
2419
|
additional.each do |rel_data|
|
|
2383
2420
|
rel_type = extract_relationship_type(rel_data[:relationship_type])
|
|
2384
|
-
related =
|
|
2421
|
+
related, tail_flag = parse_related_identifiers(
|
|
2422
|
+
rel_data[:related_ids],
|
|
2423
|
+
)
|
|
2385
2424
|
|
|
2386
2425
|
# Handle "as amended by" clause for additional relationships
|
|
2387
2426
|
amendments = nil
|
|
2388
|
-
approved_flag =
|
|
2427
|
+
approved_flag = tail_flag
|
|
2389
2428
|
|
|
2390
2429
|
if rel_data[:amendments]
|
|
2391
2430
|
if rel_data[:amendments].is_a?(Hash) && rel_data[:amendments][:approved_amendments]
|
|
@@ -2420,6 +2459,43 @@ extract_optional(parsed, attributes, :rev_sep) unless attributes[:revision] =~ /
|
|
|
2420
2459
|
# Parse a list of identifier strings into identifier objects
|
|
2421
2460
|
# @param list_data [Hash, Array, nil] the parsed identifier list data
|
|
2422
2461
|
# @return [Array<Identifier>] array of parsed identifier objects
|
|
2462
|
+
# The approved-amendments tail of a relationship face — "Amendment to
|
|
2463
|
+
# IEEE Std 802.3-2018 and its approved amendments", "Revision of
|
|
2464
|
+
# IEEE Std 802.3-2002 including all approved amendments". The grammar
|
|
2465
|
+
# hands the clause back inside the related-ids list, where it cannot
|
|
2466
|
+
# parse as an identifier and used to degrade into a junk target
|
|
2467
|
+
# ("IEEE Std (its approved amendments)"). Cut it from the id text and
|
|
2468
|
+
# set the flag {Components::Relationship} already models instead.
|
|
2469
|
+
APPROVED_AMENDMENTS_TAIL =
|
|
2470
|
+
/\A\s*(?<id>.*?)\s*(?:and\s+its|including\s+all|its)\s+
|
|
2471
|
+
approved\s+amendments\s*\z/x.freeze
|
|
2472
|
+
|
|
2473
|
+
# @return [Array(Array<Identifier>, Boolean)] the parsed targets and
|
|
2474
|
+
# whether the list carried the approved-amendments tail
|
|
2475
|
+
def parse_related_identifiers(list_data)
|
|
2476
|
+
approved_flag = false
|
|
2477
|
+
targets = extract_identifier_strings(list_data).filter_map do |id_str|
|
|
2478
|
+
match = APPROVED_AMENDMENTS_TAIL.match(id_str)
|
|
2479
|
+
if match
|
|
2480
|
+
approved_flag = true
|
|
2481
|
+
id = match[:id]
|
|
2482
|
+
id = nil if id.nil? || id.strip.empty?
|
|
2483
|
+
else
|
|
2484
|
+
id = id_str
|
|
2485
|
+
end
|
|
2486
|
+
next unless id
|
|
2487
|
+
|
|
2488
|
+
begin
|
|
2489
|
+
Identifier.parse(id)
|
|
2490
|
+
rescue Pubid::Errors::ParseError
|
|
2491
|
+
# If parsing fails, create minimal identifier with just the
|
|
2492
|
+
# string. This maintains graceful degradation.
|
|
2493
|
+
Identifier.new(parenthetical_content: id)
|
|
2494
|
+
end
|
|
2495
|
+
end
|
|
2496
|
+
[targets, approved_flag]
|
|
2497
|
+
end
|
|
2498
|
+
|
|
2423
2499
|
def parse_identifier_list(list_data)
|
|
2424
2500
|
return [] unless list_data
|
|
2425
2501
|
|
|
@@ -75,6 +75,15 @@ module Pubid
|
|
|
75
75
|
hash.delete("publisher") if hash.is_a?(::Hash)
|
|
76
76
|
hash
|
|
77
77
|
end
|
|
78
|
+
|
|
79
|
+
# Nested-safe twin of the delete above (issue #806): lutaml
|
|
80
|
+
# serializes an identifier inside another one's collection — a
|
|
81
|
+
# relations edge target — through its own transform, which
|
|
82
|
+
# bypasses the to_hash override. The canonicalizer's class hook is
|
|
83
|
+
# called for nested models too.
|
|
84
|
+
def self.compact_hash(_model, hash)
|
|
85
|
+
hash.delete("publisher") if hash.is_a?(::Hash)
|
|
86
|
+
end
|
|
78
87
|
end
|
|
79
88
|
end
|
|
80
89
|
end
|
|
@@ -154,8 +154,14 @@ module Pubid
|
|
|
154
154
|
elsif extra.include?(key) && respond_to?(setter)
|
|
155
155
|
public_send(setter, value)
|
|
156
156
|
end
|
|
157
|
+
|
|
157
158
|
end
|
|
158
159
|
|
|
160
|
+
# The construction tail (issue #806): derive the graph edges from
|
|
161
|
+
# the faces this loop just assigned — the relationships carry their
|
|
162
|
+
# parsed targets as runtime state (`related_identifiers`), which is
|
|
163
|
+
# what the derivation reads.
|
|
164
|
+
derive_relations!
|
|
159
165
|
end
|
|
160
166
|
|
|
161
167
|
# Override accessors to return component objects.
|
|
@@ -31,7 +31,11 @@ module Pubid
|
|
|
31
31
|
def mr_supplement_suffix
|
|
32
32
|
segments = ["cor"]
|
|
33
33
|
segments << number.to_s if number
|
|
34
|
-
|
|
34
|
+
if year
|
|
35
|
+
# The month rides the year ("cor.1.2019-05"), so two monthly
|
|
36
|
+
# corrigenda of one year do not share a slug.
|
|
37
|
+
segments << (month ? "#{year}-#{month}" : year.to_s)
|
|
38
|
+
end
|
|
35
39
|
segments.join(".")
|
|
36
40
|
end
|
|
37
41
|
end
|
|
@@ -43,6 +43,15 @@ module Pubid
|
|
|
43
43
|
hash
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
# The same delete, nested-safe (issue #806): lutaml serializes an
|
|
47
|
+
# identifier inside another one's collection — a relations edge
|
|
48
|
+
# target — through its own transform, which bypasses the to_hash
|
|
49
|
+
# override above. The canonicalizer's class hook is called for
|
|
50
|
+
# nested models too, so the derived key drops on every path.
|
|
51
|
+
def self.compact_hash(_model, hash)
|
|
52
|
+
hash.delete("publisher") if hash.is_a?(::Hash)
|
|
53
|
+
end
|
|
54
|
+
|
|
46
55
|
# A dual-published document is one document under two designations, and
|
|
47
56
|
# this wrapper carries neither number itself — so `root.number`, the key
|
|
48
57
|
# relaton-index sorts and bsearches on, was "". Walk to the first
|
|
@@ -310,6 +310,18 @@ module Pubid
|
|
|
310
310
|
end
|
|
311
311
|
hash
|
|
312
312
|
end
|
|
313
|
+
|
|
314
|
+
# Nested-safe twin of the deletes above (issue #806): lutaml
|
|
315
|
+
# serializes an identifier inside another one's collection — a
|
|
316
|
+
# relations edge target — through its own transform, which
|
|
317
|
+
# bypasses the to_hash override. The canonicalizer's class hook is
|
|
318
|
+
# called for nested models too.
|
|
319
|
+
def self.compact_hash(_model, hash)
|
|
320
|
+
return unless hash.is_a?(::Hash)
|
|
321
|
+
|
|
322
|
+
hash.delete("publisher")
|
|
323
|
+
hash.delete("copublisher")
|
|
324
|
+
end
|
|
313
325
|
end
|
|
314
326
|
end
|
|
315
327
|
end
|
data/lib/pubid/ieee/parser.rb
CHANGED
|
@@ -263,8 +263,12 @@ module Pubid
|
|
|
263
263
|
cleaned = cleaned.gsub(/\s+-\s+(\d{4})\b/, '-\1')
|
|
264
264
|
|
|
265
265
|
# 3. Add missing "Std" after IEEE: "IEEE 1070-1995" → "IEEE Std 1070-1995"
|
|
266
|
-
# Only at start of string, IEEE + space + digit
|
|
267
|
-
|
|
266
|
+
# Only at start of string, IEEE + space + digit.
|
|
267
|
+
# Not before an ISO-style colon year ("IEEE 8802-1AE:2013/Amd.1-2015"):
|
|
268
|
+
# the grammar's ieee_colon_year_identifier reads only the bare IEEE
|
|
269
|
+
# publisher, and "IEEE Std …:YYYY" stays a grammar negative.
|
|
270
|
+
cleaned = cleaned.gsub(/^IEEE\s+(?!Std\b)(?![\dA-Za-z.-]+:\d{4}\b)(\d)/,
|
|
271
|
+
'IEEE Std \1')
|
|
268
272
|
|
|
269
273
|
# 3.5. Convert "IEEE No." to "IEEE Std": "IEEE No. 264-1968" → "IEEE Std 264-1968"
|
|
270
274
|
# NOTE: Do NOT convert AIEE No - AIEE uses "No" as standard format
|
|
@@ -87,6 +87,10 @@ module Pubid
|
|
|
87
87
|
atom "note", "note"
|
|
88
88
|
atom "parenthetical_content", "paren"
|
|
89
89
|
atom "relationships.*.relationship_type", "rel"
|
|
90
|
+
# The document graph (issue #806): the typed edges — supersedes,
|
|
91
|
+
# revises, amends and the attested reaffirmation/redesignation faces
|
|
92
|
+
# — each carrying its parsed targets.
|
|
93
|
+
atom "relations", "edges", kind: :edges
|
|
90
94
|
# Identifiers an IEEE id nests.
|
|
91
95
|
atom "ieee_identifier", "ieeeid", kind: :id
|
|
92
96
|
atom "iec_identifier", "iecid", kind: :id
|
data/lib/pubid/ieee/renderer.rb
CHANGED
|
@@ -386,6 +386,8 @@ module Pubid
|
|
|
386
386
|
result += ". " if id.number # Add period and space for formal format
|
|
387
387
|
result += id.number if id.number
|
|
388
388
|
result += "-#{id.year}" if id.year
|
|
389
|
+
# The corrigendum's own numeric month ("…/Cor. 1-2019-05").
|
|
390
|
+
result += "-#{id.month}" if id.year && id.month
|
|
389
391
|
result
|
|
390
392
|
end
|
|
391
393
|
|
data/lib/pubid/ieee/urn.adoc
CHANGED
|
@@ -58,7 +58,12 @@ Core: `number` (the bare digits, the relaton index key: `C37.09` is `37` with
|
|
|
58
58
|
`draftstatus`, `ts*` for a `typed_stage` that does not collapse to `stage`),
|
|
59
59
|
`lang`, `loc`, the IEEE flags (`project`, `redline`, `interp`, …), the
|
|
60
60
|
free-text designations (`nick`, `note`, `paren`, `rel` …), then the nested
|
|
61
|
-
identifiers
|
|
61
|
+
identifiers, then `edges-` (`relations`, the document graph of
|
|
62
|
+
issue #806: one `edges-<type>-(<targets>)` segment per edge — the type
|
|
63
|
+
word is the canonical verb (`supersedes`, `amends`, `revises`) or the
|
|
64
|
+
attested face type (`reaffirmation_of`, `redesignation_of`, …) — with
|
|
65
|
+
the face clauses `-(<intermediate amendments>)` and `-approved`
|
|
66
|
+
appended in that order). Facets: `sep`, `seps`, `revsep`, `yearsep`, `datesep`,
|
|
62
67
|
`format`, `langsrc`.
|
|
63
68
|
|
|
64
69
|
----
|
data/lib/pubid/iso/CLAUDE.md
CHANGED
|
@@ -253,3 +253,5 @@
|
|
|
253
253
|
(`identifiers/full/iso-pubid-tc-documents.txt` →
|
|
254
254
|
`pass/tc_document.txt`, 7 faces) and the testsuite exports them as
|
|
255
255
|
`tests/iso/tc_document.yaml` rows.
|
|
256
|
+
|
|
257
|
+
- **The amendment states its `amends` edge (issue #806)**: `Identifiers::Amendment#derive_relations` turns the `base` attribute into a `Components::Relation` edge (`amends` → base) on the additive `relations` wire key — the ISO amendment reference made first-class. Corrigenda state no edge (no attested verb). The wire key needs the `map "relations"` in the top-class `key_value` block (ISO enumerates its maps), the `edges-` atom in the URN schema, and equality skips `relations`, so stored rows and parsed faces stay one document to a search.
|
data/lib/pubid/iso/identifier.rb
CHANGED
|
@@ -145,6 +145,9 @@ module Pubid
|
|
|
145
145
|
# unique typed-stage `code` under "stage" and recompute the rest on
|
|
146
146
|
# load. _type already pins the document type.
|
|
147
147
|
map "stage", with: { to: :stage_to_kv, from: :stage_from_kv }
|
|
148
|
+
# The document graph (issue #806): the amendment edge toward its
|
|
149
|
+
# base. Polymorphic nested identifiers, omitted when empty.
|
|
150
|
+
map "relations", to: :relations
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
# Serialize typed_stage as just its unique code (e.g. "is", "dis",
|
|
@@ -126,6 +126,18 @@ module Pubid
|
|
|
126
126
|
{ key: :amd,
|
|
127
127
|
web: :amendment, title: "Amendment", short: "AMD" }
|
|
128
128
|
end
|
|
129
|
+
|
|
130
|
+
# The document-graph edge (issue #806): the amendment's `base` IS
|
|
131
|
+
# the amendment reference, stated as an `amends` edge toward the
|
|
132
|
+
# document it amends. The corrigendum states none — issue #806's
|
|
133
|
+
# canonical verbs cover the amendment faces.
|
|
134
|
+
def derive_relations
|
|
135
|
+
return [] unless base
|
|
136
|
+
|
|
137
|
+
[::Pubid::Components::Relation.new(
|
|
138
|
+
type: ::Pubid::Components::Relation::AMENDS, targets: [base],
|
|
139
|
+
)]
|
|
140
|
+
end
|
|
129
141
|
end
|
|
130
142
|
end
|
|
131
143
|
end
|
|
@@ -26,6 +26,8 @@ module Pubid
|
|
|
26
26
|
atom "supplement_version", "v"
|
|
27
27
|
atom "languages.*.code", "lang"
|
|
28
28
|
atom "locality.value", "loc"
|
|
29
|
+
# The document graph (issue #806): the amendment edge toward its base.
|
|
30
|
+
atom "relations", "edges", kind: :edges
|
|
29
31
|
|
|
30
32
|
facet "languages.*.original_code", "langsrc"
|
|
31
33
|
facet "edition.original_text", "edsrc"
|
data/lib/pubid/iso/urn.adoc
CHANGED
|
@@ -43,7 +43,11 @@ path-safe, and give no collision.
|
|
|
43
43
|
Core: `number`. Atoms, canonical order: `pub-`, `co-` (list), `part-`,
|
|
44
44
|
`subpart-`, `year-`, `month-`, `day-`, `undated-` (bool), `ed-`
|
|
45
45
|
(`edition.number`), `stage-`, `iter-` (`stage_iteration`), `v-`
|
|
46
|
-
(`supplement_version`), `lang-` (`languages.*.code`, list), `loc
|
|
46
|
+
(`supplement_version`), `lang-` (`languages.*.code`, list), `loc-`,
|
|
47
|
+
`edges-` (`relations`, the document graph of issue #806: one
|
|
48
|
+
`edges-<type>-(<targets>)` segment per edge, with the face clauses
|
|
49
|
+
`-(<intermediate amendments>)` and `-approved` appended in that order;
|
|
50
|
+
an ISO amendment states `amends` toward its base);
|
|
47
51
|
`tcdoc` adds `tctype-`, `tc-`, `sctype-`, `sc-`, `wgtype-`, `wg-`; `dir`
|
|
48
52
|
adds `subgroup-`; `all` adds `ids-(…)`; `bundle` adds `sups-(…)`. Facets:
|
|
49
53
|
`langsrc` (`languages.*.original_code`), `edsrc` (`edition.original_text`).
|
|
@@ -53,6 +57,6 @@ ISO 9001 urn:pubid:iso:is:9001
|
|
|
53
57
|
ISO/IEC/IEEE 8802-3:2021 urn:pubid:iso:is:8802:co-IEC,IEEE:part-3:year-2021
|
|
54
58
|
ISO/DIS 9001 urn:pubid:iso:is:9001:stage-dis
|
|
55
59
|
ISO 9001:2015(E) urn:pubid:iso:is:9001:year-2015:lang-en:f:0.langsrc-E
|
|
56
|
-
ISO 9001:2015/Amd 1:2016/Cor 1:2017 urn:pubid:iso:is:9001:year-2015:amd:1:year-2016:cor:1:year-2017
|
|
60
|
+
ISO 9001:2015/Amd 1:2016/Cor 1:2017 urn:pubid:iso:is:9001:year-2015:amd:1:year-2016:edges-amends-((iso:is:9001:year-2015)):cor:1:year-2017
|
|
57
61
|
ISO 9001 (all parts) urn:pubid:iso:all:ids-(iso:is:9001)
|
|
58
62
|
----
|
|
@@ -102,10 +102,56 @@ module Pubid
|
|
|
102
102
|
when :int then integer(raw)
|
|
103
103
|
when :id then nested(raw)
|
|
104
104
|
when :ids then PubidUrn.split_top(raw, ",").map { |item| nested(item) }
|
|
105
|
+
when :edges then decode_edges(raw)
|
|
105
106
|
else slot_value(raw, atom)
|
|
106
107
|
end
|
|
107
108
|
end
|
|
108
109
|
|
|
110
|
+
# The document graph (issue #806): the inverse of
|
|
111
|
+
# Encoder#edge_list — one "<type>-(<targets>)[-<clauses>]" segment
|
|
112
|
+
# per edge, joined by a top-level comma.
|
|
113
|
+
def decode_edges(raw)
|
|
114
|
+
PubidUrn.split_top(raw, ",").map { |item| decode_edge(item) }
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def decode_edge(item)
|
|
118
|
+
parts = PubidUrn.split_top(item, "-")
|
|
119
|
+
type = parts.shift
|
|
120
|
+
unless /\A[a-z][a-z0-9_]*\z/.match?(type)
|
|
121
|
+
fail!("bad relation type #{type.inspect}")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
edge = { "type" => type,
|
|
125
|
+
"targets" => identifier_group(parts.shift) }
|
|
126
|
+
intermediates = []
|
|
127
|
+
until parts.empty?
|
|
128
|
+
part = parts.shift
|
|
129
|
+
if part == "approved"
|
|
130
|
+
edge["approved_amendments_flag"] = true
|
|
131
|
+
elsif part.start_with?("(")
|
|
132
|
+
intermediates.concat(identifier_group(part))
|
|
133
|
+
else
|
|
134
|
+
fail!("bad relation clause #{part.inspect}")
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
edge["intermediate_amendments"] = intermediates unless
|
|
138
|
+
intermediates.empty?
|
|
139
|
+
edge
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# One bracketed, comma-joined list of nested identifiers.
|
|
143
|
+
def identifier_group(raw)
|
|
144
|
+
nested_list(raw)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def nested_list(raw)
|
|
148
|
+
unless raw.is_a?(String) && raw.start_with?("(") && raw.end_with?(")")
|
|
149
|
+
fail!("nested identifier list #{raw.inspect} needs brackets")
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
PubidUrn.split_top(raw[1..-2], ",").map { |item| nested(item) }
|
|
153
|
+
end
|
|
154
|
+
|
|
109
155
|
# The value of a :string, :bool or list atom, or of a facet.
|
|
110
156
|
def slot_value(raw, slot)
|
|
111
157
|
return scalar(raw, slot) unless slot.list?
|
|
@@ -115,10 +115,53 @@ module Pubid
|
|
|
115
115
|
when :int then typed(value, Integer, atom, schema).to_s
|
|
116
116
|
when :id then nested(typed(value, Hash, atom, schema))
|
|
117
117
|
when :ids then nested_list(typed(value, Array, atom, schema))
|
|
118
|
+
when :edges then edge_list(typed(value, Array, atom, schema), atom,
|
|
119
|
+
schema)
|
|
118
120
|
else slot_value(value, atom, schema)
|
|
119
121
|
end
|
|
120
122
|
end
|
|
121
123
|
|
|
124
|
+
# The document graph (issue #806): one segment per edge, joined by a
|
|
125
|
+
# top-level comma. An edge is "<type>-(<targets>)" — the type word
|
|
126
|
+
# ("supersedes"), then the nested identifier list — extended in a
|
|
127
|
+
# fixed order by the optional face clauses an "as amended by …" face
|
|
128
|
+
# carries: "-(<intermediate amendments>)", then "-approved". "-"
|
|
129
|
+
# separates and not ":", because a top-level ":" would end the atom
|
|
130
|
+
# token; everything bracketed is paren-protected from the splitters.
|
|
131
|
+
# The relation type words never carry a "-" (Components::Relation
|
|
132
|
+
# validates that), so the type reads unambiguously before the first
|
|
133
|
+
# bracketed group.
|
|
134
|
+
def edge_list(edges, atom, schema)
|
|
135
|
+
edges.map do |edge|
|
|
136
|
+
edge_value(typed(edge, Hash, atom, schema), atom, schema)
|
|
137
|
+
end.join(",")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def edge_value(edge, atom, schema)
|
|
141
|
+
type = edge["type"]
|
|
142
|
+
unless type.is_a?(String) &&
|
|
143
|
+
::Pubid::Components::Relation::TYPE_NAME.match?(type)
|
|
144
|
+
raise Errors::InvalidInputError,
|
|
145
|
+
"#{schema.type} #{atom.path}: #{type.inspect} is not a " \
|
|
146
|
+
"relation type"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
targets = edge["targets"]
|
|
150
|
+
unless targets.is_a?(Array) && targets.any?
|
|
151
|
+
raise Errors::InvalidInputError,
|
|
152
|
+
"#{schema.type} #{atom.path}: the #{type} edge states no " \
|
|
153
|
+
"targets"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
parts = ["#{type}-(#{nested_list(targets)})"]
|
|
157
|
+
intermediates = edge["intermediate_amendments"]
|
|
158
|
+
if intermediates.is_a?(Array) && intermediates.any?
|
|
159
|
+
parts << "(#{nested_list(intermediates)})"
|
|
160
|
+
end
|
|
161
|
+
parts << "approved" if edge["approved_amendments_flag"]
|
|
162
|
+
parts.join("-")
|
|
163
|
+
end
|
|
164
|
+
|
|
122
165
|
# The value of a :string, :bool or list atom, or of a facet.
|
|
123
166
|
def slot_value(value, slot, schema)
|
|
124
167
|
return scalar(value, slot, schema) unless slot.list?
|
|
@@ -8,7 +8,9 @@ module Pubid
|
|
|
8
8
|
# +path+ is a dotted key path into the node's +to_hash+; "*" walks the
|
|
9
9
|
# elements of an Array ("languages.*.code"). +kind+ is one of
|
|
10
10
|
# :string, :list (of Strings), :bool, :bools (a list of booleans), :int,
|
|
11
|
-
# :id (a nested identifier hash)
|
|
11
|
+
# :id (a nested identifier hash), :ids (an Array of them) or :edges (the
|
|
12
|
+
# document graph of issue #806: an Array of
|
|
13
|
+
# {"type" =>, "targets" => [, …]} relation edges). A path with
|
|
12
14
|
# "*" is always a list: :list, or :bools when its elements are booleans.
|
|
13
15
|
Atom = Struct.new(:path, :prefix, :kind) do
|
|
14
16
|
def parts
|
|
@@ -86,7 +88,7 @@ module Pubid
|
|
|
86
88
|
# has the shape PubidUrn::STRUCTURE reads as structure.
|
|
87
89
|
class FlavorSchema
|
|
88
90
|
NAME = /\A[a-z][a-z0-9]*\z/
|
|
89
|
-
KINDS = %i[string list bool bools int id ids].freeze
|
|
91
|
+
KINDS = %i[string list bool bools int id ids edges].freeze
|
|
90
92
|
FACET_KINDS = %i[string list bool bools].freeze
|
|
91
93
|
CORE_KINDS = %i[string int].freeze
|
|
92
94
|
# "f" opens the facet group; "type" is the type-metadata URN
|
data/lib/pubid/version.rb
CHANGED