pubid 2.0.0.pre.alpha.39 → 2.0.0.pre.alpha.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e53b03c87c2a04f877d8eba11d5689984de9c0af641258c68c8c03377d762f12
4
- data.tar.gz: 5bdad1686cf8cd3709ea1494eef8c78dd7c6974bae2802ccc669db939f788731
3
+ metadata.gz: 9b4cbb25ba50fae05ff215becf19f4edfe4b4cdea3d470e0ae1d7447d9e50c9d
4
+ data.tar.gz: 859a16d7d83590fc3a0ada0d7b0e78d631b3b923d7c85fbdc08bf1f170c78b98
5
5
  SHA512:
6
- metadata.gz: 822faa7030a35d1e87901785b0d22bb0716c1b997985c6b9d616c1eb75f3e7fe3436ca61c427c4d8abd44d14fe2e173b7a8c5ab3bc26941bb68e75f308862965
7
- data.tar.gz: e636567ecb22497f4cf0c0cafdfe68d06f83e593bc15483c168cbc25053a61221d6738ac16730f2bbe0e05c88ce6d91bb3166da7386ac1ca4004363fea390a5a
6
+ metadata.gz: 7e6c74d29a9cb81d4e3cf829bfb707ce236e8e5f41af17cd5e6ac79ffe2712e7914c50c610be2f4ccb57534dc5ad3c1d087d71bb985500833780e01adf57b7b5
7
+ data.tar.gz: 3ded5e29bd316cdc19e52e380cc987446c2173c4d428e90084406aa224862e9c66df4c673d86b3f975d8bb6e60dabbb289896d8116ff4d95fc24bc6a8b967d46
@@ -1762,6 +1762,7 @@ module Pubid
1762
1762
  end
1763
1763
 
1764
1764
  # Check for specific draft notation (D1, D2, etc.)
1765
+ draft_version_present = false
1765
1766
  if parsed[:draft]
1766
1767
  draft_data = parsed[:draft]
1767
1768
  if draft_data.is_a?(Array)
@@ -1769,8 +1770,12 @@ module Pubid
1769
1770
  r.merge(e)
1770
1771
  end
1771
1772
  end
1773
+ # A verbatim draft designator ("/D2.1.1") is a version in itself;
1774
+ # only an attribute-less date hash ("{month:, year:}") lacks one.
1775
+ draft_version_present = true unless draft_data.is_a?(Hash)
1772
1776
 
1773
1777
  if draft_data.is_a?(Hash) && draft_data[:draft_version]
1778
+ draft_version_present = true
1774
1779
  dv = draft_data[:draft_version]
1775
1780
  version = if dv.is_a?(Array)
1776
1781
  dv.map do |v|
@@ -1781,6 +1786,21 @@ module Pubid
1781
1786
  end
1782
1787
 
1783
1788
  if version
1789
+ # A draft version that IS an ISO stage token ("/DCD1" and
1790
+ # "/CD1" both capture version "CD1") takes that stage on a
1791
+ # PLAIN IEEE document: the stage token outranks the ordinal
1792
+ # ladder (docs/IEEE-DRAFT-STAGES.md §1.3, "DDIS" = DIS), so
1793
+ # the render drops the Draft word. A joint ISO-led
1794
+ # stage-word draft keeps its generic project stage — its
1795
+ # publishers block composes the same face through the
1796
+ # typed-stage project branch.
1797
+ copubs = parsed[:publishers].is_a?(Hash) ? parsed[:publishers][:copublishers] : nil
1798
+ joint = copubs && !(copubs.respond_to?(:empty?) ? copubs.empty? : copubs.nil?)
1799
+ if !joint &&
1800
+ (m = version.to_s.match(/\A(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)\d*\z/))
1801
+ return m[1]
1802
+ end
1803
+
1784
1804
  # relaton's hyphenated "/D-2" spelling captures the dash inside
1785
1805
  # draft_version; the stage registry keys on "D2". A date-embedded
1786
1806
  # version ("3-2017-07") keys on its leading ordinal.
@@ -1802,13 +1822,17 @@ module Pubid
1802
1822
  return "P"
1803
1823
  elsif type_value == "Std"
1804
1824
  return "Std"
1805
- elsif type_value == "Draft Std" && parsed[:draft].nil? && parsed[:digit_draft].nil?
1825
+ elsif type_value == "Draft Std" && !draft_version_present && parsed[:digit_draft].nil?
1806
1826
  # A version-less "Draft Std" fabricates /D1 (issue #205);
1807
1827
  # deriving the stage from that fabricated version renders the
1808
1828
  # same P-prefixed form as an explicit "/D1" spelling, so the
1809
1829
  # render reaches its fixed point in one round (pubid#318).
1810
- # Gated on no-draft: a dotted version ("D2.0") fails the registry
1811
- # lookup above and must fall through, keeping "Draft Std".
1830
+ # Gated on no captured VERSION: a dotted version ("D2.0")
1831
+ # fails the registry lookup above and must fall through,
1832
+ # keeping "Draft Std". A draft-version-less tree that carries
1833
+ # only a date ("IEEE Draft Std P754/D1.2.6 Nov 2006") takes
1834
+ # the same fabricated D1, the version the render already
1835
+ # implies.
1812
1836
  return "D1"
