pubid 2.0.47 → 2.0.49
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 +2 -2
- data/conformance/pending.yaml +0 -173
- data/data/parg/ansi.json +1 -1
- data/data/parg/wmo.json +1 -0
- data/data/parg/wmo.parg +108 -0
- data/lib/pubid/ansi/CLAUDE.md +26 -4
- data/lib/pubid/ansi/builder.rb +19 -9
- data/lib/pubid/ansi/identifier.rb +17 -0
- data/lib/pubid/ansi/pubid_urn_schema.rb +2 -0
- data/lib/pubid/ansi/renderer.rb +6 -4
- data/lib/pubid/ansi/urn_generator.rb +2 -0
- data/lib/pubid/version.rb +1 -1
- data/lib/pubid/wmo/CLAUDE.md +183 -0
- data/lib/pubid/wmo/builder.rb +71 -0
- data/lib/pubid/wmo/identifier.rb +167 -0
- data/lib/pubid/wmo/identifiers/annex.rb +43 -0
- data/lib/pubid/wmo/identifiers/publication.rb +17 -0
- data/lib/pubid/wmo/identifiers/standard.rb +18 -0
- data/lib/pubid/wmo/identifiers.rb +11 -0
- data/lib/pubid/wmo/parser.rb +32 -0
- data/lib/pubid/wmo/pubid_urn_schema.rb +42 -0
- data/lib/pubid/wmo/renderer.rb +63 -0
- data/lib/pubid/wmo/urn_generator.rb +96 -0
- data/lib/pubid/wmo/urn_parser.rb +159 -0
- data/lib/pubid/wmo.rb +112 -0
- data/lib/pubid.rb +1 -0
- metadata +17 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Wmo
|
|
5
|
+
# The pubid-scheme URN of wmo (pubid#763 widened;
|
|
6
|
+
# docs/URN-SCHEMES.adoc).
|
|
7
|
+
#
|
|
8
|
+
# WMO-No. 1364, 2025 edition -> urn:pubid:wmo:pub:1364:ed-2025
|
|
9
|
+
# WMO/TD-No. 196 -> urn:pubid:wmo:pub:196:series-TD
|
|
10
|
+
# WMO-No. 306, Volume I.1 -> urn:pubid:wmo:pub:306:vol-I.1
|
|
11
|
+
# WMO-No. 8, 2021/2018 edition
|
|
12
|
+
# -> urn:pubid:wmo:pub:8:ed-2021~2F2018
|
|
13
|
+
# WMO-No. 8, Provisional 2026 edition
|
|
14
|
+
# -> urn:pubid:wmo:pub:8:ed-2026:
|
|
15
|
+
# status-Provisional
|
|
16
|
+
# WMO-No. 1364, 2023 edition, updated in 2025
|
|
17
|
+
# -> urn:pubid:wmo:pub:1364:ed-2023:
|
|
18
|
+
# updated-2025
|
|
19
|
+
# S-411 1.2.1 -> urn:pubid:wmo:std:411:ed-1.2.1
|
|
20
|
+
# S-411 Annex A -> urn:pubid:wmo:std:411:annex:annexform-Annex:letter-A
|
|
21
|
+
#
|
|
22
|
+
# The edition is one atom: a calendar-year face (the year pair
|
|
23
|
+
# escaped `~2F` for its slash) on a publication, a dotted face on a
|
|
24
|
+
# standard or annex. The series, volume, status and updated-in
|
|
25
|
+
# faces are atoms of the widening; series is nil on the WMO-No.
|
|
26
|
+
# default, so existing URNs are unchanged. The annex marker and
|
|
27
|
+
# letter follow the iala schema (annexform- / letter-).
|
|
28
|
+
PubidUrnSchema = Pubid::PubidUrn.define("wmo") do
|
|
29
|
+
atom "series", "series"
|
|
30
|
+
atom "volume", "vol"
|
|
31
|
+
atom "edition", "ed"
|
|
32
|
+
atom "edition_status", "status"
|
|
33
|
+
atom "updated_in", "updated"
|
|
34
|
+
atom "annex_form", "annexform"
|
|
35
|
+
atom "letter", "letter"
|
|
36
|
+
|
|
37
|
+
type "pubid:wmo:publication", "pub"
|
|
38
|
+
type "pubid:wmo:standard", "std"
|
|
39
|
+
type "pubid:wmo:annex", "annex"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Wmo
|
|
5
|
+
# Human-readable renderer for WMO identifiers.
|
|
6
|
+
#
|
|
7
|
+
# Produces strings like:
|
|
8
|
+
# "WMO-No. 1364"
|
|
9
|
+
# "WMO-No. 1364, 2025 edition"
|
|
10
|
+
# "WMO-No. 8, Volume I"
|
|
11
|
+
# "WMO-No. 306, Volume I.1, 2020 edition"
|
|
12
|
+
# "WMO-No. 8, 2021/2018 edition"
|
|
13
|
+
# "WMO-No. 1364, 2023 edition, updated in 2025"
|
|
14
|
+
# "WMO-No. 8, Provisional 2026 edition"
|
|
15
|
+
# "WMO/TD-No. 196"
|
|
16
|
+
# "JCOMM Technical Report No. 14"
|
|
17
|
+
# "GAW Report No. 312"
|
|
18
|
+
# "S-411"
|
|
19
|
+
# "S-411 1.2.1"
|
|
20
|
+
# "S-411 Annex A"
|
|
21
|
+
#
|
|
22
|
+
# The faces carry no publisher token — the series head ("WMO-No.",
|
|
23
|
+
# "WMO/TD-No.", ...) is the designation and the S-number prints bare
|
|
24
|
+
# (the repository form) — so to_s(with_publisher:) is the identity
|
|
25
|
+
# on every type. The face order is the widening ruling's: volume
|
|
26
|
+
# first, then the edition face (status word inside it), then the
|
|
27
|
+
# updated-in year.
|
|
28
|
+
class Renderer < ::Pubid::Renderers::Base
|
|
29
|
+
def render(context: nil, **_opts)
|
|
30
|
+
id = @id
|
|
31
|
+
|
|
32
|
+
return render_annex(id) if id.is_a?(Identifiers::Annex)
|
|
33
|
+
return render_publication(id) if id.is_a?(Identifiers::Publication)
|
|
34
|
+
|
|
35
|
+
rendered = "S-#{id.number}"
|
|
36
|
+
rendered << " #{id.edition}" if id.edition
|
|
37
|
+
rendered
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def render_publication(id)
|
|
41
|
+
rendered = "#{id.series_config[:face]} #{id.number}"
|
|
42
|
+
rendered << ", Volume #{id.volume}" if id.volume
|
|
43
|
+
if id.edition
|
|
44
|
+
rendered << if id.edition_status
|
|
45
|
+
", #{id.edition_status} #{id.edition} edition"
|
|
46
|
+
else
|
|
47
|
+
", #{id.edition} edition"
|
|
48
|
+
end
|
|
49
|
+
rendered << ", updated in #{id.updated_in}" if id.updated_in
|
|
50
|
+
end
|
|
51
|
+
rendered
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# The marker case is preserved verbatim ("Annex" vs "ANNEX").
|
|
55
|
+
def render_annex(id)
|
|
56
|
+
rendered = "S-#{id.base.number} #{id.annex_form}"
|
|
57
|
+
rendered << " #{id.letter}" if id.letter
|
|
58
|
+
rendered << " #{id.edition}" if id.edition
|
|
59
|
+
rendered
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Wmo
|
|
5
|
+
# Generates URN strings for WMO identifiers under the WMO assigning
|
|
6
|
+
# authority of the IANA-registered `mrn` namespace, following the
|
|
7
|
+
# IALA pattern (pubid#763 proposed form; no authoritative WMO
|
|
8
|
+
# urn:mrn:wmo: rule is published — the S-411 repository carries none
|
|
9
|
+
# — so this shape is the fleet's extension until one exists):
|
|
10
|
+
#
|
|
11
|
+
# urn:mrn:wmo:pub:wmo-<number>[:vol-<v>][:status-<s>][:ed<year>]
|
|
12
|
+
# [:updated-<year>] the WMO-No. series
|
|
13
|
+
# urn:mrn:wmo:pub:wmo-td-<number> the Technical Document series
|
|
14
|
+
# urn:mrn:wmo:pub:jcomm-tr-<number> the joint WMO/IOC series
|
|
15
|
+
# urn:mrn:wmo:pub:gaw-<number> the GAW series
|
|
16
|
+
# urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>] the S-100 specs
|
|
17
|
+
# urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
|
|
18
|
+
#
|
|
19
|
+
# The segment order mirrors the human face order (volume, status,
|
|
20
|
+
# edition, updated-in). Volume and status segment values are
|
|
21
|
+
# caseless (downcased like the annex letter, re-cased by the
|
|
22
|
+
# parser). The year pair keeps its slash out of the NSS — RFC 2141
|
|
23
|
+
# has no slash in the trans set — as a hyphen ("2021/2018" rides as
|
|
24
|
+
# "ed2021-2018", the same hyphenation the MR slug uses).
|
|
25
|
+
#
|
|
26
|
+
# Examples:
|
|
27
|
+
# urn:mrn:wmo:pub:wmo-1364:ed2025
|
|
28
|
+
# urn:mrn:wmo:pub:wmo-306:vol-i.1
|
|
29
|
+
# urn:mrn:wmo:pub:wmo-8:ed2021-2018
|
|
30
|
+
# urn:mrn:wmo:pub:wmo-8:status-provisional:ed2026
|
|
31
|
+
# urn:mrn:wmo:pub:wmo-1364:ed2023:updated-2025
|
|
32
|
+
# urn:mrn:wmo:pub:wmo-td-196
|
|
33
|
+
# urn:mrn:wmo:pub:jcomm-tr-14
|
|
34
|
+
# urn:mrn:wmo:pub:gaw-312
|
|
35
|
+
# urn:mrn:wmo:pub:s-411:ed1.2.1
|
|
36
|
+
# urn:mrn:wmo:pub:s-411:annex-a
|
|
37
|
+
class UrnGenerator
|
|
38
|
+
attr_reader :identifier
|
|
39
|
+
|
|
40
|
+
def initialize(identifier)
|
|
41
|
+
@identifier = identifier
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def generate
|
|
45
|
+
return generate_annex if identifier.is_a?(Identifiers::Annex)
|
|
46
|
+
|
|
47
|
+
parts = ["urn:mrn:wmo:pub", code_segment]
|
|
48
|
+
parts << "vol-#{identifier.volume.downcase}" if identifier.volume
|
|
49
|
+
if identifier.edition_status
|
|
50
|
+
parts << "status-#{identifier.edition_status.downcase}"
|
|
51
|
+
end
|
|
52
|
+
parts << mrn_edition if identifier.edition
|
|
53
|
+
parts << "updated-#{identifier.updated_in}" if identifier.updated_in
|
|
54
|
+
parts.join(":")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
# The publication series code via its SERIES slug ("wmo-1364",
|
|
60
|
+
# "wmo-td-196", "jcomm-tr-14", "gaw-312"); the S-100 specs keep
|
|
61
|
+
# their lexical form lowercased ("s-411").
|
|
62
|
+
def code_segment
|
|
63
|
+
if identifier.is_a?(Identifiers::Publication)
|
|
64
|
+
"#{identifier.series_config[:mrn]}-#{identifier.number}"
|
|
65
|
+
else
|
|
66
|
+
"s-#{identifier.number}"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# The edition segment: the edition value glued after "ed", with
|
|
71
|
+
# the year pair's slash hyphenated.
|
|
72
|
+
def mrn_edition
|
|
73
|
+
"ed#{identifier.edition.tr('/', '-')}"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# URN for an annex: the base specification's code, then an "annex"
|
|
77
|
+
# segment (lettered form for the "ANNEX A" style, bare for "Annex"
|
|
78
|
+
# without a letter), then the annex's own edition.
|
|
79
|
+
def generate_annex
|
|
80
|
+
base = identifier.base
|
|
81
|
+
parts = ["urn:mrn:wmo:pub", "s-#{base.number}"]
|
|
82
|
+
parts << annex_segment
|
|
83
|
+
parts << "ed#{identifier.edition}" if identifier.edition
|
|
84
|
+
parts.join(":")
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def annex_segment
|
|
88
|
+
if identifier.letter
|
|
89
|
+
"annex-#{identifier.letter.downcase}"
|
|
90
|
+
else
|
|
91
|
+
"annex"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pubid
|
|
4
|
+
module Wmo
|
|
5
|
+
# Parses WMO MRN URNs back into identifiers.
|
|
6
|
+
#
|
|
7
|
+
# UrnGenerator emits:
|
|
8
|
+
# urn:mrn:wmo:pub:wmo-<number>
|
|
9
|
+
# [:vol-<v>][:status-<s>][:ed<year>][:updated-<y>]
|
|
10
|
+
# urn:mrn:wmo:pub:wmo-td-<number> / jcomm-tr-<number> / gaw-<number>
|
|
11
|
+
# urn:mrn:wmo:pub:s-<number>[:ed<x.y.z>]
|
|
12
|
+
# urn:mrn:wmo:pub:s-<number>:annex[-<letter>][:ed<x.y.z>]
|
|
13
|
+
#
|
|
14
|
+
# Examples:
|
|
15
|
+
# urn:mrn:wmo:pub:wmo-1364:ed2025 → WMO-No. 1364, 2025 edition
|
|
16
|
+
# urn:mrn:wmo:pub:wmo-306:vol-i.1 → WMO-No. 306, Volume I.1
|
|
17
|
+
# urn:mrn:wmo:pub:wmo-8:ed2021-2018 → WMO-No. 8, 2021/2018 edition
|
|
18
|
+
# urn:mrn:wmo:pub:wmo-td-196 → WMO/TD-No. 196
|
|
19
|
+
# urn:mrn:wmo:pub:jcomm-tr-14 → JCOMM Technical Report No. 14
|
|
20
|
+
# urn:mrn:wmo:pub:gaw-312 → GAW Report No. 312
|
|
21
|
+
# urn:mrn:wmo:pub:s-411:ed1.2.1 → S-411 1.2.1
|
|
22
|
+
# urn:mrn:wmo:pub:s-411:annex-a → S-411 Annex A
|
|
23
|
+
class UrnParser < Pubid::UrnParser::Base
|
|
24
|
+
PREFIX = "urn:mrn:wmo:pub:"
|
|
25
|
+
|
|
26
|
+
def parse_urn(urn)
|
|
27
|
+
body = strip_mrn_namespace(urn)
|
|
28
|
+
parts = split_parts(body)
|
|
29
|
+
code = parts.fetch(0)
|
|
30
|
+
segments = parts.drop(1)
|
|
31
|
+
|
|
32
|
+
# Longest slug first: "wmo-td-" also starts with "wmo-".
|
|
33
|
+
if (match = code.match(/\Awmo-td-(\d+)\z/i))
|
|
34
|
+
parse_publication("TD", match[1], segments)
|
|
35
|
+
elsif (match = code.match(/\Awmo-(\d+)\z/i))
|
|
36
|
+
parse_publication(nil, match[1], segments)
|
|
37
|
+
elsif (match = code.match(/\Ajcomm-tr-(\d+)\z/i))
|
|
38
|
+
parse_publication("JCOMM", match[1], segments)
|
|
39
|
+
elsif (match = code.match(/\Agaw-(\d+)\z/i))
|
|
40
|
+
parse_publication("GAW", match[1], segments)
|
|
41
|
+
elsif (match = code.match(/\As-(\d+)\z/i))
|
|
42
|
+
parse_standard(match[1], segments)
|
|
43
|
+
else
|
|
44
|
+
raise ::Pubid::Errors::UrnParseError,
|
|
45
|
+
"Invalid WMO URN code segment: #{code.inspect}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def strip_mrn_namespace(urn)
|
|
52
|
+
unless urn.downcase.start_with?(PREFIX)
|
|
53
|
+
raise ::Pubid::Errors::UrnParseError,
|
|
54
|
+
"Invalid WMO URN: #{urn.inspect}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
urn[PREFIX.length..]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Publication segments: the optional volume, status and
|
|
61
|
+
# updated-in segments plus the single ed<year> edition. All but
|
|
62
|
+
# the edition are caseless (downcased by the generator), so the
|
|
63
|
+
# rebuild re-cases them into the attested faces. The canonical
|
|
64
|
+
# comma faces are rebuilt and the text parser normalizes from
|
|
65
|
+
# there (one construction path).
|
|
66
|
+
def parse_publication(series, number, segments)
|
|
67
|
+
volume = nil
|
|
68
|
+
status = nil
|
|
69
|
+
edition = nil
|
|
70
|
+
updated_in = nil
|
|
71
|
+
|
|
72
|
+
segments.each do |seg|
|
|
73
|
+
case seg
|
|
74
|
+
when /\Avol-([a-z]+(?:\.\d+)*)\z/i
|
|
75
|
+
raise_segment!(seg, "duplicate volume") if volume
|
|
76
|
+
volume = Regexp.last_match(1).upcase
|
|
77
|
+
when /\Astatus-([a-z]+)\z/i
|
|
78
|
+
raise_segment!(seg, "duplicate status") if status
|
|
79
|
+
status = Regexp.last_match(1).capitalize
|
|
80
|
+
when /\Aed(\d{4}(?:-\d{4})?)\z/i
|
|
81
|
+
raise_segment!(seg, "duplicate edition") if edition
|
|
82
|
+
edition = Regexp.last_match(1).tr("-", "/")
|
|
83
|
+
when /\Aupdated-(\d{4})\z/i
|
|
84
|
+
raise_segment!(seg, "duplicate updated") if updated_in
|
|
85
|
+
updated_in = Regexp.last_match(1)
|
|
86
|
+
else
|
|
87
|
+
raise_segment!(seg)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
text = "#{Identifier.series_config(series)[:face]} #{number}"
|
|
92
|
+
text << " Volume #{volume}" if volume
|
|
93
|
+
if edition
|
|
94
|
+
text << if status
|
|
95
|
+
", #{status} #{edition} edition"
|
|
96
|
+
else
|
|
97
|
+
", #{edition} edition"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
text << ", updated in #{updated_in}" if updated_in
|
|
101
|
+
flavor_parse(text)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Standard and annex segments: an optional annex segment (at most
|
|
105
|
+
# one), then the optional dotted edition. Rebuilt as the human
|
|
106
|
+
# forms.
|
|
107
|
+
#
|
|
108
|
+
# The annex segment is caseless in the MRN ("annex" / "annex-a"),
|
|
109
|
+
# so the rebuild picks the attested WMO face "Annex" (the DCEG
|
|
110
|
+
# docidentifier). The uppercase "ANNEX" form stays a parse-only
|
|
111
|
+
# human alias; its URN re-renders to the attested face.
|
|
112
|
+
def parse_standard(number, segments)
|
|
113
|
+
annex_letter = nil
|
|
114
|
+
edition = nil
|
|
115
|
+
has_annex = false
|
|
116
|
+
|
|
117
|
+
segments.each do |seg|
|
|
118
|
+
case seg
|
|
119
|
+
when /\Aannex(-([a-z]))?\z/i
|
|
120
|
+
raise_segment!(seg, "duplicate annex") if has_annex
|
|
121
|
+
|
|
122
|
+
has_annex = true
|
|
123
|
+
annex_letter = Regexp.last_match(2)&.upcase
|
|
124
|
+
else
|
|
125
|
+
raise_segment!(seg) if edition
|
|
126
|
+
|
|
127
|
+
edition = edition_value(seg, /\A\d+(\.\d+)+\z/)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
text = "S-#{number}"
|
|
132
|
+
text += " Annex" if has_annex
|
|
133
|
+
text += " #{annex_letter}" if annex_letter
|
|
134
|
+
text += " #{edition}" if edition
|
|
135
|
+
flavor_parse(text)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# The value of an "ed<value>" segment, validated against +shape+
|
|
139
|
+
# (a year for a publication, dotted for a standard or annex). Any
|
|
140
|
+
# other segment is a parse error, per the ISO urn_parser strictness.
|
|
141
|
+
def edition_value(seg, shape)
|
|
142
|
+
unless seg.match?(/\Aed/i)
|
|
143
|
+
raise_segment!(seg)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
edition = seg.sub(/\Aed/i, "")
|
|
147
|
+
return edition if edition.match?(shape)
|
|
148
|
+
|
|
149
|
+
raise_segment!(seg)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def raise_segment!(seg, reason = nil)
|
|
153
|
+
detail = reason ? " (#{reason})" : ""
|
|
154
|
+
raise ::Pubid::Errors::UrnParseError,
|
|
155
|
+
"Invalid WMO URN segment#{detail}: #{seg.inspect}"
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
data/lib/pubid/wmo.rb
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pubid"
|
|
4
|
+
module Pubid
|
|
5
|
+
# WMO (World Meteorological Organization) document identifiers
|
|
6
|
+
# (pubid#763 widened): the WMO-No. publication series and the other
|
|
7
|
+
# WMO technical-document series (WMO/TD, JCOMM Technical Report, GAW
|
|
8
|
+
# Report) and, since the JCOMM dissolution, the WMO-published
|
|
9
|
+
# S-100-family product specifications.
|
|
10
|
+
#
|
|
11
|
+
# WMO-No. 1364 the WMO-No. series, bare
|
|
12
|
+
# WMO-No. 1364, 2025 edition year edition (calendar years)
|
|
13
|
+
# WMO-No. 8, Volume I volume face (before the edition)
|
|
14
|
+
# WMO-No. 8, 2021/2018 edition compound year-pair edition
|
|
15
|
+
# WMO-No. 8, Provisional 2026
|
|
16
|
+
# edition status-qualified edition
|
|
17
|
+
# WMO-No. 1364, 2023 edition,
|
|
18
|
+
# updated in 2025 edition + updated-in year
|
|
19
|
+
# WMO/TD-No. 196 the Technical Document series
|
|
20
|
+
# JCOMM Technical Report No. 14 the joint WMO/IOC series
|
|
21
|
+
# GAW Report No. 312 the GAW series
|
|
22
|
+
# S-411 WMO-published S-100 spec, bare
|
|
23
|
+
# S-411 1.2.1 dotted edition (the S-411 repo form)
|
|
24
|
+
# S-411 Annex A annex wrapper (the DCEG docidentifier)
|
|
25
|
+
#
|
|
26
|
+
# The S-lexical type assignment is the #763 ruling: the lexical shape is
|
|
27
|
+
# the IHO S-100 form, but the flavor owns the WMO-published documents —
|
|
28
|
+
# the same publisher-parameterised split as IALA's S-201 (Pubid::Iala,
|
|
29
|
+
# urn:mrn:iala:pub:s-201:ed2.0.0). See lib/pubid/wmo/CLAUDE.md.
|
|
30
|
+
module Wmo
|
|
31
|
+
extend Pubid::PrefixesSupport
|
|
32
|
+
|
|
33
|
+
# The leading series tokens of the publication series (the widening
|
|
34
|
+
# prefix law: a head token names its publisher — the bare "TD-No."
|
|
35
|
+
# spelling names no publisher and parses in no flavor). These are
|
|
36
|
+
# this flavor's OWN tokens, not joint publications, so they live
|
|
37
|
+
# here and not in JOINT_PREFIXES. The S-100 lexical form ("S-411")
|
|
38
|
+
# deliberately leads NO prefix: a bare S-number is the shared S-100
|
|
39
|
+
# shape of two assigning authorities (IHO and WMO), so each flavor
|
|
40
|
+
# parses it and neither owns the routing (the pubid#469
|
|
41
|
+
# dual-perspective policy).
|
|
42
|
+
PREFIXES = [
|
|
43
|
+
"WMO-No.",
|
|
44
|
+
"WMO/TD-No.",
|
|
45
|
+
"JCOMM Technical Report No.",
|
|
46
|
+
"GAW Report No.",
|
|
47
|
+
].freeze
|
|
48
|
+
|
|
49
|
+
autoload :Builder, "#{__dir__}/wmo/builder"
|
|
50
|
+
autoload :Identifier, "#{__dir__}/wmo/identifier"
|
|
51
|
+
autoload :Identifiers, "#{__dir__}/wmo/identifiers"
|
|
52
|
+
autoload :Parser, "#{__dir__}/wmo/parser"
|
|
53
|
+
autoload :Renderer, "#{__dir__}/wmo/renderer"
|
|
54
|
+
autoload :UrnGenerator, "#{__dir__}/wmo/urn_generator"
|
|
55
|
+
autoload :UrnParser, "#{__dir__}/wmo/urn_parser"
|
|
56
|
+
autoload :PubidUrnSchema, "#{__dir__}/wmo/pubid_urn_schema"
|
|
57
|
+
|
|
58
|
+
# Parse a WMO identifier string into an identifier object.
|
|
59
|
+
# @param identifier [String] The WMO identifier string to parse
|
|
60
|
+
# @return [Pubid::Wmo::Identifier]
|
|
61
|
+
def self.parse(identifier)
|
|
62
|
+
Identifier.parse(identifier)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Per-flavor format registry: inherits global formats, overrides :human
|
|
66
|
+
Identifier.format_registry = FormatRegistry.new(parent: ::Pubid::Identifier.format_registry)
|
|
67
|
+
Identifier.format_registry.register(:human, renderer: Wmo::Renderer)
|
|
68
|
+
|
|
69
|
+
# Auto-discover all identifier types from the Identifiers namespace.
|
|
70
|
+
# @return [Array<Class>] identifier classes (Pubid::Identifier subclasses)
|
|
71
|
+
def self.identifier_types
|
|
72
|
+
@identifier_types ||= Identifiers.constants
|
|
73
|
+
.filter_map { |c| resolve_identifier_constant(c) }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# One Identifiers constant as an identifier class, or nil: a constant
|
|
77
|
+
# that does not resolve, or resolves to anything but a Pubid::Identifier
|
|
78
|
+
# subclass, is not a type.
|
|
79
|
+
# @param const [Symbol]
|
|
80
|
+
# @return [Class, nil]
|
|
81
|
+
def self.resolve_identifier_constant(const)
|
|
82
|
+
klass = Identifiers.const_get(const)
|
|
83
|
+
return if !klass.is_a?(Class) || !(klass < Pubid::Identifier)
|
|
84
|
+
|
|
85
|
+
klass unless klass == Identifier
|
|
86
|
+
rescue NameError
|
|
87
|
+
nil
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# WMO identifiers carry no typed stages.
|
|
91
|
+
# @return [Array<Pubid::Components::TypedStage>]
|
|
92
|
+
def self.all_typed_stages
|
|
93
|
+
[]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Lookup: type code -> identifier class
|
|
97
|
+
# @param code [String, Symbol]
|
|
98
|
+
# @return [Class, nil]
|
|
99
|
+
def self.locate_type(code)
|
|
100
|
+
identifier_types.find { |t| t.type[:key].to_s == code.to_s }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# WMO identifiers carry no typed stages.
|
|
104
|
+
# @param _abbr [String, Symbol]
|
|
105
|
+
# @return [nil]
|
|
106
|
+
def self.locate_stage(_abbr)
|
|
107
|
+
nil
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
Pubid::Registry.register(:wmo, Pubid::Wmo)
|
data/lib/pubid.rb
CHANGED
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.
|
|
4
|
+
version: 2.0.49
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -156,6 +156,8 @@ files:
|
|
|
156
156
|
- data/parg/tgpp.json
|
|
157
157
|
- data/parg/un.json
|
|
158
158
|
- data/parg/w3c.json
|
|
159
|
+
- data/parg/wmo.json
|
|
160
|
+
- data/parg/wmo.parg
|
|
159
161
|
- data/parg/xsf.json
|
|
160
162
|
- data/plateau/update_codes.yaml
|
|
161
163
|
- lib/pubid.rb
|
|
@@ -1206,6 +1208,19 @@ files:
|
|
|
1206
1208
|
- lib/pubid/w3c/renderer.rb
|
|
1207
1209
|
- lib/pubid/w3c/urn_generator.rb
|
|
1208
1210
|
- lib/pubid/w3c/urn_parser.rb
|
|
1211
|
+
- lib/pubid/wmo.rb
|
|
1212
|
+
- lib/pubid/wmo/CLAUDE.md
|
|
1213
|
+
- lib/pubid/wmo/builder.rb
|
|
1214
|
+
- lib/pubid/wmo/identifier.rb
|
|
1215
|
+
- lib/pubid/wmo/identifiers.rb
|
|
1216
|
+
- lib/pubid/wmo/identifiers/annex.rb
|
|
1217
|
+
- lib/pubid/wmo/identifiers/publication.rb
|
|
1218
|
+
- lib/pubid/wmo/identifiers/standard.rb
|
|
1219
|
+
- lib/pubid/wmo/parser.rb
|
|
1220
|
+
- lib/pubid/wmo/pubid_urn_schema.rb
|
|
1221
|
+
- lib/pubid/wmo/renderer.rb
|
|
1222
|
+
- lib/pubid/wmo/urn_generator.rb
|
|
1223
|
+
- lib/pubid/wmo/urn_parser.rb
|
|
1209
1224
|
- lib/pubid/xsf.rb
|
|
1210
1225
|
- lib/pubid/xsf/CLAUDE.md
|
|
1211
1226
|
- lib/pubid/xsf/builder.rb
|
|
@@ -1249,7 +1264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1249
1264
|
- !ruby/object:Gem::Version
|
|
1250
1265
|
version: '0'
|
|
1251
1266
|
requirements: []
|
|
1252
|
-
rubygems_version: 4.0.
|
|
1267
|
+
rubygems_version: 4.0.23
|
|
1253
1268
|
specification_version: 4
|
|
1254
1269
|
summary: The international publication identifier (PubID) library for Ruby.
|
|
1255
1270
|
test_files: []
|