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 +4 -4
- data/lib/pubid/nist/CLAUDE.md +18 -0
- data/lib/pubid/nist/urn_parser.rb +36 -8
- data/lib/pubid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b4cbb25ba50fae05ff215becf19f4edfe4b4cdea3d470e0ae1d7447d9e50c9d
|
|
4
|
+
data.tar.gz: 859a16d7d83590fc3a0ada0d7b0e78d631b3b923d7c85fbdc08bf1f170c78b98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e6c74d29a9cb81d4e3cf829bfb707ce236e8e5f41af17cd5e6ac79ffe2712e7914c50c610be2f4ccb57534dc5ad3c1d087d71bb985500833780e01adf57b7b5
|
|
7
|
+
data.tar.gz: 3ded5e29bd316cdc19e52e380cc987446c2173c4d428e90084406aa224862e9c66df4c673d86b3f975d8bb6e60dabbb289896d8116ff4d95fc24bc6a8b967d46
|
data/lib/pubid/nist/CLAUDE.md
CHANGED
|
@@ -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,
|
|
43
|
+
code, suffix = parse_payload(payload)
|
|
44
44
|
|
|
45
45
|
text = "#{publisher_for(type_token)} #{type_label(type_token)} #{code}"
|
|
46
|
-
text +=
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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