1813
1837
  elsif type_value.match?(/^No\.?$/)
1814
1838
  return type_value
@@ -54,3 +54,21 @@ Read this before you change `lib/pubid/nist/` or `spec/pubid/nist/`. The root
54
54
  `update`/`update_component` and cleared to `nil` before the object is
55
55
  returned. Neither carries live information `edition`/`update` doesn't
56
56
  already cover. Locked by `spec/pubid/all_parts_edition_keys_audit_spec.rb`.
57
+
58
+ - **The URN parser must rebuild the human face the generator started from,
59
+ field for field.** `UrnGenerator` dot-joins identity fields after the
60
+ number (`urn:nist:sp:304.e2017.A.supp`), and `UrnParser#parse_payload`
61
+ splits them back: the edition/volume/revision glue onto the number, a
62
+ single capital-letter token is a **part** glued to the code
63
+ (`304A`), an edition's additional text keeps its dot (`13e2.June1908` —
64
+ the token after `eN`), `insert`/`errata`/`add` markers glue verbatim,
65
+ the bare `.supp` is supplementability (non-identity) and a valued
66
+ `.supp-<v>` is `sup<v>`. The rebuild is only correct if the flavor's own
67
+ grammar accepts it, so every branch is measured against the corpus —
68
+ before this, the five rows with a part letter, an edition additional
69
+ text, or an addendum marker failed to re-parse and the reference's own
70
+ `parse_urn` raised on its own output. The ts mirror must reproduce
71
+ Ruby's `String#split` behaviour and drop **trailing** empty fields
72
+ (`"800-38.A.supp.add."` splits with a trailing `""` in JS but not in
73
+ Ruby; keeping it appends a stray `.`). Locked by
74
+ `spec/pubid/nist/urn_parser_spec.rb`.
@@ -40,10 +40,10 @@ module Pubid
40
40
  parts = split_parts(body)
41
41
 
42
42
  type_token, payload = parts
43
- code, revision = parse_payload(payload)
43
+ code, suffix = parse_payload(payload)
44
44
 
45
45
  text = "#{publisher_for(type_token)} #{type_label(type_token)} #{code}"
46
- text += revision if revision
46
+ text += suffix
47
47
  flavor_parse(text)
48
48
  end
49
49
 
@@ -58,14 +58,42 @@ module Pubid
58
58
  NBS_SERIES.include?(type_token.downcase) ? "NBS" : "NIST"
59
59
  end
60
60
 
61
+ # The generator dot-joins the identity's fields after the number
62
+ # ("urn:nist:circ:25.e1924.supp", "urn:nist:circ:539.v10.supp",
63
+ # "urn:nist:circ:24.supp-1"). Reassemble the human spelling the
64
+ # flavor parser reads: the edition and volume glue onto the number,
65
+ # a revision glues after them, the bare ".supp" marks
66
+ # supplementability (non-identity) and a valued ".supp-<v>" is the
67
+ # supplement's "sup<v>" face.
61
68
  def parse_payload(payload)
62
- # Strip the trailing ".supp" supplement marker.
63
- stripped = payload.sub(/\.supp\z/, "")
64
- # Split revision suffix from code (e.g., "800-53.r5" → ["800-53", "r5"]).
65
- match = stripped.match(/^(.*)\.(r\d+)$/i)
66
- return [stripped, nil] unless match
69
+ tokens = payload.split(".")
70
+ code = tokens.shift.to_s
71
+ suffix = +""
72
+ part = nil
73
+ edition = nil
74
+ volume = nil
75
+ revision = nil
76
+ supplement = nil
67
77
 
68
- [match[1], match[2]]
78
+ tokens.each do |token|
79
+ case token
80
+ when /\Ar\d+\z/i then revision = token
81
+ when /\Ae[\w]+\z/i then edition = token
82
+ when /\Av\d+\z/i then volume = token
83
+ when /\Asupp-(.+)\z/im then supplement = Regexp.last_match(1)
84
+ when "supp" then next # supplementability marker, not identity
85
+ when "insert", "errata" then suffix << token # glued in the human
86
+ when /\A[A-Z]\z/ then part = token # part letter, glued to the code
87
+ when /\A[A-Z][a-z]+\d{4}\z/ # edition's additional text ("13e2.June1908")
88
+ edition = "#{edition}.#{token}" if edition
89
+ else suffix << ".#{token}" # unknown marker: keep verbatim
90
+ end
91
+ end
92
+
93
+ code << part.to_s
94
+ suffix << edition.to_s << volume.to_s << revision.to_s
95
+ suffix << "sup#{supplement}" if supplement
96
+ [code, suffix]
69
97
  end
70
98
 
71
99
  def type_label(token)
data/lib/pubid/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pubid
4
- VERSION = "2.0.0.pre.alpha.39"
4
+ VERSION = "2.0.0.pre.alpha.41"
5
5
  end
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.0.pre.alpha.39
4
+ version: 2.0.0.pre.alpha.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.