relaton 1.11.2 → 1.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -5
  3. data/.rubocop.yml +1 -1
  4. data/lib/relaton/db.rb +7 -19
  5. data/lib/relaton/registry.rb +28 -0
  6. data/lib/relaton/version.rb +1 -1
  7. data/relaton.gemspec +1 -1
  8. data/spec/relaton/registry_spec.rb +1 -0
  9. data/spec/relaton_spec.rb +2 -2
  10. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +8 -9
  11. data/spec/vcr_cassetes/async_fetch.yml +1351 -1438
  12. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +11 -13
  13. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +9 -11
  14. data/spec/vcr_cassetes/cie_001_1980.yml +8 -9
  15. data/spec/vcr_cassetes/ecma_6.yml +8 -9
  16. data/spec/vcr_cassetes/en_10160_1999.yml +29 -33
  17. data/spec/vcr_cassetes/fisp_140.yml +7 -8
  18. data/spec/vcr_cassetes/gb_t_20223_2006.yml +7 -9
  19. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +11 -12
  20. data/spec/vcr_cassetes/iec_60050_102_2007.yml +29 -34
  21. data/spec/vcr_cassetes/iec_combined_included.yml +99 -116
  22. data/spec/vcr_cassetes/ieee_528_2019.yml +620 -618
  23. data/spec/vcr_cassetes/iho_b_11.yml +8 -9
  24. data/spec/vcr_cassetes/iso_111111119115_1.yml +3 -4
  25. data/spec/vcr_cassetes/iso_19115_1.yml +16 -20
  26. data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -40
  27. data/spec/vcr_cassetes/iso_19115_all_parts.yml +17 -21
  28. data/spec/vcr_cassetes/iso_19133_2005.yml +16 -20
  29. data/spec/vcr_cassetes/iso_combined_applied.yml +29 -37
  30. data/spec/vcr_cassetes/iso_combined_included.yml +29 -37
  31. data/spec/vcr_cassetes/iso_dis_14093.yml +14 -18
  32. data/spec/vcr_cassetes/itu_combined_included.yml +189 -315
  33. data/spec/vcr_cassetes/oasis_amqp_core_types_v1_0_pt1.yml +10 -11
  34. data/spec/vcr_cassetes/ogc_19_025r1.yml +11 -12
  35. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +3 -4
  36. data/spec/vcr_cassetes/rfc_8341.yml +8 -9
  37. data/spec/vcr_cassetes/sp_800_38b.yml +7 -8
  38. data/spec/vcr_cassetes/threads_from_env.yml +61 -69
  39. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -35
  40. data/spec/vcr_cassetes/w3c_json_ld11.yml +21 -23
  41. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 451c0d9a82ae4722a2840928ff36a7c9f352dcfd5a2a3c6356eb0629d18141dd
4
- data.tar.gz: 2f68099b406013f4a9a4bcc080aeb771060fba85db058251ad78e98ec5989ab8
3
+ metadata.gz: 4e53eb8b2768e1b80e472312aa1af438457ce7115fe078256318749666261f33
4
+ data.tar.gz: 670a8f3815488a7b315c1e0b56f6376c16fd317cec1fb444d7c6d0dac9c92107
5
5
  SHA512:
