relaton 3.0.0.pre.alpha.5 → 3.0.0.pre.alpha.6
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/3gpp/bibliography.rb +19 -6
- data/lib/relaton/3gpp/processor.rb +6 -0
- data/lib/relaton/bib/item_data.rb +14 -0
- data/lib/relaton/bipm/bibliography.rb +24 -21
- data/lib/relaton/bsi/bibliography.rb +26 -23
- data/lib/relaton/calconnect/bibliography.rb +6 -6
- data/lib/relaton/calconnect/hit_collection.rb +4 -1
- data/lib/relaton/ccsds/bibliography.rb +15 -10
- data/lib/relaton/ccsds/hit_collection.rb +1 -1
- data/lib/relaton/ccsds/processor.rb +3 -2
- data/lib/relaton/cen/bibliography.rb +27 -24
- data/lib/relaton/cie/bibliography.rb +11 -9
- data/lib/relaton/cie/scrapper.rb +15 -8
- data/lib/relaton/core/processor.rb +61 -8
- data/lib/relaton/core/request_error.rb +21 -3
- data/lib/relaton/db/cache.rb +49 -19
- data/lib/relaton/db/cache_entry.rb +9 -0
- data/lib/relaton/db/registry.rb +128 -28
- data/lib/relaton/db.rb +162 -48
- data/lib/relaton/ecma/bibliography.rb +18 -13
- data/lib/relaton/etsi/bibliography.rb +8 -7
- data/lib/relaton/gb/bibliography.rb +20 -12
- data/lib/relaton/iala/bibliography.rb +15 -12
- data/lib/relaton/iana/bibliography.rb +12 -12
- data/lib/relaton/iana/parser.rb +5 -2
- data/lib/relaton/iec/bibliography.rb +18 -7
- data/lib/relaton/iec/processor.rb +5 -0
- data/lib/relaton/ieee/bibliography.rb +19 -13
- data/lib/relaton/ieee/processor.rb +16 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +2 -2
- data/lib/relaton/ietf/bibliography.rb +11 -9
- data/lib/relaton/ietf/scraper.rb +5 -4
- data/lib/relaton/iso/bibliography.rb +11 -9
- data/lib/relaton/itu/bibliography.rb +9 -4
- data/lib/relaton/jis/bibliography.rb +22 -11
- data/lib/relaton/nist/bibliography.rb +25 -21
- data/lib/relaton/oasis/bibliography.rb +16 -13
- data/lib/relaton/ogc/bibliography.rb +15 -14
- data/lib/relaton/ogc/hit_collection.rb +9 -7
- data/lib/relaton/ogc/processor.rb +7 -1
- data/lib/relaton/omg/bibliography.rb +9 -9
- data/lib/relaton/omg/scraper.rb +3 -2
- data/lib/relaton/plateau/bibliography.rb +9 -7
- data/lib/relaton/plateau/hit_collection.rb +2 -1
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/xsf/bibliography.rb +11 -6
- metadata +18 -4
|
@@ -3,36 +3,37 @@ module Relaton
|
|
|
3
3
|
module Bibliography
|
|
4
4
|
extend self
|
|
5
5
|
|
|
6
|
-
# @param
|
|
6
|
+
# @param ref [String, Pubid::Ogc::Identifier]
|
|
7
7
|
# @param year [String, nil]
|
|
8
8
|
# @return [Relaton::Ogc::HitCollection]
|
|
9
|
-
def search(
|
|
10
|
-
code =
|
|
9
|
+
def search(ref, year = nil, _opts = {})
|
|
10
|
+
code = ref.is_a?(String) ? ref.sub(/^OGC\s/, "") : ref
|
|
11
11
|
HitCollection.new(code, year).find
|
|
12
12
|
rescue Faraday::ConnectionFailed, Faraday::SSLError
|
|
13
13
|
raise Relaton::RequestError, HitCollection::ENDPOINT
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
# @param
|
|
16
|
+
# @param ref [String, Pubid::Ogc::Identifier] a reference, or its parse
|
|
17
|
+
# from Relaton::Db (relaton#205), which is used as it is
|
|
17
18
|
# @param year [String, nil]
|
|
18
19
|
# @param opts [Hash]
|
|
19
20
|
# @return [Relaton::Ogc::ItemData, nil]
|
|
20
|
-
def get(
|
|
21
|
-
result = bib_search_filter(
|
|
21
|
+
def get(ref, year = nil, opts = {})
|
|
22
|
+
result = bib_search_filter(ref, year, opts) || (return nil)
|
|
22
23
|
ret = bib_results_filter(result, year)
|
|
23
24
|
if ret[:ret]
|
|
24
|
-
Util.info "Found: `#{ret[:ret].docidentifier.first.content}`", key:
|
|
25
|
+
Util.info "Found: `#{ret[:ret].docidentifier.first.content}`", key: ref.to_s
|
|
25
26
|
ret[:ret]
|
|
26
27
|
else
|
|
27
|
-
fetch_ref_err(
|
|
28
|
+
fetch_ref_err(ref, year, ret[:years])
|
|
28
29
|
end
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
private
|
|
32
33
|
|
|
33
|
-
def bib_search_filter(
|
|
34
|
-
Util.info "Fetching from Relaton repository ...", key:
|
|
35
|
-
search(
|
|
34
|
+
def bib_search_filter(ref, year, opts)
|
|
35
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
36
|
+
search(ref, year, opts)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def bib_results_filter(result, year)
|
|
@@ -51,11 +52,11 @@ module Relaton
|
|
|
51
52
|
{ years: missed_years }
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def fetch_ref_err(
|
|
55
|
-
Util.info "Not found.", key:
|
|
55
|
+
def fetch_ref_err(ref, year, missed_years)
|
|
56
|
+
Util.info "Not found.", key: ref.to_s
|
|
56
57
|
unless missed_years.empty?
|
|
57
58
|
Util.info "There was no match for `#{year}`, though there " \
|
|
58
|
-
"were matches found for `#{missed_years.join('`, `')}`.", key:
|
|
59
|
+
"were matches found for `#{missed_years.join('`, `')}`.", key: ref.to_s
|
|
59
60
|
end
|
|
60
61
|
nil
|
|
61
62
|
end
|
|
@@ -8,7 +8,7 @@ module Relaton
|
|
|
8
8
|
|
|
9
9
|
# @return [self]
|
|
10
10
|
def find
|
|
11
|
-
return self if ref.nil? || ref.empty?
|
|
11
|
+
return self if ref.nil? || ref.to_s.empty?
|
|
12
12
|
|
|
13
13
|
row = best_match ref
|
|
14
14
|
return self unless row
|
|
@@ -50,7 +50,7 @@ module Relaton
|
|
|
50
50
|
# `<nnn>` field alone, so one bucket holds every year that reused the
|
|
51
51
|
# number (`05-007` and `17-007` share bucket `007`).
|
|
52
52
|
#
|
|
53
|
-
# @param
|
|
53
|
+
# @param ref [String, Pubid::Ogc::Identifier]
|
|
54
54
|
# @return [Hash, nil]
|
|
55
55
|
#
|
|
56
56
|
# The substring-scan fallback this used to take when parsing failed is
|
|
@@ -59,8 +59,8 @@ module Relaton
|
|
|
59
59
|
# ids, so an ambiguous reference silently resolved to whichever row
|
|
60
60
|
# sorted first, instead of telling the caller the reference is not an
|
|
61
61
|
# identifier. ecma, w3c and xsf never had one.
|
|
62
|
-
def best_match(
|
|
63
|
-
pubid = parse_ref
|
|
62
|
+
def best_match(ref)
|
|
63
|
+
pubid = parse_ref ref
|
|
64
64
|
rows = index.search(pubid)
|
|
65
65
|
rows.max_by { |r| [revision_key(r[:id].revision), r[:file]] }
|
|
66
66
|
end
|
|
@@ -93,7 +93,7 @@ module Relaton
|
|
|
93
93
|
# lowercases the revision, so `OGC 19-025r1`, `19-025r1`, `11-038R2` and
|
|
94
94
|
# the revision-less `16-079` all parse without normalization here.
|
|
95
95
|
#
|
|
96
|
-
# @param
|
|
96
|
+
# @param ref [String, Pubid::Ogc::Identifier] a pubid is returned as it is
|
|
97
97
|
# @return [Pubid::Ogc::Identifier, nil]
|
|
98
98
|
#
|
|
99
99
|
# An unrecognized reference **raises**; like ISO, ETSI and 3GPP we let it
|
|
@@ -103,8 +103,10 @@ module Relaton
|
|
|
103
103
|
# logs it through the `StandardError` arm at `lib/relaton/db.rb:122`.
|
|
104
104
|
# Rescuing here would collapse "this identifier is malformed" into "no
|
|
105
105
|
# such document", leaving a caller unable to tell them apart.
|
|
106
|
-
def parse_ref(
|
|
107
|
-
|
|
106
|
+
def parse_ref(ref)
|
|
107
|
+
return ref unless ref.is_a?(String)
|
|
108
|
+
|
|
109
|
+
::Pubid::Ogc::Identifier.parse ref.strip
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
end
|
|
@@ -21,10 +21,16 @@ module Relaton
|
|
|
21
21
|
Bibliography.get(code, date, opts)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
# OGC documents print their identifier without the `OGC ` token
|
|
25
|
+
# (`19-025r1`).
|
|
26
|
+
def bare_identifiers?
|
|
27
|
+
true
|
|
28
|
+
end
|
|
29
|
+
|
|
24
30
|
# The `year` argument filters by publication year, but an OGC pubid's
|
|
25
31
|
# `year` is the year in the document number (`19` in `OGC 19-025r1`),
|
|
26
32
|
# so it cannot be folded into the key: such a query is not cached.
|
|
27
|
-
def cache_key(ref, year, opts)
|
|
33
|
+
def cache_key(ref, year, opts, parsed = nil)
|
|
28
34
|
year ? nil : super
|
|
29
35
|
end
|
|
30
36
|
|
|
@@ -6,23 +6,23 @@ module Relaton
|
|
|
6
6
|
module Bibliography
|
|
7
7
|
extend self
|
|
8
8
|
|
|
9
|
-
# @param
|
|
9
|
+
# @param ref [String, Pubid::Omg::Identifier] the OMG standard reference
|
|
10
10
|
# @return [Relaton::Omg::Item]
|
|
11
|
-
def search(
|
|
12
|
-
Scraper.scrape_page
|
|
11
|
+
def search(ref)
|
|
12
|
+
Scraper.scrape_page ref
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
# @param
|
|
15
|
+
# @param ref [String, Pubid::Omg::Identifier] the OMG standard reference
|
|
16
16
|
# @param year [String] the year the standard was published (optional)
|
|
17
17
|
# @param opts [Hash] options
|
|
18
18
|
# @return [Relaton::Omg::Item]
|
|
19
|
-
def get(
|
|
20
|
-
Util.info "Fetching from www.omg.org ...", key:
|
|
21
|
-
result = search
|
|
19
|
+
def get(ref, _year = nil, _opts = {})
|
|
20
|
+
Util.info "Fetching from www.omg.org ...", key: ref.to_s
|
|
21
|
+
result = search ref
|
|
22
22
|
if result
|
|
23
|
-
Util.info "Found: `#{result.docidentifier.first.content}`", key:
|
|
23
|
+
Util.info "Found: `#{result.docidentifier.first.content}`", key: ref.to_s
|
|
24
24
|
else
|
|
25
|
-
Util.info "Not found.", key:
|
|
25
|
+
Util.info "Not found.", key: ref.to_s
|
|
26
26
|
end
|
|
27
27
|
result
|
|
28
28
|
end
|
data/lib/relaton/omg/scraper.rb
CHANGED
|
@@ -19,12 +19,13 @@ module Relaton
|
|
|
19
19
|
@part = part
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
# @param ref [String] the OMG reference, e.g.
|
|
22
|
+
# @param ref [String, Pubid::Omg::Identifier] the OMG reference, e.g.
|
|
23
|
+
# "OMG UML 2.1.1 Superstructure", or its parse from Relaton::Db
|
|
23
24
|
# @return [Relaton::Omg::ItemData, nil] nil when the page is not found
|
|
24
25
|
# @raise [Pubid::Errors::ParseError] when the reference is not an OMG
|
|
25
26
|
# identifier
|
|
26
27
|
def self.scrape_page(ref)
|
|
27
|
-
pubid = ::Pubid::Omg::Identifier.parse(ref)
|
|
28
|
+
pubid = ref.is_a?(String) ? ::Pubid::Omg::Identifier.parse(ref) : ref
|
|
28
29
|
scraper = new(pubid.acronym, pubid.version, pubid.part)
|
|
29
30
|
doc = scraper.get_doc
|
|
30
31
|
return if doc.nil? || scraper.fetch_link.empty?
|
|
@@ -3,22 +3,24 @@ module Relaton
|
|
|
3
3
|
module Bibliography
|
|
4
4
|
extend self
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
# @param ref [String, Pubid::Plateau::Identifier] the reference, or the
|
|
7
|
+
# parse that Relaton::Db routed with (relaton#205)
|
|
8
|
+
def search(ref)
|
|
9
|
+
HitCollection.new(ref).find
|
|
8
10
|
end
|
|
9
11
|
|
|
10
12
|
# Only a transport failure is rescued, and it becomes the
|
|
11
13
|
# Relaton::RequestError that Relaton::Db retries. Anything else keeps
|
|
12
14
|
# its own class: an unrecognized reference raises Pubid::Errors::ParseError
|
|
13
15
|
# (relaton-cli reports it), and a bug keeps its backtrace.
|
|
14
|
-
def get(
|
|
15
|
-
Util.info "Fetching ...", key:
|
|
16
|
-
result = search(
|
|
16
|
+
def get(ref, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength
|
|
17
|
+
Util.info "Fetching ...", key: ref.to_s
|
|
18
|
+
result = search(ref).fetch_doc
|
|
17
19
|
if result
|
|
18
|
-
Util.info "Found `#{result.docidentifier.first.content}`", key:
|
|
20
|
+
Util.info "Found `#{result.docidentifier.first.content}`", key: ref.to_s
|
|
19
21
|
result
|
|
20
22
|
else
|
|
21
|
-
Util.warn "Not found.", key:
|
|
23
|
+
Util.warn "Not found.", key: ref.to_s
|
|
22
24
|
end
|
|
23
25
|
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
|
24
26
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
@@ -44,8 +44,9 @@ module Relaton
|
|
|
44
44
|
# (metanorma/pubid #269) — so search accepts both forms. An unrecognized
|
|
45
45
|
# reference raises; like ISO and 3GPP we let it propagate — relaton-cli
|
|
46
46
|
# rescues Pubid::Errors::Error. See lib/relaton/plateau/CLAUDE.md.
|
|
47
|
+
# Relaton::Db passes the reference already parsed (relaton#205).
|
|
47
48
|
def pubid_ref
|
|
48
|
-
@pubid_ref ||= ::Pubid::Plateau.parse(ref)
|
|
49
|
+
@pubid_ref ||= ref.is_a?(String) ? ::Pubid::Plateau.parse(ref) : ref
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
# A reference with no edition (`PLATEAU Handbook #00`, or any Technical
|
data/lib/relaton/version.rb
CHANGED
|
@@ -35,16 +35,18 @@ module Relaton
|
|
|
35
35
|
HitCollection.new(parse_ref(ref)).search
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
# @param ref [String, Pubid::Xsf::Identifier] the reference, or the
|
|
39
|
+
# parse that Relaton::Db routed with (relaton#205)
|
|
40
|
+
def get(ref, _year = nil, _opts = {})
|
|
41
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
42
|
+
result = search(ref)
|
|
41
43
|
if result.empty?
|
|
42
|
-
Util.info "Not found.", key:
|
|
44
|
+
Util.info "Not found.", key: ref.to_s
|
|
43
45
|
return
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
bib = result.first.item
|
|
47
|
-
Util.info "Found: `#{bib.docidentifier.first.content}`", key:
|
|
49
|
+
Util.info "Found: `#{bib.docidentifier.first.content}`", key: ref.to_s
|
|
48
50
|
bib
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -66,11 +68,14 @@ module Relaton
|
|
|
66
68
|
# Anything else raises -- see `.search`. `Pubid::Errors::ParseError`
|
|
67
69
|
# includes `Pubid::Errors::Error`, which is the class relaton-cli rescues.
|
|
68
70
|
#
|
|
69
|
-
# @param ref [String]
|
|
71
|
+
# @param ref [String, Pubid::Xsf::Identifier]
|
|
70
72
|
# @return [Pubid::Xsf::Identifier]
|
|
71
73
|
# @raise [Pubid::Errors::ParseError]
|
|
72
74
|
#
|
|
73
75
|
def parse_ref(ref)
|
|
76
|
+
# A parsed pubid comes from Relaton::Db (relaton#205); it is used as it is.
|
|
77
|
+
return ref unless ref.is_a?(String)
|
|
78
|
+
|
|
74
79
|
::Pubid::Xsf::Identifier.parse normalize_ref(ref)
|
|
75
80
|
end
|
|
76
81
|
|
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.0.0.pre.alpha.
|
|
4
|
+
version: 3.0.0.pre.alpha.6
|
|
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
|
+
date: 2026-10-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -428,14 +428,14 @@ dependencies:
|
|
|
428
428
|
requirements:
|
|
429
429
|
- - "~>"
|
|
430
430
|
- !ruby/object:Gem::Version
|
|
431
|
-
version: 2.0.0.pre.alpha.
|
|
431
|
+
version: 2.0.0.pre.alpha.21
|
|
432
432
|
type: :runtime
|
|
433
433
|
prerelease: false
|
|
434
434
|
version_requirements: !ruby/object:Gem::Requirement
|
|
435
435
|
requirements:
|
|
436
436
|
- - "~>"
|
|
437
437
|
- !ruby/object:Gem::Version
|
|
438
|
-
version: 2.0.0.pre.alpha.
|
|
438
|
+
version: 2.0.0.pre.alpha.21
|
|
439
439
|
- !ruby/object:Gem::Dependency
|
|
440
440
|
name: yeptris
|
|
441
441
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -450,6 +450,20 @@ dependencies:
|
|
|
450
450
|
- - ">="
|
|
451
451
|
- !ruby/object:Gem::Version
|
|
452
452
|
version: '0.4'
|
|
453
|
+
- !ruby/object:Gem::Dependency
|
|
454
|
+
name: relaton-render
|
|
455
|
+
requirement: !ruby/object:Gem::Requirement
|
|
456
|
+
requirements:
|
|
457
|
+
- - "~>"
|
|
458
|
+
- !ruby/object:Gem::Version
|
|
459
|
+
version: 1.4.0.pre.alpha.1
|
|
460
|
+
type: :runtime
|
|
461
|
+
prerelease: false
|
|
462
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
463
|
+
requirements:
|
|
464
|
+
- - "~>"
|
|
465
|
+
- !ruby/object:Gem::Version
|
|
466
|
+
version: 1.4.0.pre.alpha.1
|
|
453
467
|
- !ruby/object:Gem::Dependency
|
|
454
468
|
name: rfcxml
|
|
455
469
|
requirement: !ruby/object:Gem::Requirement
|