relaton 3.1.8 → 3.1.9
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/relaton/cli/index_site_generator.rb +19 -5
- data/lib/relaton/core/request_error.rb +7 -0
- data/lib/relaton/db/registry.rb +1 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/data_fetcher.rb +12 -2
- data/lib/relaton/w3c/safe_realize.rb +35 -3
- data/lib/relaton/wmo/bibdata.rb +8 -0
- data/lib/relaton/wmo/bibitem.rb +8 -0
- data/lib/relaton/wmo/bibliography.rb +86 -0
- data/lib/relaton/wmo/docidentifier.rb +41 -0
- data/lib/relaton/wmo/doctype.rb +17 -0
- data/lib/relaton/wmo/ext.rb +23 -0
- data/lib/relaton/wmo/item.rb +15 -0
- data/lib/relaton/wmo/item_base.rb +18 -0
- data/lib/relaton/wmo/item_data.rb +6 -0
- data/lib/relaton/wmo/processor.rb +45 -0
- data/lib/relaton/wmo/util.rb +8 -0
- data/lib/relaton/wmo.rb +41 -0
- data/lib/relaton.rb +1 -0
- metadata +18 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ea394ab28844cd3cd3a8bf4fb5050801ca09e7470f12f41ac4e3c2de5819c5b
|
|
4
|
+
data.tar.gz: b68f5acb575773b322524d63a4c3957f07b97b96f5f38fcfa0e17303cb1c1a8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e502491df55e172406e8cf02c7e0fd51557ec9d1d9a897f903846151cf782a2fef6bc56f52dbd155e8944af0a0c0f27a48d6e4193fb2b0c8ef14f6de2f2dcd61
|
|
7
|
+
data.tar.gz: d0ed43395a6bde95476b75856c57b57913823d204eabdc94c752ff3dee4e1bc82972c93a3dcd8eda21dc83966e66c7d13818a2657b53bafa6c3bc999485bd6ec
|
|
@@ -378,9 +378,19 @@ module Relaton
|
|
|
378
378
|
end
|
|
379
379
|
end
|
|
380
380
|
|
|
381
|
-
#
|
|
381
|
+
# Documents no row could identify: `add` leaves id_hash nil when
|
|
382
|
+
# neither a pubid parse nor a committed-index row covers the file.
|
|
383
|
+
# (A derived alias pruned by `indexed_rows` because another document
|
|
384
|
+
# owns its spelling is NOT a skip — its id_hash is present and the
|
|
385
|
+
# primary row serves the file.)
|
|
382
386
|
def skipped_count
|
|
383
|
-
count
|
|
387
|
+
@rows.count { |row| row.id_hash.nil? }
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# The files behind `skipped_count`.
|
|
391
|
+
def skipped_files
|
|
392
|
+
@rows.select { |row| row.id_hash.nil? }
|
|
393
|
+
.map(&:file).uniq.sort
|
|
384
394
|
end
|
|
385
395
|
|
|
386
396
|
# Rows bucketed by shard, in deterministic (key, rendered) order;
|
|
@@ -767,9 +777,13 @@ module Relaton
|
|
|
767
777
|
),
|
|
768
778
|
)
|
|
769
779
|
if machine.skipped_count.positive?
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
780
|
+
raise Relaton::IndexBuildError,
|
|
781
|
+
"Machine index build: #{machine.skipped_count} of " \
|
|
782
|
+
"#{machine.count} document(s) could not be indexed — neither " \
|
|
783
|
+
"a pubid parse of the printed docid nor a committed-index row " \
|
|
784
|
+
"covers them, so no fetch could ever find them: " \
|
|
785
|
+
"#{machine.skipped_files.join(', ')}. Fix the records' " \
|
|
786
|
+
"docidentifier or the flavor grammar, then rebuild."
|
|
773
787
|
end
|
|
774
788
|
machine.shard_count
|
|
775
789
|
end
|
|
@@ -49,6 +49,13 @@ module Relaton
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
# `relaton index` could not build machine-index rows for some documents:
|
|
53
|
+
# neither a pubid parse of the printed docid nor a committed-index row
|
|
54
|
+
# covers them, so those documents would be invisible to every fetch. The
|
|
55
|
+
# build fails (the 2026-11-23 adobe drop: 11 records lost from a published
|
|
56
|
+
# index with only a log warning) instead of publishing a partial index.
|
|
57
|
+
class IndexBuildError < Error; end
|
|
58
|
+
|
|
52
59
|
module Core
|
|
53
60
|
RequestError = Relaton::RequestError
|
|
54
61
|
end
|
data/lib/relaton/db/registry.rb
CHANGED
data/lib/relaton/version.rb
CHANGED
|
@@ -149,6 +149,7 @@ module Relaton
|
|
|
149
149
|
index.save
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
+
Util.info "Crawl done: #{pacing_summary}."
|
|
152
153
|
report_errors
|
|
153
154
|
end
|
|
154
155
|
|
|
@@ -167,8 +168,15 @@ module Relaton
|
|
|
167
168
|
raise CrawlIncompleteError,
|
|
168
169
|
"crawl is rate-limited: gave up after " \
|
|
169
170
|
"#{rounds} consecutive backoffs " \
|
|
170
|
-
"(#{SafeRealize.governor.throttle_count} rate-limited responses
|
|
171
|
-
"refusing to save a partial dataset"
|
|
171
|
+
"(#{SafeRealize.governor.throttle_count} rate-limited responses, " \
|
|
172
|
+
"#{pacing_summary}); refusing to save a partial dataset"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# How many requests went through the shared pacer, and at what gap: the
|
|
176
|
+
# rate api.w3.org saw, for the abort message and the run log.
|
|
177
|
+
def pacing_summary
|
|
178
|
+
pacer = SafeRealize.pacer
|
|
179
|
+
"#{pacer.requests} requests paced at a #{pacer.gap} s gap"
|
|
172
180
|
end
|
|
173
181
|
|
|
174
182
|
# The per-resource counterpart to guard_complete_pagination: pagination can
|
|
@@ -195,6 +203,7 @@ module Relaton
|
|
|
195
203
|
# link so the worker can hand it back to realize as the parent_resource.
|
|
196
204
|
#
|
|
197
205
|
def enqueue_specs(queue)
|
|
206
|
+
SafeRealize.pacer.wait
|
|
198
207
|
specs = client.specifications(embed: true)
|
|
199
208
|
expected_pages = specs.pages
|
|
200
209
|
last_page = nil
|
|
@@ -412,6 +421,7 @@ module Relaton
|
|
|
412
421
|
attempt = 0
|
|
413
422
|
begin
|
|
414
423
|
SafeRealize.governor.wait
|
|
424
|
+
SafeRealize.pacer.wait
|
|
415
425
|
page = client.specifications(embed: true, page: number)
|
|
416
426
|
SafeRealize.governor.succeeded!
|
|
417
427
|
page
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "concurrent/map"
|
|
2
|
+
require_relative "../core/pacer"
|
|
2
3
|
require_relative "governor"
|
|
3
4
|
|
|
4
5
|
module Relaton
|
|
@@ -24,6 +25,16 @@ module Relaton
|
|
|
24
25
|
# href monopolise a worker.
|
|
25
26
|
THROTTLE_ATTEMPTS = 3
|
|
26
27
|
|
|
28
|
+
# Minimum seconds between request starts across the whole worker pool.
|
|
29
|
+
# api.w3.org publishes its limit as 6000 requests per IP every 10 minutes
|
|
30
|
+
# (https://api.w3.org/doc), i.e. 10 req/s on average. Before the pacer the
|
|
31
|
+
# crawl was held only by its worker count, so its rate followed the host's
|
|
32
|
+
# latency, and on 2026-11-19, -20 and -22 it went over that budget and was
|
|
33
|
+
# banned (relaton-data-w3c run 45067048102). 0.12 s is ~8.3 req/s, 5000
|
|
34
|
+
# per 10 minutes: the headroom covers lutaml-hal's inner retries, which
|
|
35
|
+
# do not pass through here. RELATON_W3C_GAP overrides it; 0 disables it.
|
|
36
|
+
DEFAULT_GAP = 0.12
|
|
37
|
+
|
|
27
38
|
# Hrefs that failed terminally — one map shared by every includer
|
|
28
39
|
# (DataFetcher and DataParser) since a broken resource is broken for the
|
|
29
40
|
# whole crawl. Initialized eagerly (at load, single-threaded) so the
|
|
@@ -42,17 +53,32 @@ module Relaton
|
|
|
42
53
|
|
|
43
54
|
class << self
|
|
44
55
|
attr_reader :skipped, :throttled
|
|
45
|
-
attr_accessor :governor
|
|
56
|
+
attr_accessor :governor, :pacer
|
|
46
57
|
|
|
47
|
-
# Start a crawl (or a spec example) from a clean slate. The governor
|
|
48
|
-
# reset in place, so a reference taken before the reset
|
|
58
|
+
# Start a crawl (or a spec example) from a clean slate. The governor and
|
|
59
|
+
# the pacer are reset in place, so a reference taken before the reset
|
|
60
|
+
# stays live. The gap is read again, like the governor's env knobs.
|
|
49
61
|
def reset!
|
|
50
62
|
@skipped.clear
|
|
51
63
|
@throttled.clear
|
|
52
64
|
@governor.reset!
|
|
65
|
+
@pacer.gap = gap
|
|
66
|
+
@pacer.reset!
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @return [Float] RELATON_W3C_GAP, or DEFAULT_GAP when it is unset,
|
|
70
|
+
# unreadable or negative. "0" is accepted and disables pacing.
|
|
71
|
+
def gap
|
|
72
|
+
value = ENV["RELATON_W3C_GAP"].to_s.strip
|
|
73
|
+
value.match?(/\A\d+(\.\d+)?\z/) ? value.to_f : DEFAULT_GAP
|
|
53
74
|
end
|
|
54
75
|
end
|
|
55
76
|
|
|
77
|
+
# Shared by every worker: the pool between them starts at most one
|
|
78
|
+
# request per gap (see Core::Pacer). Built after `class << self`, which
|
|
79
|
+
# defines `gap`.
|
|
80
|
+
@pacer = Core::Pacer.new(gap: gap)
|
|
81
|
+
|
|
56
82
|
# @param parent_resource [Object, nil] the index/page the link came from.
|
|
57
83
|
# When the page was fetched with `embed: true`, its inlined `_embedded`
|
|
58
84
|
# payload lets the link realize from memory instead of issuing an HTTP
|
|
@@ -78,6 +104,12 @@ module Relaton
|
|
|
78
104
|
begin
|
|
79
105
|
attempt += 1
|
|
80
106
|
SafeRealize.governor.wait
|
|
107
|
+
# Every realize takes a slot, an embedded one too. lutaml-hal serves
|
|
108
|
+
# it from the page only when the page's `_embedded` holds an exact
|
|
109
|
+
# href match; otherwise it falls through to a real GET, and an
|
|
110
|
+
# unpaced fall-through on every spec is the rate that got the crawl
|
|
111
|
+
# banned. The cost is one gap per specification, ~3 minutes a run.
|
|
112
|
+
SafeRealize.pacer.wait
|
|
81
113
|
realized = obj.realize(parent_resource: parent_resource)
|
|
82
114
|
# Only a realize that actually went to the network says anything about
|
|
83
115
|
# the limiter. With a parent_resource, lutaml-hal serves the object
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Wmo
|
|
5
|
+
# Retrieval front-end for the WMO flavor. Parses a reference with
|
|
6
|
+
# Pubid::Wmo, looks it up in the `relaton-data-wmo` index, fetches the
|
|
7
|
+
# matching YAML record, and deserializes it into a Relaton::Wmo::Item.
|
|
8
|
+
# Modelled on Relaton::Adobe::Bibliography (pubid-backed, index via
|
|
9
|
+
# `pubid_class`); WMO identifiers carry no edition year, so each
|
|
10
|
+
# reference maps to a single record.
|
|
11
|
+
module Bibliography
|
|
12
|
+
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-wmo/main/".freeze
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
# Search for a WMO publication by its identifier.
|
|
16
|
+
#
|
|
17
|
+
# @param text [String, Pubid::Wmo::Identifier] the WMO reference
|
|
18
|
+
# (e.g. "WMO-No. 8", "WMO/TD-No. 1551", "GAW Report No. 234")
|
|
19
|
+
# @param _year [String, nil] unused (WMO ids carry no edition year)
|
|
20
|
+
# @param _opts [Hash] options (unused)
|
|
21
|
+
# @return [Relaton::Wmo::Item, nil]
|
|
22
|
+
def search(text, _year = nil, _opts = {})
|
|
23
|
+
pubid = pubid_for(text) or return
|
|
24
|
+
Util.info "Fetching from Relaton repository ...", key: pubid.to_s
|
|
25
|
+
# Numbered series narrow via binary search; series with no
|
|
26
|
+
# number pass nil to scan (Relaton::Index::Type#search returns
|
|
27
|
+
# all rows for a nil id, then applies the block).
|
|
28
|
+
query = pubid.root.number ? pubid : nil
|
|
29
|
+
row = index.search(query) { |r| pubid_match?(r[:id], pubid) }.first
|
|
30
|
+
unless row
|
|
31
|
+
Util.info "Not found.", key: pubid.to_s
|
|
32
|
+
return
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
uri = URI("#{ENDPOINT}#{row[:file]}")
|
|
36
|
+
resp = Net::HTTP.get_response uri
|
|
37
|
+
unless resp.code == "200"
|
|
38
|
+
raise Relaton::RequestError, "Could not access #{uri}: HTTP #{resp.code}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
item = Relaton::Wmo::Item.from_yaml resp.body
|
|
42
|
+
Util.info "Found: `#{item.docidentifier.first&.content}`", key: pubid.to_s
|
|
43
|
+
item.tap { |i| i.fetched = Date.today.to_s }
|
|
44
|
+
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
|
45
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
46
|
+
Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
|
|
47
|
+
Errno::ETIMEDOUT => e
|
|
48
|
+
raise Relaton::RequestError, "Could not access #{uri}: #{e.message}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get(ref, year = nil, opts = {})
|
|
52
|
+
search(ref, year, opts)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
# Coerce a reference to a Pubid::Wmo identifier. A non-canonical
|
|
58
|
+
# string is a graceful miss (logged, returns nil) rather than a
|
|
59
|
+
# raised Parslet error — the ref reached here only because it
|
|
60
|
+
# matched the flavor's prefix regex.
|
|
61
|
+
def pubid_for(text)
|
|
62
|
+
return text unless text.is_a?(String)
|
|
63
|
+
|
|
64
|
+
::Pubid::Wmo.parse(text)
|
|
65
|
+
rescue StandardError
|
|
66
|
+
Util.info "Not found.", key: text
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def index
|
|
71
|
+
Relaton::Index.find_or_create(
|
|
72
|
+
:wmo,
|
|
73
|
+
pages_url: PAGES_URL,
|
|
74
|
+
pubid_class: ::Pubid::Wmo::Identifier,
|
|
75
|
+
)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Identity match on the human render: both `row_id` and `query`
|
|
79
|
+
# are Pubid::Wmo identifiers rendering to their canonical forms.
|
|
80
|
+
def pubid_match?(row_id, query)
|
|
81
|
+
row_id.to_s == query.to_s
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Wmo
|
|
3
|
+
# Structured WMO document identifier. The docid string is the canonical
|
|
4
|
+
# form (e.g. "WMO-No. 8", "WMO/TD-No. 1551", "JCOMM Technical Report
|
|
5
|
+
# No. 5", "GAW Report No. 234"); its `content` is soft-parsed into a
|
|
6
|
+
# Pubid::Wmo identifier kept in `@pubid`, mirroring
|
|
7
|
+
# Relaton::Adobe::Docidentifier.
|
|
8
|
+
#
|
|
9
|
+
# Parsing is soft: a non-WMO string (e.g. a page title) leaves `@pubid`
|
|
10
|
+
# nil rather than raising, so the plain `content` string still
|
|
11
|
+
# round-trips.
|
|
12
|
+
class Docidentifier < Bib::Docidentifier
|
|
13
|
+
attr_reader :pubid
|
|
14
|
+
|
|
15
|
+
def initialize(attrs = {}, options = {})
|
|
16
|
+
pubid = attrs.is_a?(Hash) ? attrs.delete(:pubid) : nil
|
|
17
|
+
attrs[:content] ||= pubid.to_s if pubid
|
|
18
|
+
super
|
|
19
|
+
@pubid = pubid if pubid
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def content=(value)
|
|
23
|
+
super
|
|
24
|
+
@pubid = ::Pubid::Wmo.parse(value) if value
|
|
25
|
+
rescue StandardError
|
|
26
|
+
@pubid = nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# WMO identifiers carry no part/date/all-parts component (edition
|
|
30
|
+
# and volume live on the record, not the id), so the base class's
|
|
31
|
+
# abstract mutation hooks are safe no-ops: they keep
|
|
32
|
+
# `Bib::ItemData#to_most_recent_reference` / `#to_all_parts` from
|
|
33
|
+
# raising on WMO items, and never change the rendered `content`.
|
|
34
|
+
def remove_part!; end
|
|
35
|
+
|
|
36
|
+
def remove_date!; end
|
|
37
|
+
|
|
38
|
+
def to_all_parts!; end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Wmo
|
|
3
|
+
# WMO publication document types. The value is carried in the
|
|
4
|
+
# inherited `content` attribute. The list mirrors the series the
|
|
5
|
+
# dataset tracks (the Pubid::Wmo series heads) plus the S-100
|
|
6
|
+
# product specifications WMO publishes.
|
|
7
|
+
class Doctype < Bib::Doctype
|
|
8
|
+
TYPES = %w[
|
|
9
|
+
technical-regulations
|
|
10
|
+
technical-document
|
|
11
|
+
technical-report
|
|
12
|
+
report
|
|
13
|
+
specification
|
|
14
|
+
].freeze
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Wmo
|
|
3
|
+
# WMO bibliographic item extension. Adds WMO-specific structured
|
|
4
|
+
# metadata on top of the shared Relaton::Bib::Ext so the fields
|
|
5
|
+
# round-trip through both XML and YAML without per-repo merge hacks.
|
|
6
|
+
# Doctype is referenced lazily via autoload from lib/relaton/wmo.rb.
|
|
7
|
+
class Ext < Bib::Ext
|
|
8
|
+
attribute :doctype, :string
|
|
9
|
+
attribute :urn, :string
|
|
10
|
+
attribute :webpage, :string
|
|
11
|
+
|
|
12
|
+
xml do
|
|
13
|
+
map_element "urn", to: :urn
|
|
14
|
+
map_element "webpage", to: :webpage
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
key_value do
|
|
18
|
+
map_element "urn", to: :urn
|
|
19
|
+
map_element "webpage", to: :webpage
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Wmo
|
|
3
|
+
# Wmo bibliographic item. Re-declares +ext+ to use the typed Ext
|
|
4
|
+
# subclass so Wmo-specific fields round-trip natively. Sub-files
|
|
5
|
+
# (ItemData, Ext, Docidentifier) are loaded lazily via the autoload
|
|
6
|
+
# entries declared in lib/relaton/wmo.rb.
|
|
7
|
+
class Item < Bib::Item
|
|
8
|
+
model ItemData
|
|
9
|
+
|
|
10
|
+
attribute :ext, Ext
|
|
11
|
+
attribute :docidentifier, Docidentifier, collection: true,
|
|
12
|
+
initialize_empty: true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Wmo
|
|
3
|
+
class ItemBase < Lutaml::Model::Serializable
|
|
4
|
+
include Bib::NamespaceHelper
|
|
5
|
+
|
|
6
|
+
attr_accessor :type
|
|
7
|
+
|
|
8
|
+
model ItemData
|
|
9
|
+
|
|
10
|
+
instance_exec(&Bib::ItemShared::ATTRIBUTES)
|
|
11
|
+
|
|
12
|
+
xml do
|
|
13
|
+
map_attribute "type", to: :type
|
|
14
|
+
instance_exec(&Bib::ItemShared::XML_BODY)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative "../core/processor"
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Wmo
|
|
5
|
+
# Relaton processor for the WMO flavor. Registered by
|
|
6
|
+
# Relaton::Registry when the unified gem loads. Supports
|
|
7
|
+
# `relaton fetch wmo ...` once the relaton-data-wmo dataset publishes
|
|
8
|
+
# its index.
|
|
9
|
+
class Processor < Core::Processor
|
|
10
|
+
def initialize
|
|
11
|
+
@short = :relaton_wmo
|
|
12
|
+
@prefix = "WMO"
|
|
13
|
+
# The series heads the grammar carries (pubid#763 + the widening
|
|
14
|
+
# round). Bare S-numbers deliberately lead NO prefix: an S-100
|
|
15
|
+
# lexical form is the shared shape of IHO and WMO, and neither
|
|
16
|
+
# flavor owns the routing (pubid#469).
|
|
17
|
+
@defaultprefix = %r{^(?:WMO-No\.|WMO/TD-No\.|JCOMM|GAW)\s}
|
|
18
|
+
@pubid_identifier = :Wmo # Db cache key
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def get(code, date, opts)
|
|
22
|
+
require_relative "../wmo"
|
|
23
|
+
Bibliography.get(code, date, opts)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# `Bibliography.get` reads a reference pubid cannot parse as a miss
|
|
27
|
+
# (`pubid_for`), so it gets no key here either: it is not cached.
|
|
28
|
+
def cache_pubid(ref)
|
|
29
|
+
super
|
|
30
|
+
rescue StandardError
|
|
31
|
+
nil
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def from_xml(xml)
|
|
35
|
+
require_relative "../wmo"
|
|
36
|
+
Item.from_xml xml
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def from_yaml(yaml)
|
|
40
|
+
require_relative "../wmo"
|
|
41
|
+
Item.from_yaml(yaml)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/relaton/wmo.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "bib"
|
|
4
|
+
require_relative "index"
|
|
5
|
+
require "pubid"
|
|
6
|
+
require_relative "version"
|
|
7
|
+
|
|
8
|
+
# Relaton::Wmo is the World Meteorological Organization flavor of the
|
|
9
|
+
# unified relaton gem: the WMO-No. series, WMO/TD technical documents,
|
|
10
|
+
# JCOMM technical reports and GAW reports, keyed by Pubid::Wmo
|
|
11
|
+
# (pubid#763 + the widening round). Adds typed Ext fields (doctype, urn,
|
|
12
|
+
# webpage) so they round-trip natively through YAML and XML.
|
|
13
|
+
module Relaton
|
|
14
|
+
module Wmo
|
|
15
|
+
INDEXFILE = "index-v2".freeze
|
|
16
|
+
# The machine index on the data repo's Pages site (relaton#206) —
|
|
17
|
+
# manifest + per-shard rows read by the consumer's index; the zip stays
|
|
18
|
+
# on the Pages site for the whole-index retry on a miss.
|
|
19
|
+
PAGES_URL = "https://relaton.github.io/relaton-data-wmo/"
|
|
20
|
+
|
|
21
|
+
class Error < StandardError; end
|
|
22
|
+
|
|
23
|
+
autoload :Doctype, "relaton/wmo/doctype"
|
|
24
|
+
autoload :Ext, "relaton/wmo/ext"
|
|
25
|
+
autoload :ItemData, "relaton/wmo/item_data"
|
|
26
|
+
autoload :ItemBase, "relaton/wmo/item_base"
|
|
27
|
+
autoload :Item, "relaton/wmo/item"
|
|
28
|
+
autoload :Bibitem, "relaton/wmo/bibitem"
|
|
29
|
+
autoload :Bibdata, "relaton/wmo/bibdata"
|
|
30
|
+
autoload :Docidentifier, "relaton/wmo/docidentifier"
|
|
31
|
+
autoload :Util, "relaton/wmo/util"
|
|
32
|
+
autoload :Bibliography, "relaton/wmo/bibliography"
|
|
33
|
+
autoload :Processor, "relaton/wmo/processor"
|
|
34
|
+
|
|
35
|
+
# Returns hash of XML grammar
|
|
36
|
+
# @return [String]
|
|
37
|
+
def self.grammar_hash
|
|
38
|
+
Digest::MD5.hexdigest Relaton::VERSION
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/relaton.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.
|
|
4
|
+
version: 3.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -310,14 +310,14 @@ dependencies:
|
|
|
310
310
|
requirements:
|
|
311
311
|
- - "~>"
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
|
-
version: 0.3.
|
|
313
|
+
version: 0.3.11
|
|
314
314
|
type: :runtime
|
|
315
315
|
prerelease: false
|
|
316
316
|
version_requirements: !ruby/object:Gem::Requirement
|
|
317
317
|
requirements:
|
|
318
318
|
- - "~>"
|
|
319
319
|
- !ruby/object:Gem::Version
|
|
320
|
-
version: 0.3.
|
|
320
|
+
version: 0.3.11
|
|
321
321
|
- !ruby/object:Gem::Dependency
|
|
322
322
|
name: htmlentities
|
|
323
323
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -520,14 +520,14 @@ dependencies:
|
|
|
520
520
|
requirements:
|
|
521
521
|
- - "~>"
|
|
522
522
|
- !ruby/object:Gem::Version
|
|
523
|
-
version: 2.0.
|
|
523
|
+
version: 2.0.50
|
|
524
524
|
type: :runtime
|
|
525
525
|
prerelease: false
|
|
526
526
|
version_requirements: !ruby/object:Gem::Requirement
|
|
527
527
|
requirements:
|
|
528
528
|
- - "~>"
|
|
529
529
|
- !ruby/object:Gem::Version
|
|
530
|
-
version: 2.0.
|
|
530
|
+
version: 2.0.50
|
|
531
531
|
- !ruby/object:Gem::Dependency
|
|
532
532
|
name: yeptris
|
|
533
533
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -1468,6 +1468,18 @@ files:
|
|
|
1468
1468
|
- lib/relaton/w3c/pubid.rb
|
|
1469
1469
|
- lib/relaton/w3c/safe_realize.rb
|
|
1470
1470
|
- lib/relaton/w3c/util.rb
|
|
1471
|
+
- lib/relaton/wmo.rb
|
|
1472
|
+
- lib/relaton/wmo/bibdata.rb
|
|
1473
|
+
- lib/relaton/wmo/bibitem.rb
|
|
1474
|
+
- lib/relaton/wmo/bibliography.rb
|
|
1475
|
+
- lib/relaton/wmo/docidentifier.rb
|
|
1476
|
+
- lib/relaton/wmo/doctype.rb
|
|
1477
|
+
- lib/relaton/wmo/ext.rb
|
|
1478
|
+
- lib/relaton/wmo/item.rb
|
|
1479
|
+
- lib/relaton/wmo/item_base.rb
|
|
1480
|
+
- lib/relaton/wmo/item_data.rb
|
|
1481
|
+
- lib/relaton/wmo/processor.rb
|
|
1482
|
+
- lib/relaton/wmo/util.rb
|
|
1471
1483
|
- lib/relaton/xsf.rb
|
|
1472
1484
|
- lib/relaton/xsf/README.adoc
|
|
1473
1485
|
- lib/relaton/xsf/bibdata.rb
|