6
- metadata.gz: da891dd5fb56ea1c68ebf14d88aae5db6c0b861e6d48bac73686ce572b60be8f919145cb53c179521b91b68a22ef3b694156e4b0599553f900a7a842a24300d3
7
- data.tar.gz: 5e2cac57ca860937d708dcba84516947f8952ff6b3f7df51811dc54ef4d1f2e97c660a77a6f4f65ce6d87f010e2d556834d940d2baef72f7c27fe156d1bd8fcc
6
+ metadata.gz: 64186cb269dbd470798c3ccbe2996ea736c909c7258bc385528626e043bee1c7d88a1a6409948392ef73203ea4715a93b8474bfd3437503a08a1e312d430a968
7
+ data.tar.gz: 434cbc56312aa11577c2227788eeb930ea2e85e9f5c98f37b5738e58d030bfbcf0cbffcdeb623dda7ef31ca7628bc80f7a88a63050814e3b87a0c1883abcb287
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
19
+ ruby: [ '3.0', '2.7', '2.6' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
@@ -24,10 +24,6 @@ jobs:
24
24
  with:
25
25
  submodules: true
26
26
 
27
- # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
- - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
- run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
-
31
27
  - uses: ruby/setup-ruby@v1
32
28
  with:
33
29
  ruby-version: ${{ matrix.ruby }}
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.5
10
+ TargetRubyVersion: 2.6
11
11
  Rails:
12
12
  Enabled: false
data/lib/relaton/db.rb CHANGED
@@ -63,7 +63,7 @@ module Relaton
63
63
  # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
64
64
  ##
65
65
  def fetch(code, year = nil, opts = {})
66
- stdclass = standard_class(code) || return
66
+ stdclass = @registry.class_by_ref(code) || return
67
67
  processor = @registry.processors[stdclass]
68
68
  ref = if processor.respond_to?(:urn_to_code)
69
69
  processor.urn_to_code(code)&.first
@@ -101,7 +101,7 @@ module Relaton
101
101
 
102
102
  # Fetch asynchronously
103
103
  def fetch_async(code, year = nil, opts = {}, &block) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
104
- stdclass = standard_class code
104
+ stdclass = @registry.class_by_ref code
105
105
  if stdclass
106
106
  unless @queues[stdclass]
107
107
  processor = @registry.processors[stdclass]
@@ -142,7 +142,7 @@ module Relaton
142
142
  @registry.processors.each do |name, processor|
143
143
  std = name if processor.prefix == stdclass
144
144
  end
145
- std = standard_class(code) or return nil unless std
145
+ std = @registry.class_by_ref(code) or return nil unless std
146
146
 
147
147
  check_bibliocache(code, year, opts, std)
148
148
  end
@@ -151,8 +151,8 @@ module Relaton
151
151
  # @param code [String]
152
152
  # @return [Array]
153
153
  def docid_type(code)
154
- stdclass = standard_class(code) or return [nil, code]
155
- _prefix, code = strip_id_wrapper(code, stdclass)
154
+ stdclass = @registry.class_by_ref(code) or return [nil, code]
155
+ _, code = strip_id_wrapper(code, stdclass)
156
156
  [@registry.processors[stdclass].idtype, code]
157
157
  end
158
158
 
@@ -218,7 +218,7 @@ module Relaton
218
218
  # @param year [Integer, nil] year to filter
219
219
  # @return [BibliographicItem, nil]
220
220
  def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
221
- processor = @registry.processors[standard_class(file.split("/")[-2])]
221
+ processor = @registry.processor_by_ref(file.split("/")[-2])
222
222
  item = if file.match?(/xml$/) then processor.from_xml(content)
223
223
  else processor.hash_to_bib(YAML.safe_load(content))
224
224
  end
@@ -269,7 +269,7 @@ module Relaton
269
269
  type: "updates")
270
270
  end
271
271
  divider = stdclass == :relaton_itu ? " " : "/"
272
- refs[1..-1].each_with_object(doc) do |c, d|
272
+ refs[1..].each_with_object(doc) do |c, d|
273
273
  bib = check_bibliocache(ref + divider + c, year, opts, stdclass)
274
274
  if bib
