relaton 2.1.0 → 2.2.0.pre.alpha.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/CLAUDE.md +8 -0
  4. data/Gemfile +8 -0
  5. data/lib/relaton/db/cache.rb +232 -0
  6. data/lib/relaton/db/config.rb +24 -0
  7. data/lib/relaton/db/registry.rb +119 -0
  8. data/lib/relaton/db/util.rb +9 -0
  9. data/lib/relaton/db/version.rb +5 -0
  10. data/lib/relaton/db/workers_pool.rb +22 -0
  11. data/lib/relaton/db.rb +21 -206
  12. data/lib/relaton/version.rb +1 -1
  13. data/lib/relaton.rb +2 -10
  14. data/relaton.gemspec +47 -36
  15. data/spec/relaton/config_spec.rb +1 -1
  16. data/spec/relaton/db_cache_spec.rb +4 -4
  17. data/spec/relaton/db_spec.rb +18 -7
  18. data/spec/relaton/registry_spec.rb +39 -39
  19. data/spec/relaton/util_spec.rb +1 -1
  20. data/spec/relaton_meta_spec.rb +25 -0
  21. data/spec/relaton_spec.rb +163 -88
  22. data/spec/spec_helper.rb +2 -2
  23. data/spec/vcr_cassetes/api_relaton_org.yml +8 -8
  24. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -79
  25. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +80 -77
  26. data/spec/vcr_cassetes/cipm_meeting_43.yml +1372 -1380
  27. data/spec/vcr_cassetes/gb_t_20223_2006.yml +500 -504
  28. data/spec/vcr_cassetes/iso_19115_1.yml +17204 -13047
  29. data/spec/vcr_cassetes/iso_19115_1_2.yml +193 -240
  30. data/spec/vcr_cassetes/iso_19115_1_std.yml +17207 -13050
  31. data/spec/vcr_cassetes/iso_19115_all_parts.yml +116 -160
  32. data/spec/vcr_cassetes/iso_19133_2005.yml +78 -82
  33. data/spec/vcr_cassetes/iso_combined_applied.yml +186 -232
  34. data/spec/vcr_cassetes/iso_combined_included.yml +187 -233
  35. data/spec/vcr_cassetes/ogc_19_025r1.yml +211 -208
  36. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +246 -246
  37. data/spec/vcr_cassetes/rfc_8341.yml +1026 -1020
  38. metadata +133 -78
  39. data/.rubocop.yml +0 -12
  40. data/lib/relaton/config.rb +0 -24
  41. data/lib/relaton/db_cache.rb +0 -230
  42. data/lib/relaton/registry.rb +0 -118
  43. data/lib/relaton/util.rb +0 -7
  44. data/lib/relaton/workers_pool.rb +0 -21
  45. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
  46. data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
  47. data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
  48. data/spec/vcr_cassetes/ecma_6.yml +0 -112
  49. data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
  50. data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
  51. data/spec/vcr_cassetes/iso_dis.yml +0 -157
data/lib/relaton/db.rb CHANGED
@@ -1,9 +1,16 @@
1
+ require "relaton/bib"
2
+ require "yaml"
3
+ require "net/http"
4
+ require "nokogiri"
5
+ require "fileutils"
6
+ require "date"
7
+
1
8
  module Relaton
2
9
  class Db
3
10
  # @param global_cache [String] directory of global DB
4
11
  # @param local_cache [String] directory of local DB
5
12
  def initialize(global_cache, local_cache)
6
- @registry = Relaton::Registry.instance
13
+ @registry = Registry.instance
7
14
  gpath = global_cache && File.expand_path(global_cache)
8
15
  @db = open_cache_biblio(gpath)
9
16
  lpath = local_cache && File.expand_path(local_cache)
@@ -53,14 +60,7 @@ module Relaton
53
60
  # after this date (inclusive, formats: "YYYY", "YYYY-MM",
54
61
  # or "YYYY-MM-DD")
55
62
  #
56
- # @return [nil, RelatonBib::BibliographicItem,
57
- # RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
58
- # RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
59
- # RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
60
- # RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
61
- # RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
62
- # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
63
- # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
63
+ # @return [nil, RelatonBib::BibliographicItem, ...]
64
64
  ##
