pubid 2.0.46 → 2.0.48

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.
@@ -13,6 +13,22 @@ module Pubid
13
13
  attribute :part, :string
14
14
  attribute :subpart, :string
15
15
 
16
+ # How the input joined the year to the number: "-" for the
17
+ # "ANSI X9.62-2005" spelling, nil for the colon of "ANSI/ISO 9899:1990".
18
+ # Spelling only, so `==`, `hash` and `===` skip it (relaton#45).
19
+ attribute :date_separator, :string
20
+ equality_ignored :date_separator
21
+
22
+ # How the input joined the publisher group to the number: "-" for the
23
+ # "ANSI/ISA-5.1-2009" spelling, nil for the space of "ANSI/ISA 5.1".
24
+ # Spelling only, so `==`, `hash` and `===` skip it.
25
+ attribute :number_separator, :string
26
+ equality_ignored :number_separator
27
+
28
+ # The revision letter of "ANSI/TIA-568.2-D". It names a different
29
+ # document, so it is identity; `#revision_of?` reads it.
30
+ attribute :revision, :string
31
+
16
32
  def self.parse(string)
17
33
  unless string.is_a?(String)
18
34
  raise Pubid::Errors::InvalidInputError,
@@ -28,6 +44,23 @@ module Pubid
28
44
  parsed = Pubid::Parg::Model.bound(:ansi, string)
29
45
  Pubid::Ansi::Builder.new.build(parsed)
30
46
  end
47
+
48
+ # The revision is identity, so it reaches the slug too: "568.2-C" and
49
+ # "568.2-D" must not share a filename.
50
+ def mr_number_with_part
51
+ num = super
52
+ num && mr_join(num, revision&.downcase)
53
+ end
54
+
55
+ # The separator belongs to the year: drop it with the year, so a
56
+ # year-less copy carries no orphan spelling flag in its hash.
57
+ def exclude(*args)
58
+ result = super
59
+ if args.include?(:year) || args.include?(:date)
60
+ result.date_separator = nil
61
+ end
62
+ result
63
+ end
31
64
  end
32
65
  end
33
66
  end
@@ -4,7 +4,8 @@ module Pubid
4
4
  # American National Standard identifier
5
5
  class AmericanNationalStandard < SingleIdentifier
6
6
  def self.type
