relaton 3.0.0.pre.alpha.5 → 3.0.0.pre.alpha.7
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/etsi/data_fetcher.rb +118 -9
- 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 +6 -1
- 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/index/config.rb +9 -1
- data/lib/relaton/index/file_io.rb +190 -0
- data/lib/relaton/index/type.rb +96 -23
- 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
|
@@ -9,15 +9,15 @@ module Relaton
|
|
|
9
9
|
class Bibliography
|
|
10
10
|
class << self
|
|
11
11
|
# rubocop:disable Metrics/MethodLength
|
|
12
|
-
# @param
|
|
12
|
+
# @param ref [Strin] code of standard for search
|
|
13
13
|
# @return [RelatonGb::HitCollection]
|
|
14
|
-
def search(
|
|
15
|
-
case
|
|
14
|
+
def search(ref)
|
|
15
|
+
case ref
|
|
16
16
|
when /^(GB|GJ|GS)/
|
|
17
17
|
# Scrape national standards.
|
|
18
|
-
Util.info "Fetching from openstd.samr.gov.cn ...", key:
|
|
18
|
+
Util.info "Fetching from openstd.samr.gov.cn ...", key: ref
|
|
19
19
|
require_relative "gb_scraper"
|
|
20
|
-
GbScraper.scrape_page
|
|
20
|
+
GbScraper.scrape_page ref
|
|
21
21
|
# when /^ZB/
|
|
22
22
|
# Scrape proffesional.
|
|
23
23
|
# when /^DB/
|
|
@@ -26,26 +26,34 @@ module Relaton
|
|
|
26
26
|
# Enterprise standard
|
|
27
27
|
when %r{^T/[^\s]{2,6}\s}
|
|
28
28
|
# Scrape social standard.
|
|
29
|
-
Util.info "Fetching from www.ttbz.org.cn ...", key:
|
|
29
|
+
Util.info "Fetching from www.ttbz.org.cn ...", key: ref
|
|
30
30
|
require_relative "t_scraper"
|
|
31
|
-
TScraper.scrape_page
|
|
31
|
+
TScraper.scrape_page ref
|
|
32
32
|
else
|
|
33
33
|
# Scrape sector standard.
|
|
34
34
|
require "relaton/gb/sec_scraper"
|
|
35
|
-
SecScraper.scrape_page
|
|
35
|
+
SecScraper.scrape_page ref
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
# rubocop:enable Metrics/MethodLength
|
|
39
39
|
|
|
40
|
-
# @param
|
|
40
|
+
# @param ref [String, Pubid::Gb::Identifier] the GB standard Code to
|
|
41
|
+
# look up (e.g. "GB/T 20223"), or its parse from Relaton::Db
|
|
42
|
+
# (relaton#205)
|
|
41
43
|
# @param year [String] the year the standard was published (optional)
|
|
42
44
|
# @param opts [Hash] options; restricted to :all_parts if all-parts reference is required
|
|
43
45
|
# @return [Relaton::Gb::ItemData, nil]
|
|
44
|
-
# @raise [Pubid::Errors::ParseError] when the
|
|
46
|
+
# @raise [Pubid::Errors::ParseError] when the reference is not a GB
|
|
45
47
|
# identifier
|
|
46
|
-
def get(
|
|
48
|
+
def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
47
49
|
require "pubid"
|
|
48
|
-
pubid
|
|
50
|
+
# A parsed pubid comes from Relaton::Db (relaton#205); it is never
|
|
51
|
+
# mutated (`exclude` below copies).
|
|
52
|
+
pubid = ref.is_a?(String) ? ::Pubid::Gb::Identifier.parse(ref) : ref
|
|
53
|
+
if pubid.all_parts?
|
|
54
|
+
opts = opts.merge(all_parts: true)
|
|
55
|
+
pubid = pubid.identifiers.first
|
|
56
|
+
end
|
|
49
57
|
year = (year || pubid.year)&.to_s
|
|
50
58
|
pubid = pubid.exclude(:year)
|
|
51
59
|
pubid.part = "1" if opts[:all_parts]
|
|
@@ -8,15 +8,15 @@ module Relaton
|
|
|
8
8
|
class << self
|
|
9
9
|
# Search for an IALA publication by its identifier.
|
|
10
10
|
#
|
|
11
|
-
# @param
|
|
11
|
+
# @param ref [String] the IALA reference to look up (e.g. "IALA S1070")
|
|
12
12
|
# @param _year [String, nil] optional edition/year filter
|
|
13
13
|
# @param _opts [Hash] options (unused)
|
|
14
14
|
# @return [Relaton::Iala::Item, nil]
|
|
15
|
-
def search(
|
|
16
|
-
Util.info "Fetching from Relaton repository ...", key:
|
|
17
|
-
row = best_match
|
|
15
|
+
def search(ref, _year = nil, _opts = {})
|
|
16
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
17
|
+
row = best_match ref
|
|
18
18
|
unless row
|
|
19
|
-
Util.info "Not found.", key:
|
|
19
|
+
Util.info "Not found.", key: ref.to_s
|
|
20
20
|
return
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -27,7 +27,7 @@ module Relaton
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
item = Relaton::Iala::Item.from_yaml resp.body
|
|
30
|
-
Util.info "Found: `#{item.docidentifier.first&.content}`", key:
|
|
30
|
+
Util.info "Found: `#{item.docidentifier.first&.content}`", key: ref.to_s
|
|
31
31
|
item.tap { |i| i.fetched = Date.today.to_s }
|
|
32
32
|
rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
|
33
33
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
@@ -59,7 +59,7 @@ module Relaton
|
|
|
59
59
|
# must never match each other. An `Annex` row carries its base
|
|
60
60
|
# identifier, which `===` compares with its own subset match.
|
|
61
61
|
#
|
|
62
|
-
# @param
|
|
62
|
+
# @param ref [String]
|
|
63
63
|
# @return [Hash, nil]
|
|
64
64
|
#
|
|
65
65
|
# The substring-scan fallback this used to take when parsing failed is
|
|
@@ -68,8 +68,8 @@ module Relaton
|
|
|
68
68
|
# ids, so an ambiguous reference silently resolved to whichever row
|
|
69
69
|
# sorted first, instead of telling the caller the reference is not an
|
|
70
70
|
# identifier. ecma, w3c and xsf never had one.
|
|
71
|
-
def best_match(
|
|
72
|
-
pubid = parse_ref
|
|
71
|
+
def best_match(ref)
|
|
72
|
+
pubid = parse_ref ref
|
|
73
73
|
rows = index.search(pubid)
|
|
74
74
|
rows.max_by { |r| [edition_key(r[:id].edition), language_key(r[:id]), r[:file]] }
|
|
75
75
|
end
|
|
@@ -114,7 +114,7 @@ module Relaton
|
|
|
114
114
|
# zero-pads the number to its type's canonical width, so `IALA M1`,
|
|
115
115
|
# `M0001` and `R1016:ed2.0(F)` all parse without normalization here.
|
|
116
116
|
#
|
|
117
|
-
# @param
|
|
117
|
+
# @param ref [String, Pubid::Iala::Identifier]
|
|
118
118
|
# @return [Pubid::Iala::Identifier, nil]
|
|
119
119
|
#
|
|
120
120
|
# An unrecognized reference **raises**; like ISO, ETSI and 3GPP we let it
|
|
@@ -124,8 +124,11 @@ module Relaton
|
|
|
124
124
|
# logs it through the `StandardError` arm at `lib/relaton/db.rb:122`.
|
|
125
125
|
# Rescuing here would collapse "this identifier is malformed" into "no
|
|
126
126
|
# such document", leaving a caller unable to tell them apart.
|
|
127
|
-
def parse_ref(
|
|
128
|
-
::
|
|
127
|
+
def parse_ref(ref)
|
|
128
|
+
# A parsed pubid comes from Relaton::Db (relaton#205); it is used as it is.
|
|
129
|
+
return ref unless ref.is_a?(String)
|
|
130
|
+
|
|
131
|
+
::Pubid::Iala::Identifier.parse ref.to_s.strip
|
|
129
132
|
end
|
|
130
133
|
|
|
131
134
|
# The index is pubid-backed: `pubid_class:` is what makes
|
|
@@ -15,10 +15,10 @@ module Relaton
|
|
|
15
15
|
module Bibliography
|
|
16
16
|
SOURCE = "https://raw.githubusercontent.com/relaton/relaton-data-iana/refs/heads/v2/"
|
|
17
17
|
|
|
18
|
-
# @param
|
|
18
|
+
# @param ref [String, Pubid::Iana::Identifier]
|
|
19
19
|
# @return [Relaton::Iana::Item, nil]
|
|
20
|
-
def search(
|
|
21
|
-
pubid = parse_ref
|
|
20
|
+
def search(ref)
|
|
21
|
+
pubid = parse_ref ref
|
|
22
22
|
return unless pubid
|
|
23
23
|
|
|
24
24
|
# Pass the pubid so Relaton::Index narrows candidates by number via
|
|
@@ -34,19 +34,19 @@ module Relaton
|
|
|
34
34
|
raise Relaton::RequestError, e.message
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# @param ref [String] the IANA registry slug to look up
|
|
37
|
+
# @param ref [String, Pubid::Iana::Identifier] the IANA registry slug to look up
|
|
38
38
|
# @param year [String, NilClass] not used
|
|
39
39
|
# @param opts [Hash] options
|
|
40
40
|
# @return [Relaton::Iana::Item, nil]
|
|
41
41
|
def get(ref, _year = nil, _opts = {})
|
|
42
|
-
Util.info "Fetching from Relaton repository ...", key: ref
|
|
42
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
43
43
|
result = search(ref)
|
|
44
44
|
unless result
|
|
45
|
-
Util.info "Not found.", key: ref
|
|
45
|
+
Util.info "Not found.", key: ref.to_s
|
|
46
46
|
return
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
Util.info "Found: `#{result.docidentifier[0].content}`", key: ref
|
|
49
|
+
Util.info "Found: `#{result.docidentifier[0].content}`", key: ref.to_s
|
|
50
50
|
result
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -63,14 +63,14 @@ module Relaton
|
|
|
63
63
|
# RuntimeError on anything else, and a citation relaton cannot parse is a
|
|
64
64
|
# miss, not an error — `#get` reports it as "Not found.".
|
|
65
65
|
#
|
|
66
|
-
# @param
|
|
66
|
+
# @param ref [String, Pubid::Iana::Identifier]
|
|
67
67
|
# @return [Pubid::Iana::Identifier, nil]
|
|
68
|
-
def parse_ref(
|
|
69
|
-
return
|
|
68
|
+
def parse_ref(ref)
|
|
69
|
+
return ref unless ref.is_a? String
|
|
70
70
|
|
|
71
|
-
::Pubid::Iana::Identifier.parse
|
|
71
|
+
::Pubid::Iana::Identifier.parse ref
|
|
72
72
|
rescue StandardError => e
|
|
73
|
-
Util.warn "Failed to parse pubid `#{
|
|
73
|
+
Util.warn "Failed to parse pubid `#{ref}`: #{e.message}"
|
|
74
74
|
nil
|
|
75
75
|
end
|
|
76
76
|
|
data/lib/relaton/iana/parser.rb
CHANGED
|
@@ -125,8 +125,11 @@ module Relaton
|
|
|
125
125
|
# @return [Array<Relaton::Bib::Date>] date
|
|
126
126
|
#
|
|
127
127
|
def parse_date
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
# moxml 0.5.98 drops every branch after the second in an N>=3 union
|
|
129
|
+
# under the reserved `xmlns` prefix (lutaml/moxml#315), which silently
|
|
130
|
+
# stripped `updated` dates from every crawled registry.
|
|
131
|
+
d = %w[created published updated].flat_map do |type|
|
|
132
|
+
@xml.xpath("./xmlns:#{type}", NS).map { |dt| Bib::Date.new(type: dt.name, at: dt.text) }
|
|
130
133
|
end
|
|
131
134
|
result = d.none? && @rootdoc ? @rootdoc.date : d
|
|
132
135
|
@errors[:date] &&= result.empty?
|
|
@@ -24,18 +24,29 @@ module Relaton
|
|
|
24
24
|
raise Relaton::RequestError, e.message
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# @param
|
|
27
|
+
# @param ref [String, Pubid::Iec::Identifier] the IEC standard code to
|
|
28
|
+
# look up (e.g. "IEC 8000"), or the parse that Relaton::Db routed
|
|
29
|
+
# with (relaton#205); a pubid is never mutated
|
|
28
30
|
# @param year [String] the year the standard was published (optional)
|
|
29
31
|
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
|
30
32
|
# reference is required
|
|
31
33
|
# @return [Relaton::Iec::ItemData, nil]
|
|
32
|
-
def get(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
|
35
|
+
if ref.is_a?(String)
|
|
36
|
+
opts[:all_parts] ||= ref.match?(/\s\(all parts\)/)
|
|
37
|
+
text = ref.sub(/\s\(all parts\)/, "")
|
|
38
|
+
return iev if text.casecmp("IEV").zero?
|
|
39
|
+
|
|
40
|
+
pubid = ::Pubid::Iec::Identifier.parse text.upcase
|
|
41
|
+
elsif ref.all_parts?
|
|
42
|
+
opts[:all_parts] = true
|
|
43
|
+
pubid = ref.identifiers.first
|
|
44
|
+
else
|
|
45
|
+
pubid = ref
|
|
46
|
+
end
|
|
38
47
|
if year
|
|
48
|
+
# Copy first: a caller's pubid is also its Db cache key.
|
|
49
|
+
pubid = pubid.class.from_hash(pubid.to_hash)
|
|
39
50
|
pubid.date = ::Pubid::Components::Date.new(year: year.to_s)
|
|
40
51
|
end
|
|
41
52
|
|
|
@@ -7,7 +7,7 @@ module Relaton
|
|
|
7
7
|
@short = :relaton_iec
|
|
8
8
|
@prefix = "IEC"
|
|
9
9
|
@pubid_flavor = :Iec # global prefixes sourced from Pubid::Iec.prefixes
|
|
10
|
-
@defaultprefix = %r{^(IEC\s|CISPR\s|IEV($|\s))}
|
|
10
|
+
@defaultprefix = %r{^(IEC\s|CISPR\s|IEV($|\s)|CEI\s)} # CEI: IEC's French spelling (relaton#243)
|
|
11
11
|
@idtype = "IEC"
|
|
12
12
|
@datasets = %w[iec-harmonized-all iec-harmonized-latest]
|
|
13
13
|
end
|
|
@@ -63,7 +63,12 @@ module Relaton
|
|
|
63
63
|
|
|
64
64
|
# @param code [String]
|
|
65
65
|
# @return [String, nil]
|
|
66
|
+
# Only a URN: `Relaton::Iec.urn_to_code` splits on `:`, so it would
|
|
67
|
+
# rewrite any reference with enough colons
|
|
68
|
+
# (`IEC 60034-1:1969+AMD1:1977+AMD2:1979+AMD3:1980 CSV`).
|
|
66
69
|
def urn_to_code(code)
|
|
70
|
+
return unless code.match?(/\Aurn:/i)
|
|
71
|
+
|
|
67
72
|
require_relative "../iec"
|
|
68
73
|
Relaton::Iec.urn_to_code code
|
|
69
74
|
end
|
|
@@ -7,11 +7,12 @@ module Relaton
|
|
|
7
7
|
#
|
|
8
8
|
# Search IEEE bibliography item by reference.
|
|
9
9
|
#
|
|
10
|
-
# @param
|
|
10
|
+
# @param ref [String, Pubid::Ieee::Identifier] the reference, or its
|
|
11
|
+
# parse from Relaton::Db (relaton#205)
|
|
11
12
|
#
|
|
12
13
|
# @return [Relaton::Ieee::ItemData, nil]
|
|
13
14
|
#
|
|
14
|
-
def search(
|
|
15
|
+
def search(ref) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
15
16
|
index = Relaton::Index.find_or_create :ieee, url: "#{GH_URL}#{INDEXFILE}.zip", file: "#{INDEXFILE}.yaml",
|
|
16
17
|
pubid_class: ::Pubid::Ieee::Identifier
|
|
17
18
|
# Pass the parsed pubid (not the raw String) so index-v2 narrows
|
|
@@ -20,7 +21,7 @@ module Relaton
|
|
|
20
21
|
# unparseable/partial ref falls back to the full-scan String search.
|
|
21
22
|
# Rows are Pubid::Ieee::Identifier objects (not Comparable), so pick by
|
|
22
23
|
# the string form.
|
|
23
|
-
pubid = parse_pubid
|
|
24
|
+
pubid = parse_pubid ref
|
|
24
25
|
needle = pubid.to_s
|
|
25
26
|
row = index.search(pubid) { |r| r[:id].to_s.include?(needle) }.min_by { |r| r[:id].to_s }
|
|
26
27
|
return unless row
|
|
@@ -36,20 +37,22 @@ module Relaton
|
|
|
36
37
|
#
|
|
37
38
|
# Get IEEE bibliography item by reference.
|
|
38
39
|
#
|
|
39
|
-
# @param
|
|
40
|
+
# @param ref [String, Pubid::Ieee::Identifier] the IEEE standard
|
|
41
|
+
# reference to look up (e.g. "IEEE 528-2019"), or its parse from
|
|
42
|
+
# Relaton::Db (relaton#205)
|
|
40
43
|
# @param year [String] the year the standard was published (optional)
|
|
41
44
|
# @param opts [Hash] options
|
|
42
45
|
#
|
|
43
46
|
# @return [Relaton::Ieee::ItemData, nil]
|
|
44
47
|
#
|
|
45
|
-
def get(
|
|
46
|
-
Util.info "Fetching from Relaton repository ...", key:
|
|
47
|
-
item = search(
|
|
48
|
+
def get(ref, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
49
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
50
|
+
item = search(ref)
|
|
48
51
|
if item
|
|
49
|
-
Util.info "Found: `#{item.docidentifier.first.content}`", key:
|
|
52
|
+
Util.info "Found: `#{item.docidentifier.first.content}`", key: ref.to_s
|
|
50
53
|
item
|
|
51
54
|
else
|
|
52
|
-
Util.info "Not found.", key:
|
|
55
|
+
Util.info "Not found.", key: ref.to_s
|
|
53
56
|
nil
|
|
54
57
|
end
|
|
55
58
|
end
|
|
@@ -60,12 +63,15 @@ module Relaton
|
|
|
60
63
|
# return the raw String when pubid can't parse it (e.g. a partial ref) so
|
|
61
64
|
# the search falls back to the substring scan.
|
|
62
65
|
#
|
|
63
|
-
# @param
|
|
66
|
+
# @param ref [String, ::Pubid::Ieee::Identifier]
|
|
64
67
|
# @return [::Pubid::Ieee::Identifier, String]
|
|
65
|
-
def parse_pubid(
|
|
66
|
-
::
|
|
68
|
+
def parse_pubid(ref)
|
|
69
|
+
# A pubid from Relaton::Db (relaton#205) is used as it is.
|
|
70
|
+
return ref unless ref.is_a?(String)
|
|
71
|
+
|
|
72
|
+
::Pubid::Ieee::Identifier.parse ref
|
|
67
73
|
rescue StandardError
|
|
68
|
-
|
|
74
|
+
ref
|
|
69
75
|
end
|
|
70
76
|
end
|
|
71
77
|
end
|
|
@@ -44,6 +44,22 @@ module Relaton
|
|
|
44
44
|
nil
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
# An IEEE pubid keeps the other publishers in `publishers` (a joint
|
|
48
|
+
# development) or `copublisher` (a standard), not in the shared
|
|
49
|
+
# `copublishers`.
|
|
50
|
+
#
|
|
51
|
+
# @param pubid [Pubid::Ieee::Identifier]
|
|
52
|
+
# @return [Array<String>]
|
|
53
|
+
def copublishers(pubid)
|
|
54
|
+
pubid = pubid.identifiers.first if pubid.all_parts?
|
|
55
|
+
others = if pubid.respond_to?(:publishers) && pubid.publishers
|
|
56
|
+
pubid.publishers
|
|
57
|
+
elsif pubid.respond_to?(:copublisher)
|
|
58
|
+
pubid.copublisher
|
|
59
|
+
end
|
|
60
|
+
Array(others).map(&:to_s) - %w[IEEE AIEE]
|
|
61
|
+
end
|
|
62
|
+
|
|
47
63
|
# @param xml [String]
|
|
48
64
|
# @return [Relaton::Ieee::ItemData]
|
|
49
65
|
def from_xml(xml)
|
|
@@ -138,8 +138,8 @@ module Relaton
|
|
|
138
138
|
Renderer.new(publisher: "IEEE", number: "P802", part: "11aj", draft: "8.0", year: "2017")
|
|
139
139
|
when "IEEE P802.11ajD9.0, November 2017" # "IEEE P802-11aj/D9.0.2017"
|
|
140
140
|
Renderer.new(publisher: "IEEE", number: "P802", part: "11aj", draft: "9.0", year: "2017")
|
|
141
|
-
when "ISO/IEC/IEEE P29119-4-DISMay2013" # "ISO/IEC/IEEE DIS P29119-4.2013"
|
|
142
|
-
Renderer.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P29119", part: "4", year: "2013")
|
|
141
|
+
when "ISO/IEC/IEEE P29119-4-DISMay2013" # "ISO/IEC/IEEE DIS P29119-4.2013-05"
|
|
142
|
+
Renderer.new(publisher: "ISO/IEC/IEEE", stage: "DIS", number: "P29119", part: "4", year: "2013", month: "05")
|
|
143
143
|
when "IEEE-P15026-3-DIS-January 2015" # "IEEE DIS P15026-3.2015"
|
|
144
144
|
Renderer.new(publisher: "IEEE", stage: "DIS", number: "P15026", year: "2015")
|
|
145
145
|
when "ANSI/IEEE PC63.7/D rev17, December 2014" # "ANSI/IEEE PC63-7/D/REV-17.2014"
|
|
@@ -7,25 +7,27 @@ module Relaton
|
|
|
7
7
|
# IETF bibliography module
|
|
8
8
|
module Bibliography
|
|
9
9
|
class << self
|
|
10
|
-
# @param
|
|
10
|
+
# @param ref [String, Pubid::Ietf::Identifier] the IETF reference
|
|
11
|
+
# (e.g. "RFC 8341"), or its parse from Relaton::Db (relaton#205)
|
|
11
12
|
# @return [RelatonIetf::IetfBibliographicItem]
|
|
12
|
-
def search(
|
|
13
|
-
Scraper.scrape_page
|
|
13
|
+
def search(ref)
|
|
14
|
+
Scraper.scrape_page ref
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
# @param
|
|
17
|
+
# @param ref [String, Pubid::Ietf::Identifier] the IETF reference
|
|
18
|
+
# (e.g. "RFC 8341"), or its parse from Relaton::Db (relaton#205)
|
|
17
19
|
# @param year [String] the year the standard was published (optional)
|
|
18
20
|
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
|
19
21
|
# reference is required
|
|
20
22
|
# @return [RelatonIetf::IetfBibliographicItem] Relaton of reference
|
|
21
|
-
def get(
|
|
22
|
-
Util.info "Fetching from Relaton repository ...", key:
|
|
23
|
-
result = search
|
|
23
|
+
def get(ref, _year = nil, _opts = {})
|
|
24
|
+
Util.info "Fetching from Relaton repository ...", key: ref.to_s
|
|
25
|
+
result = search ref
|
|
24
26
|
if result
|
|
25
27
|
docid = result.docidentifier.detect(&:primary) || result.docidentifier.first
|
|
26
|
-
Util.info "Found: `#{docid.content}`", key:
|
|
28
|
+
Util.info "Found: `#{docid.content}`", key: ref.to_s
|
|
27
29
|
else
|
|
28
|
-
Util.info "Not found.", key:
|
|
30
|
+
Util.info "Not found.", key: ref.to_s
|
|
29
31
|
end
|
|
30
32
|
result
|
|
31
33
|
end
|
data/lib/relaton/ietf/scraper.rb
CHANGED
|
@@ -15,17 +15,18 @@ module Relaton
|
|
|
15
15
|
# publishing their `index-v1` for released relatons, untouched.
|
|
16
16
|
IETF = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/main/"
|
|
17
17
|
|
|
18
|
-
# @param
|
|
18
|
+
# @param ref [String, Pubid::Ietf::Identifier] a reference, or its parse
|
|
19
|
+
# from Relaton::Db (relaton#205), which is used as it is
|
|
19
20
|
# @return [Relaton::Ietf::ItemData, nil]
|
|
20
|
-
def scrape_page(
|
|
21
|
-
id = parse_id
|
|
21
|
+
def scrape_page(ref)
|
|
22
|
+
id = ref.is_a?(String) ? parse_id(ref.sub(/\AIETF\s+/, "")) : ref
|
|
22
23
|
return unless id
|
|
23
24
|
|
|
24
25
|
fetch_doc id
|
|
25
26
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
|
26
27
|
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
27
28
|
Net::ProtocolError, SocketError
|
|
28
|
-
raise Relaton::RequestError, "No document found for #{
|
|
29
|
+
raise Relaton::RequestError, "No document found for #{ref} reference"
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
private
|
data/lib/relaton/index/config.rb
CHANGED
|
@@ -4,7 +4,7 @@ module Relaton
|
|
|
4
4
|
# Configuration class for Relaton::Index
|
|
5
5
|
#
|
|
6
6
|
class Config
|
|
7
|
-
attr_reader :storage, :storage_dir, :filename
|
|
7
|
+
attr_reader :storage, :storage_dir, :filename, :build_sidecar_in_child
|
|
8
8
|
|
|
9
9
|
#
|
|
10
10
|
# Set default values
|
|
@@ -13,6 +13,14 @@ module Relaton
|
|
|
13
13
|
@storage = FileStorage
|
|
14
14
|
@storage_dir = Dir.home
|
|
15
15
|
@filename = "index.yaml"
|
|
16
|
+
@build_sidecar_in_child = true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Build the sidecar in a forked child when available, so the one-time
|
|
20
|
+
# full materialization's memory dies with the child (relaton#242).
|
|
21
|
+
# Set to false to force an in-process build.
|
|
22
|
+
def build_sidecar_in_child=(flag)
|
|
23
|
+
@build_sidecar_in_child = flag
|
|
16
24
|
end
|
|
17
25
|
|
|
18
26
|
#
|