65
65
  def fetch(text, year = nil, opts = {})
66
66
  reference = text.strip
@@ -132,24 +132,6 @@ module Relaton
132
132
  end
133
133
  end
134
134
 
135
- # @param code [String]
136
- # @param year [String, NilClass]
137
- # @param stdclass [Symbol, NilClass]
138
- #
139
- # @param opts [Hash]
140
- # @option opts [Boolean] :all_parts If all-parts reference is required
141
- # @option opts [Boolean] :keep_year If undated reference should return
142
- # actual reference with year
143
- # @option opts [Integer] :retries (1) Number of network retries
144
- #
145
- # @return [nil, RelatonBib::BibliographicItem,
146
- # RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
147
- # RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
148
- # RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
149
- # RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
150
- # RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
151
- # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
152
- # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
153
135
  def fetch_std(code, year = nil, stdclass = nil, opts = {})
154
136
  std = nil
155
137
  @registry.processors.each do |name, processor|
@@ -194,28 +176,14 @@ module Relaton
194
176
 
195
177
  private
196
178
 
197
- # @param (see #fetch_api)
198
- # @return (see #fetch_api)
199
179
  def fetch_doc(code, year, opts, processor)
200
- if Relaton.configuration.use_api then fetch_api(code, year, opts,
201
- processor)
180
+ if Db.configuration.use_api then fetch_api(code, year, opts, processor)
202
181
  else processor.get(code, year, opts)
203
182
  end
204
183
  end
205
184
 
206
- #
207
- # @param code [String]
208
- # @param year [String]
209
- #
210
- # @param opts [Hash]
211
- # @option opts [Boolean] :all_parts If all-parts reference is required
212
- # @option opts [Boolean] :keep_year If undated reference should return
213
- # actual reference with year
214
- #
215
- # @param processor [Relaton::Processor]
216
- # @return [RelatonBib::BibliographicItem, nil]
217
185
  def fetch_api(code, year, opts, processor)
218
- url = "#{Relaton.configuration.api_host}" \
186
+ url = "#{Db.configuration.api_host}" \
219
187
  "/api/v1/document?#{params(code, year, opts)}"
220
188
  rsp = Net::HTTP.get_response URI(url)
221
189
  processor.from_xml rsp.body if rsp.code == "200"
@@ -223,36 +191,16 @@ module Relaton
223
191
  processor.get(code, year, opts)
224
192
  end
225
193
 
226
- #
227
- # Make string of parametrs
228
- #
229
- # @param [String] code
230
- # @param [String] year
231
- # @param [Hash] opts
232
- #
233
- # @return [String]
234
- #
235
194
  def params(code, year, opts)
236
195
  opts.merge(code: code, year: year).map { |k, v| "#{k}=#{v}" }.join "&"
237
196
  end
238
197
 
239
- # @param file [String] file path
240
- # @param xml [String] content in XML format
241
- # @param text [String, nil] text to serach
242
- # @param edition [String, nil] edition to filter
243
- # @param year [Integer, nil] year to filter
244
- # @return [BibliographicItem, nil]
245
198
  def search_xml(file, xml, text, edition, year)
246
199
  return unless text.nil? || match_xml_text?(xml, text)
247
200
 
248
201
  search_edition_year(file, xml, edition, year)
249
202
  end
250
203
 
251
- # @param file [String] file path
252
- # @param content [String] content in XML or YAML format
253
- # @param edition [String, nil] edition to filter
254
- # @param year [Integer, nil] year to filter
255
- # @return [BibliographicItem, nil]
256
204
  def search_edition_year(file, content, edition, year) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
257
205
  processor = @registry.processor_by_ref(file.split("/")[-2])
258
206
  item = if file.match?(/xml$/) then processor.from_xml(content)
@@ -264,14 +212,6 @@ module Relaton
264
212
  end)
265
213
  end
266
214
 
267
- #
268
- # Look up text in the XML elements attributes and content
269
- #
270
- # @param xml [String] content in XML format
271
- # @param text [String, nil] text to serach
272
- #
273
- # @return [Boolean]
274
- #
275
215
  def match_xml_text?(xml, text)
