pubid 2.0.0.pre.alpha.40 → 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: c1e4c5a6889f61e535b4d05517aff5798eb5307c79bf7e318ab21822ebfe73ae
4
- data.tar.gz: f129c70c4c9c646318c58e12d7a5e1097299c5698a083a0710e2866a2e7ad692
3
+ metadata.gz: 9b4cbb25ba50fae05ff215becf19f4edfe4b4cdea3d470e0ae1d7447d9e50c9d
4
+ data.tar.gz: 859a16d7d83590fc3a0ada0d7b0e78d631b3b923d7c85fbdc08bf1f170c78b98
5
5
  SHA512:
6
- metadata.gz: d2e7e5cea5f0749a2aa5715521a2d6c192b43395bcb9f72470207629f6e7d1f0b9a7dbb089a1cc8e23c41a6ffc61a1e1424ce2546618249ed3eb074d611b3e4f
7
- data.tar.gz: c4ee9f3166fa9caffb6f3b85d4684c11b6f08ac615ecf302af94831a9e7538a29264c2a862ffefa161fbeb4dbabc11b82405730c2435d5d666ab42c257fe2a61
6
+ metadata.gz: 7e6c74d29a9cb81d4e3cf829bfb707ce236e8e5f41af17cd5e6ac79ffe2712e7914c50c610be2f4ccb57534dc5ad3c1d087d71bb985500833780e01adf57b7b5
7
+ data.tar.gz: 3ded5e29bd316cdc19e52e380cc987446c2173c4d428e90084406aa224862e9c66df4c673d86b3f975d8bb6e60dabbb289896d8116ff4d95fc24bc6a8b967d46
@@ -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.40"
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.40
4
+ version: 2.0.0.pre.alpha.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.