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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/lib/relaton/3gpp/bibliography.rb +19 -6
  3. data/lib/relaton/3gpp/processor.rb +6 -0
  4. data/lib/relaton/bib/item_data.rb +14 -0
  5. data/lib/relaton/bipm/bibliography.rb +24 -21
  6. data/lib/relaton/bsi/bibliography.rb +26 -23
  7. data/lib/relaton/calconnect/bibliography.rb +6 -6
  8. data/lib/relaton/calconnect/hit_collection.rb +4 -1
  9. data/lib/relaton/ccsds/bibliography.rb +15 -10
  10. data/lib/relaton/ccsds/hit_collection.rb +1 -1
  11. data/lib/relaton/ccsds/processor.rb +3 -2
  12. data/lib/relaton/cen/bibliography.rb +27 -24
  13. data/lib/relaton/cie/bibliography.rb +11 -9
  14. data/lib/relaton/cie/scrapper.rb +15 -8
  15. data/lib/relaton/core/processor.rb +61 -8
  16. data/lib/relaton/core/request_error.rb +21 -3
  17. data/lib/relaton/db/cache.rb +49 -19
  18. data/lib/relaton/db/cache_entry.rb +9 -0
  19. data/lib/relaton/db/registry.rb +128 -28
  20. data/lib/relaton/db.rb +162 -48
  21. data/lib/relaton/ecma/bibliography.rb +18 -13
  22. data/lib/relaton/etsi/bibliography.rb +8 -7
  23. data/lib/relaton/etsi/data_fetcher.rb +118 -9
  24. data/lib/relaton/gb/bibliography.rb +20 -12
  25. data/lib/relaton/iala/bibliography.rb +15 -12
  26. data/lib/relaton/iana/bibliography.rb +12 -12
  27. data/lib/relaton/iana/parser.rb +5 -2
  28. data/lib/relaton/iec/bibliography.rb +18 -7
  29. data/lib/relaton/iec/processor.rb +6 -1
  30. data/lib/relaton/ieee/bibliography.rb +19 -13
  31. data/lib/relaton/ieee/processor.rb +16 -0
  32. data/lib/relaton/ieee/rawbib_id_parser.rb +2 -2
  33. data/lib/relaton/ietf/bibliography.rb +11 -9
  34. data/lib/relaton/ietf/scraper.rb +5 -4
  35. data/lib/relaton/index/config.rb +9 -1
  36. data/lib/relaton/index/file_io.rb +190 -0
  37. data/lib/relaton/index/type.rb +96 -23
  38. data/lib/relaton/iso/bibliography.rb +11 -9
  39. data/lib/relaton/itu/bibliography.rb +9 -4
  40. data/lib/relaton/jis/bibliography.rb +22 -11
  41. data/lib/relaton/nist/bibliography.rb +25 -21
  42. data/lib/relaton/oasis/bibliography.rb +16 -13
  43. data/lib/relaton/ogc/bibliography.rb +15 -14
  44. data/lib/relaton/ogc/hit_collection.rb +9 -7
  45. data/lib/relaton/ogc/processor.rb +7 -1
  46. data/lib/relaton/omg/bibliography.rb +9 -9
  47. data/lib/relaton/omg/scraper.rb +3 -2
  48. data/lib/relaton/plateau/bibliography.rb +9 -7
  49. data/lib/relaton/plateau/hit_collection.rb +2 -1
  50. data/lib/relaton/version.rb +1 -1
  51. data/lib/relaton/xsf/bibliography.rb +11 -6
  52. 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 text [Strin] code of standard for search
12
+ # @param ref [Strin] code of standard for search
13
13
  # @return [RelatonGb::HitCollection]
14
- def search(text)
15
- case text
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: text
18
+ Util.info "Fetching from openstd.samr.gov.cn ...", key: ref
19
19
  require_relative "gb_scraper"
20
- GbScraper.scrape_page text
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: text
29
+ Util.info "Fetching from www.ttbz.org.cn ...", key: ref
30
30
  require_relative "t_scraper"
31
- TScraper.scrape_page text
31
+ TScraper.scrape_page ref
32
32
  else
33
33
  # Scrape sector standard.
34
34
  require "relaton/gb/sec_scraper"
35
- SecScraper.scrape_page text
35
+ SecScraper.scrape_page ref
36
36
  end