275
275
  d.relation << RelatonBib::DocumentRelation.new(
@@ -279,18 +279,6 @@ module Relaton
279
279
  end
280
280
  end
281
281
 
282
- # @param code [String] code of standard
283
- # @return [Symbol] standard class name
284
- def standard_class(code)
285
- @registry.processors.each do |name, processor|
286
- return name if /^(urn:)?#{processor.prefix}/i.match?(code) ||
287
- processor.defaultprefix.match(code)
288
- end
289
- Util.log <<~WARN, :info
290
- [relaton] #{code} does not have a recognised prefix
291
- WARN
292
- end
293
-
294
282
  # TODO: i18n
295
283
  # Fofmat ID
296
284
  # @param code [String]
@@ -77,6 +77,34 @@ module Relaton
77
77
  processors.values.detect { |v| v.prefix == type&.upcase }
78
78
  end
79
79
 
80
+ #
81
+ # Find processor by reference or prefix
82
+ #
83
+ # @param [String] ref reference or prefix
84
+ #
85
+ # @return [Relaton::Processor] processor
86
+ #
87
+ def processor_by_ref(ref)
88
+ @processors[class_by_ref(ref)]
89
+ end
90
+
91
+ #
92
+ # Find processor by refernce or prefix
93
+ #
94
+ # @param ref [String] reference or prefix
95
+ #
96
+ # @return [Symbol, nil] standard class name
97
+ #
98
+ def class_by_ref(ref)
99
+ @processors.each do |class_name, processor|
100
+ return class_name if /^(urn:)?#{processor.prefix}(?!\w)/i.match?(ref) ||
101
+ processor.defaultprefix.match(ref)
102
+ end
103
+ Util.log <<~WARN, :info
104
+ [relaton] #{ref} does not have a recognised prefix
105
+ WARN
106
+ end
107
+
80
108
  private
81
109
 
82
110
  def camel_case(gem_name)
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.11.2".freeze
2
+ VERSION = "1.11.3".freeze
3
3
  end
data/relaton.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
  spec.files = `git ls-files`.split("\n")
29
29
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
30
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
31
31
 
32
32
  spec.add_dependency "relaton-3gpp", "~> 1.11.0"
33
33
  spec.add_dependency "relaton-bipm", "~> 1.11.0"
@@ -70,6 +70,7 @@ RSpec.describe Relaton::Registry do
70
70
 
71
71
  it "BIPM" do
72
72
  expect(Relaton::Registry.instance.by_type("BIPM")).to be_instance_of RelatonBipm::Processor
73
+ expect(Relaton::Registry.instance.processor_by_ref("CCTF")).to be_instance_of RelatonBipm::Processor
73
74
  end
74
75
 
75
76
  it "ECMA" do
data/spec/relaton_spec.rb CHANGED
@@ -196,10 +196,10 @@ RSpec.describe Relaton::Db do
196
196
  expect(File.exist?("testcache2")).to be true
197
197
  testcache = Relaton::DbCache.new "testcache"
198
198
  expect(testcache["IETF(RFC 8341)"]).to include "<docidentifier "\
199
- "type=\"RFC\" scope=\"anchor\">RFC8341</docidentifier>"
199
+ "type=\"RFC\" primary=\"true\">RFC 8341</docidentifier>"
200
200
  testcache = Relaton::DbCache.new "testcache2"
201
201
  expect(testcache["IETF(RFC 8341)"]).to include "<docidentifier "\
202
- "type=\"RFC\" scope=\"anchor\">RFC8341</docidentifier>"
202
+ "type=\"RFC\" primary=\"true\">RFC 8341</docidentifier>"
203
203
  end
204
204
  end
205
205
 
@@ -41,29 +41,29 @@ http_interactions:
41
41
  X-Xss-Protection:
42
42
  - 1; mode=block
43
43
  X-Github-Request-Id:
44
- - 687A:10CE7:F2C38C:107FE9E:6278EE7D
44
+ - FEF4:1395A:3E1BC8:42A2CE:6290BA99
45
45
  Accept-Ranges:
46
46
  - bytes
47
47
  Date:
48
- - Mon, 09 May 2022 10:35:41 GMT
48
+ - Fri, 27 May 2022 11:48:42 GMT
49
49
  Via:
50
50
  - 1.1 varnish
51
51
  X-Served-By:
52
- - cache-vie6353-VIE
52
+ - cache-vie6371-VIE
53
53
  X-Cache:
54
54
  - MISS
55
55
  X-Cache-Hits:
56
56
  - '0'
57
57
  X-Timer:
58
- - S1652092541.458281,VS0,VE220
58
+ - S1653652122.797835,VS0,VE233
59
59
  Vary:
60
60
  - Authorization,Accept-Encoding,Origin
61
61
  Access-Control-Allow-Origin:
62
62
  - "*"
63
63
  X-Fastly-Request-Id:
64
- - bc2e33f28bbade3cfbf583259d99518383e6f9f3
64
+ - 740cb118933ba3ba55fcbdb02f6f313a4eb80f39
65
65
  Expires:
66
- - Mon, 09 May 2022 10:40:41 GMT
66
+ - Fri, 27 May 2022 11:53:42 GMT
67
67
  Source-Age:
68
68
  - '0'
69
69
  body:
@@ -143,6 +143,5 @@ http_interactions:
143
143
  freeze_stage3_meeting: SMG-28
144
144
  close_meeting: SP-28
145
145
  project_end: '1999-02-12'
146
- http_version:
147
- recorded_at: Mon, 09 May 2022 10:35:41 GMT
148
- recorded_with: VCR 5.1.0
146
+ recorded_at: Fri, 27 May 2022 11:48:41 GMT
147
+ recorded_with: VCR 6.1.0