7
- { key: :ans, web: :american_national_standard,
7
+ { key: :american_national_standard,
8
+ web: :american_national_standard,
8
9
  title: "American National Standard", short: "ANS" }
9
10
  end
10
11
  end
@@ -5,11 +5,11 @@ module Pubid
5
5
  # The pubid-scheme URN of ANSI (issue #656; docs/URN-SCHEMES.adoc).
6
6
  #
7
7
  # ANSI 802.3-2012
8
- # urn:pubid:ansi:std:802.3:pub-ANSI:part-2012
8
+ # urn:pubid:ansi:std:802.3:pub-ANSI:year-2012:f:0.datesep--
9
9
  #
10
10
  # Landed with the IEEE wave, which nests ANSI ids ("IEEE Std 144-1971
11
- # (ANSI C37.24-1971)"). Note that ANSI stores the year of
12
- # "ANSI 802.3-2012" in +part+ ("2012"); the URN keeps it as it is.
11
+ # (ANSI C37.24-1971)"). The trailing "-2012" is the year (relaton#45);
12
+ # its dash is the spelling facet +datesep+.
13
13
  #
14
14
  # A component attribute maps through its identifying field only
15
15
  # (+type.abbr+, +stage.abbr+, +edition.number+ …). The registry fields of
@@ -22,6 +22,7 @@ module Pubid
22
22
  atom "type.abbr", "type"
23
23
  atom "part", "part"
24
24
  atom "subpart", "subpart"
25
+ atom "revision", "rev"
25
26
  atom "year", "year"
26
27
  atom "date.year", "dateyear"
27
28
  atom "date.month", "datemonth"
@@ -35,6 +36,8 @@ module Pubid
35
36
 
36
37
  facet "languages.*.original_code", "langsrc"
37
38
  facet "edition.original_text", "edsrc"
39
+ facet "date_separator", "datesep"
40
+ facet "number_separator", "numsep"
38
41
 
39
42
  type "pubid:ansi:standard", "std"
40
43
  type "pubid:ansi:american-national-standard", "ans"
@@ -8,6 +8,7 @@ module Pubid
8
8
  # "ANSI X3.4"
9
9
  # "ANSI/ISO 9899"
10
10
  # "ANSI X9.8-1:2007"
11
+ # "ANSI X9.62-2005" (date_separator "-")
11
12
  #
12
13
  # The renderer is registered as the `:human` format in the ANSI format
13
14
  # registry and invoked via `render(format: :human)`.
@@ -15,10 +16,11 @@ module Pubid
15
16
  def render(context: nil, **opts)
16
17
  id = @id
17
18
 
18
- parts = []
19
- parts << publisher_portion(id, context)
20
- parts << number_portion(id, context)
21
- result = parts.compact.join(" ")
19
+ # "ANSI/ISA-5.1-2009" keeps its dash; the space is the default.
20
+ result = [
21
+ publisher_portion(id, context),
22
+ number_portion(id, context),
23
+ ].join(id.number_separator || " ")
22
24
 
23
25
  result << language_portion(id) if id.languages&.any?
24
26
 
@@ -39,10 +41,18 @@ module Pubid
39
41
  [
40
42
  id.number,
41
43
  (id.part ? "-#{id.part}" : ""),
42
- (id.date ? ":#{id.date.render(context:)}" : ""),
44
+ (id.revision ? "-#{id.revision}" : ""),
45
+ date_portion(id, context),
43
46
  ].join
44
47
  end
45
48
 
49
+ # "ANSI X9.62-2005" keeps its dash; the colon is the default.
50
+ def date_portion(id, context)
51
+ return "" unless id.date
52
+
53
+ "#{id.date_separator || ':'}#{id.date.render(context:)}"
54
+ end
55
+
46
56
  def language_portion(id)
47
57
  return "" unless id.languages&.any?
48
58
 
@@ -18,6 +18,8 @@ module Pubid
18
18
  parts << urn_part if urn_part
19
19
  parts << urn_subpart if urn_subpart
20
20
  parts << urn_year if urn_year
21
+ # "568.2-C" and "568.2-D" are two documents: keep them apart.
22
+ parts << "rev-#{identifier.revision}" if identifier.revision
21
23
  parts << urn_edition if urn_edition
22
24
  parts << urn_typed_stage if urn_typed_stage
23
25
 
data/lib/pubid/ansi.rb CHANGED
@@ -6,10 +6,16 @@ module Pubid
6
6
  extend Pubid::PrefixesSupport
7
7
 
8
8
  # ANSI publisher token; ANSI/ASHRAE and ANSI/AMCA joint forms come from
9
- # Pubid::JOINT_PREFIXES. Parser::ORGANIZATIONS are co-publishers, not
10
- # leading ANSI tokens, so they are excluded.
9
+ # Pubid::JOINT_PREFIXES. Co-publisher acronyms are not leading ANSI
10
+ # tokens, so they are excluded.
11
11
  PREFIXES = ["ANSI"].freeze
12
12
 
13
+ # ANSI parses any "ANSI/<ACRONYM> ..." (relaton#45), so a co-publisher
14
+ # with a flavor of its own (AMCA, ASHRAE) keeps the route.
15
+ def self.routing_umbrella?
16
+ true
17
+ end
18
+
13
19
  autoload :Builder, "#{__dir__}/ansi/builder"
14
20
  autoload :Identifier, "#{__dir__}/ansi/identifier"
15
21
  autoload :Identifiers, "#{__dir__}/ansi/identifiers"
@@ -48,5 +48,16 @@ module Pubid
48
48
  name.split("::").last
49
49
  .gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase.to_sym
50
50
  end
51
+
52
+ # True for a flavor that accredits other publishers' documents and so
53
+ # parses their joint prefix too (ANSI reads +ANSI/AMCA 210-16+). When
54
+ # it shares a prefix with a co-publisher's own flavor, {Pubid.parse}
55
+ # tries it last and prefers the co-publisher's parse, even a
56
+ # normalizing one. Default false.
57
+ #
58
+ # @return [Boolean]
59
+ def routing_umbrella?
60
+ false
61
+ end
51
62
  end
52
63
  end
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.46"
4
+ VERSION = "2.0.48"
5
5
  end
@@ -0,0 +1,114 @@
1
+ # WMO flavor notes
2
+
3
+ WMO (World Meteorological Organization) publication identifiers and
4
+ their MRN URNs (pubid#763): the WMO-No. series and, since the JCOMM
5
+ dissolution, the WMO-published S-100-family product specifications
6
+ (consumer: metanorma/S-411-Product-Specification, authored
7
+ `mn-document-class: wmo` in the metanorma-taste `data/wmo` flavor).
8
+
9
+ Read this before you change `lib/pubid/wmo/` or `spec/pubid/wmo/`. The
10
+ root `CLAUDE.md` keeps the cross-flavor contract that every flavor
11
+ obeys.
12
+
13
+ ## The type assignment (the #763 ruling)
14
+
15
+ The S-100 type assignment follows the fleet's own precedent: IALA's
16
+ `S-201` is the S-100-family lexical form under the publishing org's
17
+ flavor (`Pubid::Iala`, `urn:mrn:iala:pub:s-201:ed2.0.0`). WMO-published
18
+ `S-411` is the same shape, so it is a **Pubid::Wmo** type — the
19
+ S-lexical form as a WMO type, publisher-parameterised, not a Pubid::Iho
20
+ identifier. The bare `S-411` string alone still names two documents
21
+ (IHO's and WMO's — each org assigns its own identifier), so like the
22
+ pubid#469 dual-perspective shapes the lexical form leads NO prefix and
23
+ `PREFIXES` carries only `WMO-No.`; the umbrella router reaches WMO's
24
+ S-411 through the exact-round-trip preference, never through a claimed
25
+ prefix.
26
+
27
+ ## Identifier space
28
+
29
+ | Type | Shape | Edition face | Example |
30
+ |------|-------|--------------|---------|
31
+ | Publication | `WMO-No. <n>` | calendar year: `, 2025 edition` | `WMO-No. 1364, 2025 edition` |
32
+ | Standard | `S-<n>` | dotted x.y.z: ` 1.2.1` | `S-411 1.2.1` |
33
+ | Annex | `S-<n> Annex <L>` (wrapper over Standard) | dotted, on the annex | `S-411 Annex A` |
34
+
35
+ - **Editions are one string attribute with a type-driven face.** The
36
+ issue's semantics: WMO editions are calendar years (`2025 edition`)
37
+ on the WMO-No. series, the S-100 shapes carry the dotted `ed1.2.1`
38
+ MRN form. The grammar binds both into the one `edition_value`
39
+ capture; the renderer and the MRN generator key the face off the
40
+ resolved type. There is no Components::Edition.
41
+ - **Parse-only alternates**: the cover-stack year face
42
+ (`WMO-No. 1364 2025 edition`), the compact aliases
43
+ (`WMO-No. 1364:ed2025`, `S-411:ed1.2.1`) and the uppercase `ANNEX`
44
+ marker all parse and normalize; the canonical faces are the
45
+ repository forms (`S-411 1.2.1`, `S-411 Annex A`) and the WMO catalog
46
+ citation (`WMO-No. 1364, 2025 edition`).
47
+ - **The dotted S-100 edition requires a dot** (`S-411 1.2` parses,
48
+ `S-411 1234` rejects): a bare digit run after the code is not an
49
+ edition face in either series, and the year face (4 digits) is
50
+ publication-only. `WMO-No. 1364:ed1.2.1` rejects for the same reason.
51
+
52
+ ## The faces carry no publisher token
53
+
54
+ `WMO-No.` is the series designation (the GB/GOST rule) and the S-number
55
+ prints bare — the repository's docidentifiers are `S-411 Annex A` and
56
+ `S-411 1.2.1`, never `WMO S-411`. `publisher_prefixes` is `[]`, so
57
+ `to_s(with_publisher:)` is the identity on every type.
58
+
59
+ ## MRN URN scheme
60
+
61
+ The `mrn` URN tree with WMO as assigning authority, sub-namespace
62
+ `pub`, following the IALA pattern:
63
+
64
+ ```
65
+ urn:mrn:wmo:pub:wmo-<number>[:ed<year>]
66
+ urn:mrn:wmo:pub:s-<number>[:annex[-<letter>]][:ed<x.y.z>]
67
+ ```
68
+
69
+ - The WMO-No. series codes as `wmo-<number>` and its edition segment is
70
+ the year (`urn:mrn:wmo:pub:wmo-1364:ed2025`); the S-100 specs keep
71
+ their lexical form lowercased (`s-411`) with the dotted edition
72
+ (`urn:mrn:wmo:pub:s-411:ed1.2.1`).
73
+ - **No authoritative rule exists yet.** The issue asked for a search
74
+ before assuming the shape: neither the S-411 repository nor any local
75
+ checkout carries a `urn:mrn:wmo:` spelling, so this generator/parser
76
+ pair IS the namespace extension, recorded as the issue's proposed
77
+ form. If WMO publishes a rule, that rule wins and this pair moves.
78
+ - The parser rebuilds the human forms and delegates to the text parser
79
+ (one construction path). The MRN annex segment is caseless
80
+ (`annex-a`), so the rebuild picks the attested face `Annex` — the
81
+ uppercase `ANNEX` human form stays a parse-only alias whose URN
82
+ re-renders to the attested face. Unknown/duplicate/reordered segments
83
+ raise `Pubid::Errors::UrnParseError` (the ISO urn_parser strictness).
84
+
85
+ ## pubid-scheme URN (docs/URN-SCHEMES.adoc, `[[urn-wmo]]`)
86
+
87
+ `lib/pubid/wmo/pubid_urn_schema.rb`: atoms `ed-` (`edition`),
88
+ `annexform-` (`annex_form`), `letter-` (`letter`); types
89
+ `pub`/`std`/`annex` over the default `number` core. The annex rides the
90
+ root-first chain (`urn:pubid:wmo:std:411:annex:annexform-Annex:
91
+ letter-A`), so the base standard is the slug prefix. `annex_form` is an
92
+ atom (identity) per the iala schema — "Annex" and "ANNEX" are two
93
+ identifiers.
94
+
95
+ ## Corpus ground truth (attested only)
96
+
97
+ `spec/fixtures/wmo/identifiers/full/identifiers.txt`, regenerated by
98
+ `rake "validation:classify[wmo]"`:
99
+
100
+ - `WMO-No. 8`, `WMO-No. 49`, `WMO-No. 1364` — the issue's series
101
+ examples; `2025 edition` — the issue's calendar-year face.
102
+ - `S-411 1.2.1` (PS), `S-411 1.2.0` (DCEG), `S-411 Annex A` (the DCEG
103
+ `:docidentifier:`), `S-411 1.1.0` (the June 2014 original PDF) —
104
+ metanorma/S-411-Product-Specification; `S-412` — the issue.
105
+ - The MRN URN rows are the issue's proposed forms over those rows.
106
+
107
+ ## relaton-side follow-ups (not this repo)
108
+
109
+ bibdata carries the plain string `S-411` today; a relaton-side ask for
110
+ docidentifier types and MRN URNs is to be filed in the relaton monogem
111
+ and cross-linked on #763. metanorma-taste's `data/wmo` flavor registers
112
+ its URN generator the way `Metanorma::Taste::UrnGenerator.register`
113
+ does for the other flavors, so S-411 documents mint the publication
114
+ URN from fields instead of hand-pinning a `:urn:` attribute.
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ # Builds a WMO identifier object from the artifact's bound map —
6
+ # the flat attribute hash the grammar's bindings block declares
7
+ # (typed at the engine, one key per capture).
8
+ #
9
+ # Each grammar alternative path carries exactly one occurrence of
10
+ # `doc_number` and `edition_value`, so one flat map serves all three
11
+ # types; the builder dispatches on `annex_marker` and `wmomarker`.
12
+ class Builder
13
+ def build(parsed)
14
+ return build_annex(parsed) if parsed[:annex_marker]
15
+ return build_publication(parsed) if parsed[:wmomarker]
16
+
17
+ Identifiers::Standard.new(**standard_attrs(parsed))
18
+ end
19
+
20
+ def self.build(parsed)
21
+ new.build(parsed)
22
+ end
23
+
24
+ private
25
+
26
+ def build_publication(hash)
27
+ Identifiers::Publication.new(**standard_attrs(hash))
28
+ end
29
+
30
+ def build_annex(hash)
31
+ base = Identifiers::Standard.new(number: hash[:doc_number])
32
+
33
+ attrs = {
34
+ base: base,
35
+ annex_form: hash[:annex_marker],
36
+ letter: hash[:annex_letter],
37
+ edition: hash[:edition_value],
38
+ }.compact
39
+
40
+ Identifiers::Annex.new(**attrs)
41
+ end
42
+
43
+ def standard_attrs(hash)
44
+ {
45
+ number: hash[:doc_number],
46
+ edition: hash[:edition_value],
47
+ }.compact
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ Pubid::Wmo::Builder.prepend(Pubid::Builder::AllPartsWrap)
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ # Base class for all WMO identifiers. Canonical name
6
+ # Pubid::Wmo::Identifier; every concrete WMO identifier
7
+ # (Identifiers::*) descends from it.
8
+ #
9
+ # Two series share the flavor (pubid#763):
10
+ #
11
+ # WMO-No. <number>[, <year> edition] the WMO-No. publication
12
+ # series; editions are
13
+ # calendar years
14
+ # S-<number>[ <x.y.z>] the WMO-published S-100
15
+ # product specifications;
16
+ # editions are dotted x.y.z
17
+ # S-<number> [Annex|ANNEX] [<letter>] [<x.y.z>] annex wrapper
18
+ #
19
+ # The edition is ONE string attribute carrying a type-driven face:
20
+ # "2025" on a Publication, "1.2.1" on a Standard or Annex. The
21
+ # renderer and the MRN URN generator key the face off the type.
22
+ class Identifier < ::Pubid::Identifier
23
+ # Parse a WMO identifier string — human form ("WMO-No. 1364",
24
+ # "S-411 1.2.1") or MRN URN ("urn:mrn:wmo:pub:s-411:ed1.2.1") —
25
+ # into an identifier.
26
+ # @param identifier [String]
27
+ # @return [Pubid::Wmo::Identifier]
28
+ # @raise [Pubid::Errors::ParseError] If parsing fails
29
+ def self.parse(identifier)
30
+ unless identifier.is_a?(String)
31
+ raise Pubid::Errors::InvalidInputError,
32
+ Pubid::INPUT_NOT_A_STRING_MESSAGE
33
+ end
34
+
35
+ if identifier.length > Pubid::MAX_INPUT_LENGTH
36
+ raise Pubid::Errors::InvalidInputError, Pubid::INPUT_TOO_LONG_MESSAGE
37
+ end
38
+
39
+ identifier = ::Pubid.utf8_input(identifier)
40
+
41
+ if FormatDetector.detect(identifier) == :urn
42
+ UrnParser.parse(identifier)
43
+ else
44
+ parsed = Pubid::Parg::Model.bound(:wmo, identifier)
45
+ Builder.build(parsed)
46
+ end
47
+ end
48
+
49
+ attribute :publisher, :string, default: "WMO"
50
+ attribute :number, :string # "1364", "411"
51
+ # One edition column, type-driven face: "2025" (the WMO-No. series'
52
+ # calendar-year edition) or "1.2.1" (the S-100 dotted edition).
53
+ attribute :edition, :string
54
+
55
+ WMO_TYPE_MAP = {
56
+ "pubid:wmo:publication" => "Pubid::Wmo::Identifiers::Publication",
57
+ "pubid:wmo:standard" => "Pubid::Wmo::Identifiers::Standard",
58
+ "pubid:wmo:annex" => "Pubid::Wmo::Identifiers::Annex",
59
+ }.freeze
60
+
61
+ key_value do
62
+ map "_type", to: :_type, polymorphic_map: WMO_TYPE_MAP
63
+ map "number", to: :number
64
+ map "edition", to: :edition
65
+ end
66
+
67
+ def to_urn
68
+ UrnGenerator.new(self).generate
69
+ end
70
+
71
+ # The edition is a plain string (the string-edition flavors precede
72
+ # this); the base mr_edition reads edition.number of a
73
+ # Components::Edition, which would crash on the string.
74
+ def mr_edition
75
+ return nil unless edition
76
+
77
+ "ed#{edition}"
78
+ end
79
+
80
+ # "WMO-No." and the S-number are designations, not publisher
81
+ # tokens: the canonical faces carry no publisher prefix for
82
+ # with_publisher to cut (the GB/GOST/ECMA rule).
83
+ def publisher_prefixes
84
+ []
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ module Identifiers
6
+ # An annex to a WMO-published S-100 product specification:
7
+ # "S-411 Annex A" (the Data Classification and Encoding Guide's
8
+ # docidentifier in metanorma/S-411-Product-Specification). The
9
+ # marker case is preserved (Annex vs ANNEX) for round-trip
10
+ # fidelity; the optional edition applies to the annex itself,
11
+ # not the base.
12
+ class Annex < Identifier
13
+ # The specification this annex supplements. Always present;
14
+ # carries the S-number (e.g. S-411).
15
+ attribute :base, ::Pubid::Wmo::Identifier, polymorphic: true
16
+ # "Annex" or "ANNEX" — preserved verbatim for exact round-trip.
17
+ attribute :annex_form, :string
18
+ # "A", "B", … or nil for the bare form.
19
+ attribute :letter, :string
20
+
21
+ key_value do
22
+ map "base", to: :base
23
+ map "annex_form", to: :annex_form
24
+ map "letter", to: :letter
25
+ end
26
+
27
+ def self.type
28
+ { key: :annex, title: "Annex", short: nil }
29
+ end
30
+
31
+ # MR string: the base head, then the annex marker (and letter),
32
+ # then the annex's own edition — "wmo.411_annex-a.ed1.2.0".
33
+ # Returning non-nil is what makes the shared MrString renderer
34
+ # recurse into `base` for the head.
35
+ def mr_supplement_suffix
36
+ segments = [letter ? "annex-#{letter.downcase}" : "annex"]
37
+ segments << "ed#{edition}" if edition
38
+ segments.join(".")
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ module Identifiers
6
+ # The WMO-No. publication series: "WMO-No. 8", "WMO-No. 49",
7
+ # "WMO-No. 1364". Editions are calendar years — "2025 edition" —
8
+ # never version ordinals; the MRN edition segment is ed<year>
9
+ # (urn:mrn:wmo:pub:wmo-1364:ed2025).
10
+ class Publication < Identifier
11
+ def self.type
12
+ { key: :publication, title: "Publication", short: nil }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ module Identifiers
6
+ # The WMO-published S-100 product specifications: the IHO S-100
7
+ # lexical form ("S-411", "S-412") with WMO as the assigning
8
+ # authority — the S-201-of-IALA type assignment of the #763
9
+ # ruling. Editions are the S-100 dotted x.y.z ("S-411 1.2.1",
10
+ # MRN ed1.2.1).
11
+ class Standard < Identifier
12
+ def self.type
13
+ { key: :standard, title: "Standard", short: "S" }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ module Identifiers
6
+ autoload :Annex, "#{__dir__}/identifiers/annex"
7
+ autoload :Publication, "#{__dir__}/identifiers/publication"
8
+ autoload :Standard, "#{__dir__}/identifiers/standard"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ # Grammar for WMO identifiers.
6
+ #
7
+ # Accepts every attested shape (pubid#763):
8
+ #
9
+ # WMO-No. 1364
10
+ # WMO-No. 1364, 2025 edition
11
+ # WMO-No. 1364 2025 edition
12
+ # WMO-No. 1364:ed2025
13
+ # S-411
14
+ # S-411 1.2.1
15
+ # S-411:ed1.2.1
16
+ # S-411 Annex A
17
+ class Parser
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pubid
4
+ module Wmo
5
+ # The pubid-scheme URN of wmo (pubid#763; docs/URN-SCHEMES.adoc).
6
+ #
7
+ # WMO-No. 1364, 2025 edition -> urn:pubid:wmo:pub:1364:ed-2025
8
+ # S-411 1.2.1 -> urn:pubid:wmo:std:411:ed-1.2.1
9
+ # S-411 Annex A -> urn:pubid:wmo:std:411:annex:annexform-Annex:letter-A
10
+ #
11
+ # The edition is one atom: a calendar-year face on a publication,
12
+ # a dotted face on a standard or annex. The annex marker and letter
13
+ # follow the iala schema (annexform- / letter-).
14
+ PubidUrnSchema = Pubid::PubidUrn.define("wmo") do
15
+ atom "edition", "ed"
16
+ atom "annex_form", "annexform"
17
+ atom "letter", "letter"
18
+
19
+ type "pubid:wmo:publication", "pub"
20
+ type "pubid:wmo:standard", "std"
21
+ type "pubid:wmo:annex", "annex"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,44 @@
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
+ # "S-411"
11
+ # "S-411 1.2.1"
12
+ # "S-411 Annex A"
13
+ #
14
+ # The faces carry no publisher token — "WMO-No." is the series
15
+ # designation and the S-number prints bare (the repository form) —
16
+ # so to_s(with_publisher:) is the identity on every type.
17
+ class Renderer < ::Pubid::Renderers::Base
18
+ def render(context: nil, **_opts)
19
+ id = @id
20
+
21
+ return render_annex(id) if id.is_a?(Identifiers::Annex)
22
+ return render_publication(id) if id.is_a?(Identifiers::Publication)
23
+
24
+ rendered = "S-#{id.number}"
25
+ rendered << " #{id.edition}" if id.edition
26
+ rendered
27
+ end
28
+
29
+ def render_publication(id)
30
+ rendered = "WMO-No. #{id.number}"
31
+ rendered << ", #{id.edition} edition" if id.edition
32
+ rendered
33
+ end
34
+
35
+ # The marker case is preserved verbatim ("Annex" vs "ANNEX").
36
+ def render_annex(id)
37
+ rendered = "S-#{id.base.number} #{id.annex_form}"
38
+ rendered << " #{id.letter}" if id.letter
39
+ rendered << " #{id.edition}" if id.edition
40
+ rendered
41
+ end
42
+ end
43
+ end
44
+ end