37
37
  end
38
38
  # rubocop:enable Metrics/MethodLength
39
39
 
40
- # @param code [String] the GB standard Code to look up (e..g "GB/T 20223")
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 code is not a GB
46
+ # @raise [Pubid::Errors::ParseError] when the reference is not a GB
45
47
  # identifier
46
- def get(code, year = nil, opts = {})
48
+ def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
47
49
  require "pubid"
48
- pubid = ::Pubid::Gb::Identifier.parse(code)
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 text [String] the IALA reference to look up (e.g. "IALA S1070")
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(text, _year = nil, _opts = {})
16
- Util.info "Fetching from Relaton repository ...", key: text
17
- row = best_match text
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: text
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: text
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 text [String]
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(text)
72
- pubid = parse_ref text
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 text [String]
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(text)
128
- ::Pubid::Iala::Identifier.parse text.to_s.strip
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 text [String, Pubid::Iana::Identifier]
18
+ # @param ref [String, Pubid::Iana::Identifier]
19
19
  # @return [Relaton::Iana::Item, nil]
20
- def search(text)
21
- pubid = parse_ref text
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 text [String, Pubid::Iana::Identifier]
66
+ # @param ref [String, Pubid::Iana::Identifier]
67
67
  # @return [Pubid::Iana::Identifier, nil]
68
- def parse_ref(text)
69
- return text unless text.is_a? String
68
+ def parse_ref(ref)
69
+ return ref unless ref.is_a? String
70
70
 
71
- ::Pubid::Iana::Identifier.parse text
71
+ ::Pubid::Iana::Identifier.parse ref
72
72
  rescue StandardError => e
73
- Util.warn "Failed to parse pubid `#{text}`: #{e.message}"
73
+ Util.warn "Failed to parse pubid `#{ref}`: #{e.message}"
74
74
  nil
75
75
  end
76
76
 
@@ -125,8 +125,11 @@ module Relaton
125
125
  # @return [Array<Relaton::Bib::Date>] date
126
126
  #
127
127
  def parse_date
128
- d = @xml.xpath("./xmlns:created|./xmlns:published|./xmlns:updated", NS).map do |dt|
129
- Bib::Date.new(type: dt.name, at: dt.text)
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 code [String] the IEC standard code to look up (e.g. "IEC 8000")
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(code, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
33
- opts[:all_parts] ||= code.match?(/\s\(all parts\)/)
34
- ref = code.sub(/\s\(all parts\)/, "")
35
- return iev if ref.casecmp("IEV").zero?
36
-
37
- pubid = ::Pubid::Iec::Identifier.parse ref.upcase
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 code [String]
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(code) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 code
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 code [String] the IEEE standard Code to look up (e..g "528-2019")
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(code, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
46
- Util.info "Fetching from Relaton repository ...", key: code
47
- item = search(code)
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: code
52
+ Util.info "Found: `#{item.docidentifier.first.content}`", key: ref.to_s
50
53
  item
51
54
  else
52
- Util.info "Not found.", key: code
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 code [String]
66
+ # @param ref [String, ::Pubid::Ieee::Identifier]
64
67
  # @return [::Pubid::Ieee::Identifier, String]
65
- def parse_pubid(code)
66
- ::Pubid::Ieee::Identifier.parse code
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
- code
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 code [String] the ISO standard Code to look up (e..g "ISO 9000")
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(text)
13
- Scraper.scrape_page text
13
+ def search(ref)
14
+ Scraper.scrape_page ref
14
15
  end
15
16
 
16
- # @param code [String] the ISO standard Code to look up (e..g "ISO 9000")
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(code, _year = nil, _opts = {})
22
- Util.info "Fetching from Relaton repository ...", key: code
23
- result = search code
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: code
28
+ Util.info "Found: `#{docid.content}`", key: ref.to_s
27
29
  else
28
- Util.info "Not found.", key: code
30
+ Util.info "Not found.", key: ref.to_s
29
31
  end
30
32
  result
31
33
  end
@@ -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 text [String]
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(text)
21
- id = parse_id text.sub(/\AIETF\s+/, "")
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 #{text} reference"
29
+ raise Relaton::RequestError, "No document found for #{ref} reference"
29
30
  end
30
31
 
31
32
  private
@@ -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
  #