276
216
  esc = Regexp.escape(text)
277
217
  pat = "((?<attr>=((?<apstr>')|\"" \
@@ -281,18 +221,6 @@ module Relaton
281
221
  .match?(xml)
282
222
  end
283
223
 
284
- # @param code [String]
285
- # @param year [String, nil]
286
- # @param stdslass [String]
287
- #
288
- # @param opts [Hash] options
289
- # @option opts [Boolean] :all_parts If all-parts reference is required
290
- # @option opts [Boolean] :keep_year If undated reference should return
291
- # actual reference with year
292
- # @option opts [Integer] :retries (1) Number of network retries
293
- #
294
- # @return [nil, Relaton::Bib::ItemData
295
- #
296
224
  def combine_doc(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
297
225
  return if stdclass == :relaton_bipm
298
226
 
@@ -323,19 +251,6 @@ module Relaton
323
251
  end
324
252
  end
325
253
 
326
- # TODO: i18n
327
- # Fofmat ID
328
- # @param code [String]
329
- # @param year [String]
330
- #
331
- # @param opts [Hash]
332
- # @option opts [Boolean] :all_parts If all-parts reference is required
333
- # @option opts [Boolean] :keep_year If undated reference should return
334
- # actual reference with year
335
- # @option opts [Integer] :retries (1) Number of network retries
336
- #
337
- # @param stdClass [Symbol]
338
- # @return [Array<String>] docid and code
339
254
  def std_id(code, year, opts, stdclass)
340
255
  prefix, code = strip_id_wrapper(code, stdclass)
341
256
  ret = code
@@ -348,59 +263,23 @@ module Relaton
348
263
  ["#{prefix}(#{ret.strip})", code]
349
264
  end
350
265
 
351
- # Find prefix and clean code
352
- # @param code [String]
353
- # @param stdClass [Symbol]
354
- # @return [Array]
355
266
  def strip_id_wrapper(code, stdclass)
356
267
  prefix = @registry[stdclass].prefix
357
268
  code =
358
269
  if code.is_a?(String)
359
- code.sub("\u2013", "-").sub(/^#{prefix}\((.+)\)$/, "\\1")
270
+ code.sub("", "-").sub(/^#{prefix}\((.+)\)$/, "\\1")
360
271
  else code.to_s
361
272
  end
362
273
  [prefix, code]
363
274
  end
364
275
 
365
- #
366
- # @param entry [String, nil] XML string
367
- # @param stdclass [Symbol]
368
- #
369
- # @return [nil, RelatonBib::BibliographicItem,
370
- # RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
371
- # RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
372
- # RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
373
- # RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
374
- # RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
375
- # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
376
- # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
377
276
  def bib_retval(entry, stdclass)
378
277
  if entry && !entry.match?(/^not_found/)
379
278
  @registry[stdclass].from_xml(entry)
380
279
  end
381
280
  end
382
281
 
383
- # @param code [String]
384
- # @param year [String]
385
- #
386
- # @param opts [Hash]
387
- # @option opts [Boolean] :all_parts If all-parts reference is required
388
- # @option opts [Boolean] :keep_year If undated reference should return
389
- # actual reference with year
390
- # @option opts [Integer] :retries (1) Number of network retries
391
- #
392
- # @param stdclass [Symbol]
393
- # @return [nil, RelatonBib::BibliographicItem,
394
- # RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
395
- # RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
396
- # RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
397
- # RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
398
- # RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
399
- # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
400
- # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
401
282
  def check_bibliocache(code, year, opts, stdclass) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
402
- # When date filters are present, check if the base
403
- # (non-date-filtered) cache entry satisfies the range
404
283
  if opts[:publication_date_before] || opts[:publication_date_after]
405
284
  base_opts = opts.except(
406
285
  :publication_date_before, :publication_date_after
@@ -447,27 +326,6 @@ module Relaton
447
326
  bib_retval(db[id], stdclass)
448
327
  end
449
328
 
450
- #
451
- # Create new bibliographic entry if it doesn't exist in database
452
- #
453
- # @param code [String]
454
- # @param year [String]
455
- #
456
- # @param opts [Hash]
457
- # @option opts [Boolean, nil] :all_parts If true then all-parts reference is
458
- # requested
459
- # @option opts [Boolean, nil] :keep_year If true then undated reference
460
- # should return actual reference with year
461
- # @option opts [Integer] :retries (1) Number of network retries
462
- # @option opts [Boolean] :no_cache If true then don't use cache
463
- #
464
- # @param stdclass [Symbol]
465
- # @param db [Relaton::DbCache,`nil]
466
- # @param id [String, nil] docid
467
- #
468
- # @return [String] bibliographic entry
469
- # XML or "redirection ID" or "not_found YYYY-MM-DD" string
470
- #
471
329
  def new_bib_entry(code, year, opts, stdclass, **args)
472
330
  entry = @semaphore.synchronize { args[:db] && args[:db][args[:id]] }
473
331
  if !entry || opts[:no_cache]
@@ -493,21 +351,9 @@ module Relaton
493
351
  args[:no_cache] ? bib_entry(bib) : entry
494
352
  end
495
353
 
496
- #
497
- # If the reference isn't equal to the document identifier
498
- # then store the document in the cache and create
499
- # for the reference a redirection to the document
500
- #
501
- # @param [<Type>] bib <description>
502
- # @param [<Type>] stdclass <description>
503
- # @param [<Type>] **args <description>
504
- #
505
- # @return [<Type>] <description>
506
- #
507
354
  def check_entry(bib, stdclass, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
508
355
  bib_id = bib && bib.docidentifier.first&.content
509
356
 
510
- # when ref isn't equal to bib's id then return a redirection to bib's id
511
357
  quoted = Regexp.quote("(#{bib_id})")
512
358
  if args[:db] && args[:id] && bib_id &&
513
359
  args[:id] !~ /#{quoted}/
@@ -518,21 +364,6 @@ module Relaton
518
364
  end
519
365
  end
520
366
 
521
- #
522
- # @param code [String]
523
- # @param year [String]
524
- #
525
- # @param opts [Hash]
526
- # @option opts [Boolean] :all_parts If all-parts reference is required
527
- # @option opts [Boolean] :keep_year If undated reference should return
528
- # actual reference with year
529
- #
530
- # @param processor [Relaton::Processor]
531
- # @param retries [Integer] remain Number of network retries
532
- #
533
- # @raise [RelatonBib::RequestError]
534
- # @return [RelatonBib::BibliographicItem]
535
- #
536
367
  def net_retry(code, year, opts, processor, retries)
537
368
  fetch_doc code, year, opts, processor
538
369
  rescue Relaton::RequestError => e
@@ -541,15 +372,6 @@ module Relaton
541
372
  net_retry(code, year, opts, processor, retries - 1)
542
373
  end
543
374
 
544
- # @param bib [RelatonBib::BibliographicItem,
545
- # RelatonIsoBib::IsoBibliographicItem, RelatonItu::ItuBibliographicItem,
546
- # RelatonIetf::IetfBibliographicItem, RelatonIec::IecBibliographicItem,
547
- # RelatonIeee::IeeeBibliographicItem, RelatonNist::NistBibliongraphicItem,
548
- # RelatonGb::GbbibliographicItem, RelatonOgc::OgcBibliographicItem,
549
- # RelatonCalconnect::CcBibliographicItem, RelatinUn::UnBibliographicItem,
550
- # RelatonBipm::BipmBibliographicItem, RelatonIho::IhoBibliographicItem,
551
- # RelatonOmg::OmgBibliographicItem, RelatonW3c::W3cBibliographicItem]
552
- # @return [String] XML or "not_found mm-dd-yyyy"
553
375
  def bib_entry(bib)
554
376
  if bib.respond_to?(:to_xml)
555
377
  bib.to_xml(bibdata: true)
@@ -558,12 +380,6 @@ module Relaton
558
380
  end
559
381
  end
560
382
 
561
- # Check if an XML entry's published date falls within the requested range.
562
- # Range semantics: [after, before) — inclusive start, exclusive end.
563
- #
564
- # @param entry [String] XML string
565
- # @param opts [Hash]
566
- # @return [Boolean]
567
383
  def pub_date_in_range?(entry, opts) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
568
384
  doc = Nokogiri::XML(entry)
569
385
  date_str = doc.at("//date[@type='published']/on")&.text
@@ -581,9 +397,6 @@ module Relaton
581
397
  true
582
398
  end
583
399
 
584
- # @param str [String] date string in "YYYY", "YYYY-MM",
585
- # or "YYYY-MM-DD" format
586
- # @return [Date, nil]
587
400
  def parse_pub_date(str)
588
401
  case str
589
402
  when /^\d{4}-\d{1,2}-\d{1,2}/ then Date.parse(str)
@@ -594,12 +407,10 @@ module Relaton
594
407
  nil
595
408
  end
596
409
 
597
- # @param dir [String, nil] DB directory
598
- # @return [Relaton::DbCache, NilClass]
599
410
  def open_cache_biblio(dir) # rubocop:disable Metrics/MethodLength
600
411
  return nil if dir.nil?
601
412
 
602
- db = DbCache.new dir
413
+ db = Cache.new dir
603
414
 
604
415
  Dir["#{dir}/*/"].each do |fdir|
605
416
  next if db.check_version?(fdir)
@@ -610,9 +421,6 @@ module Relaton
610
421
  db
611
422
  end
612
423
 
613
- # @param qwp [Hash]
614
- # @option qwp [Queue] :queue The queue of references to fetch
615
- # @option qwp [Relaton::WorkersPool] :workers_pool The pool of workers
616
424
  def process_queue(qwp)
617
425
  while args = qwp[:queue].pop; qwp[:workers_pool] << args end
618
426
  end
@@ -632,7 +440,7 @@ module Relaton
632
440
  globalname = global_bibliocache_name if opts[:global_cache]
633
441
  localname = local_bibliocache_name(opts[:local_cache])
634
442
  flush_caches globalname, localname if opts[:flush_caches]
635
- Relaton::Db.new(globalname, localname)
443
+ new(globalname, localname)
636
444
  end
637
445
 
638
446
  def flush_caches(gcache, lcache)
@@ -653,3 +461,10 @@ module Relaton
653
461
  end
654
462
  end
655
463
  end
464
+
465
+ require_relative "db/version"
466
+ require_relative "db/util"
467
+ require_relative "db/config"
468
+ require_relative "db/workers_pool"
469
+ require_relative "db/cache"
470
+ require_relative "db/registry"
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.2.0.pre.alpha.1".freeze
3
3
  end
data/lib/relaton.rb CHANGED
@@ -1,10 +1,2 @@
1
- require "relaton/bib"
2
- require "relaton/util"
3
- require "relaton/config"
4
- require "yaml"
5
-
6
- require_relative "relaton/workers_pool"
7
- require_relative "relaton/db"
8
- require_relative "relaton/db_cache"
9
- require_relative "relaton/version"
10
- require_relative "relaton/registry"
1
+ require "relaton/version"
2
+ require "relaton/db"
data/relaton.gemspec CHANGED
@@ -10,14 +10,20 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Ribose Inc."]
11
11
  spec.email = ["open.source@ribose.com"]
12
12
 
13
- spec.summary = "The Relaton core for importing, managing and caching " \
14
- "bibliographic references to technical standards."
13
+ spec.summary = "Relaton: bibliographic references to technical " \
14
+ "standards database, registry, cache, and all " \
15
+ "flavor plugins bundled in one gem."
15
16
  spec.description = <<~DESCRIPTION
16
- The Relaton core for importing, managing and caching bibliographic
17
+ Relaton is the central database, registry, and cache for bibliographic
17
18
  references to technical standards in the Relaton/XML bibliographic
18
- model.
19
+ model. It provides the Relaton::Db API, a plugin registry that lazily
20
+ loads flavor gems (relaton-iso, relaton-ietf, etc.) on demand, and a
21
+ file-based cache for fetched references.
19
22
 
20
- This gem is in active development.
23
+ Installing this gem also pulls in every Relaton flavor plugin so you
24
+ can fetch references from any supported standards body out of the
25
+ box. The CLI (relaton-cli) is intentionally NOT a dependency —
26
+ install it separately when you need command-line access.
21
27
  DESCRIPTION
22
28
 
23
29
  spec.homepage = "https://github.com/relaton/relaton"
@@ -26,36 +32,41 @@ Gem::Specification.new do |spec|
26
32
  spec.bindir = "bin"
27
33
  spec.require_paths = ["lib"]
28
34
  spec.files = `git ls-files`.split("\n")
29
- # spec.test_files = `git ls-files -- {spec}/*`.split("\n")
30
- spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
31
-
32
- spec.add_dependency "relaton-3gpp", "~> 2.1.0"
33
- spec.add_dependency "relaton-bipm", "~> 2.1.0"
34
- spec.add_dependency "relaton-bsi", "~> 2.1.0"
35
- spec.add_dependency "relaton-calconnect", "~> 2.1.0"
36
- spec.add_dependency "relaton-ccsds", "~> 2.1.0"
37
- spec.add_dependency "relaton-cen", "~> 2.1.0"
38
- spec.add_dependency "relaton-cie", "~> 2.1.0"
39
- spec.add_dependency "relaton-doi", "~> 2.1.0"
40
- spec.add_dependency "relaton-ecma", "~> 2.1.0"
41
- spec.add_dependency "relaton-etsi", "~> 2.1.0"
42
- spec.add_dependency "relaton-gb", "~> 2.1.0"
43
- spec.add_dependency "relaton-iana", "~> 2.1.0"
44
- spec.add_dependency "relaton-iec", "~> 2.1.0"
45
- spec.add_dependency "relaton-ieee", "~> 2.1.0"
46
- spec.add_dependency "relaton-ietf", "~> 2.1.0"
47
- spec.add_dependency "relaton-iho", "~> 2.1.0"
48
- spec.add_dependency "relaton-isbn", "~> 2.1.0"
49
- spec.add_dependency "relaton-iso", "~> 2.1.0"
50
- spec.add_dependency "relaton-itu", "~> 2.1.0"
51
- spec.add_dependency "relaton-jis", "~> 2.1.0"
52
- spec.add_dependency "relaton-nist", "~> 2.1.0"
53
- spec.add_dependency "relaton-oasis", "~> 2.1.0"
54
- spec.add_dependency "relaton-ogc", "~> 2.1.0"
55
- spec.add_dependency "relaton-omg", "~> 2.1.0"
56
- spec.add_dependency "relaton-plateau", "~> 2.1.0"
57
- spec.add_dependency "relaton-un", "~> 2.1.0"
58
- spec.add_dependency "relaton-w3c", "~> 2.1.0"
59
- spec.add_dependency "relaton-xsf", "~> 2.1.0"
35
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
36
+
37
+ spec.add_dependency "relaton-bib", "~> 2.2.0.pre.alpha.1"
38
+ spec.add_dependency "relaton-core", "~> 2.2.0.pre.alpha.1"
39
+ spec.add_dependency "relaton-index", "~> 2.2.0.pre.alpha.1"
40
+ spec.add_dependency "relaton-logger", "~> 2.2.0.pre.alpha.1"
41
+
42
+ spec.add_dependency "relaton-3gpp", "~> 2.2.0.pre.alpha.1"
43
+ spec.add_dependency "relaton-bipm", "~> 2.2.0.pre.alpha.1"
44
+ spec.add_dependency "relaton-bsi", "~> 2.2.0.pre.alpha.1"
45
+ spec.add_dependency "relaton-calconnect", "~> 2.2.0.pre.alpha.1"
46
+ spec.add_dependency "relaton-ccsds", "~> 2.2.0.pre.alpha.1"
47
+ spec.add_dependency "relaton-cen", "~> 2.2.0.pre.alpha.1"
48
+ spec.add_dependency "relaton-cie", "~> 2.2.0.pre.alpha.1"
49
+ spec.add_dependency "relaton-doi", "~> 2.2.0.pre.alpha.1"
50
+ spec.add_dependency "relaton-ecma", "~> 2.2.0.pre.alpha.1"
51
+ spec.add_dependency "relaton-etsi", "~> 2.2.0.pre.alpha.1"
52
+ spec.add_dependency "relaton-gb", "~> 2.2.0.pre.alpha.1"
53
+ spec.add_dependency "relaton-iana", "~> 2.2.0.pre.alpha.1"
54
+ spec.add_dependency "relaton-iec", "~> 2.2.0.pre.alpha.1"
55
+ spec.add_dependency "relaton-ieee", "~> 2.2.0.pre.alpha.1"
56
+ spec.add_dependency "relaton-ietf", "~> 2.2.0.pre.alpha.1"
57
+ spec.add_dependency "relaton-iho", "~> 2.2.0.pre.alpha.1"
58
+ spec.add_dependency "relaton-isbn", "~> 2.2.0.pre.alpha.1"
59
+ spec.add_dependency "relaton-iso", "~> 2.2.0.pre.alpha.1"
60
+ spec.add_dependency "relaton-itu", "~> 2.2.0.pre.alpha.1"
61
+ spec.add_dependency "relaton-jis", "~> 2.2.0.pre.alpha.1"
62
+ spec.add_dependency "relaton-nist", "~> 2.2.0.pre.alpha.1"
63
+ spec.add_dependency "relaton-oasis", "~> 2.2.0.pre.alpha.1"
64
+ spec.add_dependency "relaton-ogc", "~> 2.2.0.pre.alpha.1"
65
+ spec.add_dependency "relaton-omg", "~> 2.2.0.pre.alpha.1"
66
+ spec.add_dependency "relaton-plateau", "~> 2.2.0.pre.alpha.1"
67
+ spec.add_dependency "relaton-un", "~> 2.2.0.pre.alpha.1"
68
+ spec.add_dependency "relaton-w3c", "~> 2.2.0.pre.alpha.1"
69
+ spec.add_dependency "relaton-xsf", "~> 2.2.0.pre.alpha.1"
70
+
60
71
  spec.metadata["rubygems_mfa_required"] = "true"
61
72
  end
@@ -1,4 +1,4 @@
1
- describe Relaton do
1
+ describe Relaton::Db do
2
2
  after { described_class.instance_variable_set :@configuration, nil }
3
3
 
4
4
  it "configure" do
@@ -1,7 +1,7 @@
1
1
  require "fileutils"
2
2
  require "timeout"
3
3
 
4
- RSpec.describe Relaton::DbCache do
4
+ RSpec.describe Relaton::Db::Cache do
5
5
  it "creates default caches" do
6
6
  cache_path = File.expand_path("~/.relaton/cache")
7
7
  FileUtils.mv cache_path, "relaton1/cache", force: true
@@ -21,8 +21,8 @@ RSpec.describe Relaton::DbCache do
21
21
  file = File.open(file_name, File::RDWR | File::CREAT, encoding: "UTF-8") # rubocop:disable Style/FileOpen
22
22
  file.flock File::LOCK_EX
23
23
  command = <<~RBY
24
- require "relaton"
25
- cache = Relaton::DbCache.new "testcache"
24
+ require "relaton/db"
25
+ cache = Relaton::Db::Cache.new "testcache"
26
26
  cache["ISO(ISO 123)"] = "test 1"
27
27
  RBY
28
28
  pid = spawn RbConfig.ruby, "-e #{command}"
@@ -38,7 +38,7 @@ RSpec.describe Relaton::DbCache do
38
38
 
39
39
  context "delete file from cache" do
40
40
  it "delete redirect file and its original" do
41
- cache = Relaton::DbCache.new "testcache"
41
+ cache = Relaton::Db::Cache.new "testcache"
42
42
  cache["ISO(ISO 123)"] = "test 1"
43
43
  cache["ISO(123)"] = "redirection ISO(ISO 123)"
44
44
  expect(File.exist?("testcache/iso/iso_123.xml")).to be true
@@ -1,6 +1,6 @@
1
1
  RSpec.describe Relaton::Db do
2
2
  before(:each) do |example|
3
- # Relaton.instance_variable_set :@configuration, nil
3
+ # Relaton::Db.instance_variable_set :@configuration, nil
4
4
  FileUtils.rm_rf %w[testcache testcache2]
5
5
 
6
6
  if example.metadata[:vcr]
@@ -39,7 +39,7 @@ RSpec.describe Relaton::Db do
39
39
  :relaton_iso, db: db, id: "ISO(ISO 123)"
40
40
  expect(entry).to be_nil
41
41
  end.to output(
42
- "[relaton] INFO: (ISO 123) not found in cache, " \
42
+ "[relaton-db] INFO: (ISO 123) not found in cache, " \
43
43
  "if you wish to ignore cache please use " \
44
44
  "`no-cache` option.\n",
45
45
  ).to_stderr_from_any_process
@@ -350,7 +350,7 @@ RSpec.describe Relaton::Db do
350
350
  expect do
351
351
  expect(db.mv("new_cache_dir")).to be_nil
352
352
  end.to output(
353
- /\[relaton\] INFO: target directory exists/,
353
+ /\[relaton-db\] INFO: target directory exists/,
354
354
  ).to_stderr_from_any_process
355
355
  end
356
356
 
@@ -453,7 +453,13 @@ RSpec.describe Relaton::Db do
453
453
  expect(bib).to be_instance_of Relaton::Iso::ItemData
454
454
  end
455
455
 
456
- it "when no local db", vcr: "iso_19115_1" do
456
+ it "when no local db" do
457
+ docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-1",
458
+ type: "ISO")
459
+ item = Relaton::Iso::ItemData.new(docidentifier: [docid],
460
+ fetched: Date.today.to_s)
461
+ expect(Relaton::Iso::Bibliography).to receive(:get)
462
+ .with("ISO 19115-1", nil, {}).and_return item
457
463
  db = Relaton::Db.new "testcache", nil
458
464
  bib = db.fetch("ISO 19115-1", nil, {})
459
465
  expect(bib).to be_instance_of Relaton::Iso::ItemData
@@ -481,7 +487,12 @@ RSpec.describe Relaton::Db do
481
487
  end
482
488
  end
483
489
 
484
- it "fetch std", vcr: "iso_19115_1_std" do
490
+ it "fetch std" do
491
+ docid = Relaton::Bib::Docidentifier.new(content: "ISO 19115-1", type: "ISO")
492
+ item = Relaton::Iso::ItemData.new(docidentifier: [docid],
493
+ fetched: Date.today.to_s)
494
+ expect(Relaton::Iso::Bibliography).to receive(:get)
495
+ .with("ISO 19115-1", nil, {}).and_return item
485
496
  db = Relaton::Db.new "testcache", nil
486
497
  bib = db.fetch_std("ISO 19115-1", nil, :relaton_iso, {})
487
498
  expect(bib).to be_instance_of Relaton::Iso::ItemData
@@ -537,7 +548,7 @@ RSpec.describe Relaton::Db do
537
548
  expect(subject).to receive(:fetch).and_raise Errno::EACCES
538
549
  log_io = Relaton.logger_pool[:default].instance_variable_get(:@logdev)
539
550
  expect(log_io).to receive(:write).with(
540
- "[relaton] ERROR: `ISO REF` -- Permission denied\n",
551
+ "[relaton-db] ERROR: `ISO REF` -- Permission denied\n",
541
552
  )
542
553
  subject.fetch_async("ISO REF") { |r| queue << r }
543
554
  result = Timeout.timeout(5) { queue.pop }
@@ -547,7 +558,7 @@ RSpec.describe Relaton::Db do
547
558
  it "use threads number from RELATON_FETCH_PARALLEL" do
548
559
  expect(ENV).to receive(:[]).with("RELATON_FETCH_PARALLEL").and_return(1)
549
560
  allow(ENV).to receive(:[]).and_call_original
550
- expect(Relaton::WorkersPool).to receive(:new).with(1).and_call_original
561
+ expect(Relaton::Db::WorkersPool).to receive(:new).with(1).and_call_original
551
562
  expect(subject).to receive(:fetch).with("ITU-T G.993.5", nil, {})
552
563
  subject.fetch_async("ITU-T G.993.5") { |r| queue << r }
553
564
  Timeout.timeout(50) { queue.pop }