relaton 1.20.1 → 2.0.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rubocop.yml +48 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +2 -2
  5. data/CLAUDE.md +70 -0
  6. data/Gemfile +5 -5
  7. data/Rakefile +1 -1
  8. data/bin/rspec +1 -2
  9. data/docs/README.adoc +110 -83
  10. data/lib/relaton/config.rb +2 -3
  11. data/lib/relaton/db.rb +115 -33
  12. data/lib/relaton/db_cache.rb +3 -2
  13. data/lib/relaton/registry.rb +23 -30
  14. data/lib/relaton/util.rb +2 -1
  15. data/lib/relaton/version.rb +1 -1
  16. data/lib/relaton/workers_pool.rb +1 -1
  17. data/lib/relaton.rb +6 -7
  18. data/relaton.gemspec +31 -30
  19. data/spec/relaton/db_cache_spec.rb +1 -1
  20. data/spec/relaton/db_spec.rb +271 -40
  21. data/spec/relaton/registry_spec.rb +43 -41
  22. data/spec/relaton/util_spec.rb +1 -0
  23. data/spec/relaton_spec.rb +356 -168
  24. data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +12598 -12555
  25. data/spec/vcr_cassetes/api_relaton_org.yml +9 -9
  26. data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +76 -78
  27. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +51 -45
  28. data/spec/vcr_cassetes/cie_001_1980.yml +305 -265
  29. data/spec/vcr_cassetes/cipm_meeting_43.yml +1384 -1381
  30. data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +57 -64
  31. data/spec/vcr_cassetes/ecma_6.yml +185 -241
  32. data/spec/vcr_cassetes/en_10160_1999.yml +13290 -12653
  33. data/spec/vcr_cassetes/gb_t_20223_2006.yml +458 -458
  34. data/spec/vcr_cassetes/ieee_528_2019.yml +2635 -2250
  35. data/spec/vcr_cassetes/iso_19115_1.yml +13695 -13755
  36. data/spec/vcr_cassetes/iso_19115_1_2.yml +239 -248
  37. data/spec/vcr_cassetes/iso_19115_1_std.yml +13693 -13753
  38. data/spec/vcr_cassetes/iso_19115_all_parts.yml +164 -171
  39. data/spec/vcr_cassetes/iso_19133_2005.yml +85 -81
  40. data/spec/vcr_cassetes/iso_combined_applied.yml +242 -241
  41. data/spec/vcr_cassetes/iso_combined_included.yml +243 -242
  42. data/spec/vcr_cassetes/iso_dis.yml +89 -90
  43. data/spec/vcr_cassetes/ogc_19_025r1.yml +251 -242
  44. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +275 -1514
  45. data/spec/vcr_cassetes/rfc_8341.yml +1094 -1074
  46. metadata +64 -67
  47. data/.hound.yml +0 -3
  48. data/lib/relaton/processor.rb +0 -46
  49. data/spec/relaton/processor_spec.rb +0 -113
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13dbf084ccd28b8edc98d3e9b8774eb6eef7998f73627332fb7f92809cf635fd
4
- data.tar.gz: d81e1084ff58259e9d2f91d1cbbb1b6590ab6531a15f643209091fcdba1ea978
3
+ metadata.gz: 72340d2ac1023cae6be18414bf12e0aab5ffdf24d2385d2025bd91785d99f933
4
+ data.tar.gz: e995b4afd240b028524f1c174a28780aab74a9a20eab9b19ae4a288cee38ae16
5
5
  SHA512:
6
- metadata.gz: b6191397dde96436e07a88c62b4995991f50b1aae1d347a52b5ee5262e494498a4c7991ff62e9924086e39023956342900a914d527b77bfa8299b2b97c13b89d
7
- data.tar.gz: 817aca4c0d54b585cffa7d14c1645fa9bcd078aa281ab33aaa51e8c2cc125a07d4ea6a268b62b507baa06dce66410c2d2cd46a9fb7fd0ad019636e6470ce9d6b
6
+ metadata.gz: caa95533b83a97042cac9886ea93b4149b73a6d57e4f47b88b297d0a2a08d0f1d884be7092feab7d9daaf3f870578e6be3dd41e26c1c4ec2ad60814b8eaa9105
7
+ data.tar.gz: dd627fbe5b2bf14d06805aa04ae7a5dd5a60cbb67ba6c93e71fb44151e736a30976bccff5cbcf11fd7a0665dffa4f6767a84e26dc3eac57ac22a61d02db7fc95
@@ -0,0 +1,48 @@
1
+ name: Rubocop
2
+
3
+ on: pull_request
4
+
5
+ permissions:
6
+ contents: read
7
+ pull-requests: write
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 1
16
+ - name: Determine Ruby version for ruby/setup-ruby
17
+ shell: bash
18
+ run: |
19
+ RUBY_VERSION=${{ vars.RUBY_VERSION }}
20
+
21
+ if [[ -r .rubocop.yml ]]
22
+ then
23
+ RUBY_VERSION=$( \
24
+ command grep \
25
+ -E '^\s*TargetRubyVersion:\s*[0-9]+(\.[0-9]+)*' \
26
+ .rubocop.yml \
27
+ | command awk '{print $2}' \
28
+ )
29
+ fi
30
+
31
+ if [[ -z $RUBY_VERSION ]]
32
+ then
33
+ # Let setup-ruby determine the Ruby version if no .ruby-version,
34
+ # .tool-versions or mise.toml file exists
35
+ RUBY_VERSION=default
36
+ fi
37
+
38
+ echo "RUBY_VERSION=$RUBY_VERSION" >> $GITHUB_ENV
39
+ - uses: ruby/setup-ruby@v1
40
+ with:
41
+ # input ruby-version needs to be specified if no .ruby-version,
42
+ # .tool-versions or mise.toml file exists
43
+ #
44
+ # Use the version that matches the one in gemspec & .rubocop.yml
45
+ ruby-version: ${{ env.RUBY_VERSION }}
46
+ - uses: reclaim-the-stack/rubocop-action@v1.1.0
47
+ with:
48
+ gem_versions: rubocop:1.84.2 rubocop-performance:1.26.1 rubocop-rails:2.34.3
data/.gitignore CHANGED
@@ -8,3 +8,5 @@ testcache2
8
8
  .vscode/
9
9
  pkg/
10
10
  Gemfile.lock
11
+ .rubocop-remote-87c7cdd254a8d09d005ee06efac7acc0.yml
12
+ .claude/
data/.rubocop.yml CHANGED
@@ -2,11 +2,11 @@
2
2
  # https://github.com/riboseinc/oss-guides
3
3
  # All project-specific additions and overrides should be specified in this file.
4
4
 
5
- require: rubocop-rails
5
+ plugins: rubocop-rails
6
6
 
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 3.0
10
+ TargetRubyVersion: 3.2
11
11
  Rails:
12
12
  Enabled: false
data/CLAUDE.md ADDED
@@ -0,0 +1,70 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ # Run full test suite
9
+ bundle exec rake # or: bundle exec rspec
10
+
11
+ # Run a single spec file
12
+ bundle exec rspec spec/relaton/db_spec.rb
13
+
14
+ # Run a specific test by line number
15
+ bundle exec rspec spec/relaton/db_spec.rb:234
16
+
17
+ # Lint
18
+ bundle exec rubocop
19
+
20
+ # Lint with auto-fix
21
+ bundle exec rubocop -a
22
+ ```
23
+
24
+ ## Architecture
25
+
26
+ Relaton is a Ruby gem that fetches, caches, and manages bibliographic references to technical standards from 25+ organizations (ISO, IEC, IETF, NIST, IEEE, etc.).
27
+
28
+ ### Plugin Registry Pattern
29
+
30
+ **Relaton::Registry** (singleton) auto-discovers and manages backend processor gems (relaton-iso, relaton-iec, relaton-ietf, etc.). Each processor implements the **Relaton::Processor** interface (`get`, `from_xml`, `from_yaml`, `grammar_hash`, `prefix`, `defaultprefix`). The registry routes reference codes to the correct processor by matching prefixes (e.g., "ISO 19115" → `:relaton_iso`).
31
+
32
+ ### Db (lib/relaton/db.rb) — Main Public API
33
+
34
+ `Relaton::Db#fetch(ref, year, opts)` is the primary entry point. It:
35
+ 1. Identifies the processor via Registry prefix matching
36
+ 2. Handles combined references (`+` for derivedFrom, `,` for amendments) in `combine_doc`
37
+ 3. Delegates to `check_bibliocache` which manages the dual-cache lookup and network fetch flow
38
+
39
+ `Relaton::Db#fetch_all(text, edition, year)` searches cached entries, filtering by text content (via `match_xml_text?`), edition, and/or year. Returns an array of deserialized bibliographic items from both local and global caches.
40
+
41
+ The dual-cache strategy uses a **global cache** (`~/.relaton/cache`) and an optional **local cache** (project-level). `check_bibliocache` checks local first, falls back to global, and syncs between them.
42
+
43
+ ### DbCache (lib/relaton/db_cache.rb) — File-based Storage
44
+
45
+ Stores entries as files under `{dir}/{prefix}/{filename}.{ext}` (e.g., `testcache/iso/iso_19115-1.xml`). Key behaviors:
46
+ - Cache keys are wrapped like `ISO(ISO 19115-1:2014)` and converted to filenames via regex
47
+ - Entries can be XML, "not_found {date}", or "redirection {target_key}"
48
+ - Undated references expire after 60 days; dated ones persist indefinitely
49
+ - Version tracking per prefix directory invalidates cache when processor grammar changes
50
+ - File locking (`LOCK_EX`) for thread-safe concurrent writes
51
+
52
+ ### WorkersPool (lib/relaton/workers_pool.rb)
53
+
54
+ Thread pool for `fetch_async`. Default 10 threads per processor, overridable via `RELATON_FETCH_PARALLEL` env var.
55
+
56
+ ### Cache Key Format
57
+
58
+ `std_id` builds keys like `ISO(ISO 19115-1:2014 (all parts) after-2020-01-01)`. The filename regex in `db_cache.rb` uses `[^)]+` — suffixes use `-` not parentheses to avoid breaking it.
59
+
60
+ ## Testing
61
+
62
+ - RSpec with VCR cassettes in `spec/vcr_cassetes/` for recorded HTTP interactions
63
+ - Tests create `testcache`/`testcache2` directories and clean them in `before(:each)`
64
+ - Cache-related tests need `<fetched>` elements in XML for `valid_entry?` to return true
65
+ - Integration tests in `spec/relaton_spec.rb`; unit tests mirror `lib/` structure under `spec/relaton/`
66
+
67
+ ## Style
68
+
69
+ - RuboCop config inherits from [Ribose OSS guides](https://github.com/riboseinc/oss-guides), target Ruby 3.2
70
+ - Thread safety via `@semaphore` (Mutex) around cache reads/writes in Db
data/Gemfile CHANGED
@@ -3,16 +3,16 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in gemspec
4
4
  gemspec
5
5
 
6
- gem "byebug", "~> 11.0"
6
+ gem "byebug"
7
7
  gem "equivalent-xml", "~> 0.6"
8
8
  gem "guard", "~> 2.14"
9
9
  gem "guard-rspec", "~> 4.7"
10
- gem "pry-byebug", "~> 3.9.0"
10
+ gem "pry-byebug"
11
11
  gem "rake", "~> 13.0"
12
12
  gem "rspec", "~> 3.6"
13
- gem "rubocop", "~> 1.17.0"
14
- gem "rubocop-performance", "~> 1.11.0"
15
- gem "rubocop-rails", "~> 2.10.0"
13
+ gem "rubocop"
14
+ gem "rubocop-performance"
15
+ gem "rubocop-rails"
16
16
  gem "simplecov", "~> 0.15"
17
17
  gem "timecop", "~> 0.9"
18
18
  gem "vcr", "~> 6"
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/rspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+
3
3
  # This file was generated by Bundler.
4
4
  #
5
5
  # The application 'rspec' is installed as part of a gem, and
@@ -15,4 +15,3 @@ require "rubygems"
15
15
  require "bundler/setup"
16
16
 
17
17
  load Gem.bin_path("rspec-core", "rspec")
18
-
data/docs/README.adoc CHANGED
@@ -29,6 +29,7 @@ Relaton imports bibliographic entries from:
29
29
  * CIE through the techstreet.com website, via the https://github.com/relaton/relaton-cie[relaton-cie] gem
30
30
  * DOI through the api.crossref.org website, via the https://github.com/relaton/relaton-doi[relaton-doi] gem
31
31
  * ECMA through the ecma-international.org website, via the https://github.com/relaton/relaton-ecma[relaton-ecma] gem
32
+ * ETSI through the etsi.org website, via the https://github.com/relaton/relaton-etsi[relaton-etsi] gem
32
33
  * GB (Chinese national standards) through the GB websites, via the https://github.com/relaton/relaton-gb[relaton-gb] gem
33
34
  * IANA through the https://github.com/ietf-tools/iana-registries[iana-registries] dataset, via the https://github.com/relaton/relaton-iana[relaton-iana] gem
34
35
  * IEC through the iec.ch website, via the https://github.com/relaton/relaton-iec[relaton-iec] gem
@@ -37,11 +38,13 @@ Relaton imports bibliographic entries from:
37
38
  * IHO through the iho.int website, via the https://github.com/relaton/relaton-iho[relaton-iho] gem
38
39
  * ISO through the iso.org website, via the https://github.com/relaton/relaton-iso[relaton-iso] gem
39
40
  * ITU through the itu.int website, via the https://github.com/relaton/relaton-itu[relaton-itu] gem
40
- * JIS through the webdesk.jsa.or.jp website, via the https://gihub.com/relaton/relaton-jis[relaton-jis] gem
41
- * NIST standards through the nist.gov website, via the https://github.com/relaton/relaton-nist[relaotn-nist] gem
41
+ * ISBN through the openlibrary.org website, via the https://github.com/relaton/relaton-isbn[relaton-isbn] gem
42
+ * JIS through the webdesk.jsa.or.jp website, via the https://github.com/relaton/relaton-jis[relaton-jis] gem
43
+ * NIST standards through the nist.gov website, via the https://github.com/relaton/relaton-nist[relaton-nist] gem
42
44
  * OASIS through the www.oasis-open.org/standards website, via the https://github.com/relaton/relaton-oasis[relaton-oasis] gem
43
- * OGC through the https://github.com/opengeospatial/NamingAuthority[dataset], via the https://gibhub.com/relaton/relaton-ogc[relaton-ogc] gem
45
+ * OGC through the https://github.com/opengeospatial/NamingAuthority[dataset], via the https://github.com/relaton/relaton-ogc[relaton-ogc] gem
44
46
  * OMG through the omg.org/spec website, via the https://github.com/relaton/relaton-omg[relaton-omg] gem
47
+ * Plateau through the www.mlit.go.jp website, via the https://github.com/relaton/relaton-plateau[relaton-plateau] gem
45
48
  * UN through the documents.un.org website, via the https://github.com/relaton/relaton-un[relaton-un] gem
46
49
  * W3C through the w3c.org website, via the https://github.com/relaton/relaton-w3c[relaton-w3c] gem
47
50
  * XSF through the xmpp.org website, via the https://github.com/relaton/relaton-xsf[relaton-xsf] gem
@@ -82,7 +85,6 @@ e.g. `get("ISO 19115-1", "2014", all_parts: true)` is transformed into a referen
82
85
 
83
86
  === Configuration
84
87
 
85
- * `logger` - `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level.
86
88
  * `use_api` - `true` if it needs to use an online cache, `false` if not. The default value is `true`.
87
89
  * `api_host` - URL of an online cache. The default value is https://api.relaton.org.
88
90
 
@@ -92,12 +94,20 @@ require "relaton"
92
94
  => true
93
95
 
94
96
  Relaton.configure do |conf|
95
- conf.logger.level = Logger::DEBUG
96
97
  conf.use_api = true
97
98
  conf.api_host = "https://api.relaton.org"
98
99
  end
99
100
  ----
100
101
 
102
+ Logger configuration is managed through the `relaton-logger` gem via `Relaton.logger_pool`:
103
+
104
+ [source,ruby]
105
+ ----
106
+ require "relaton"
107
+
108
+ Relaton.logger_pool[:default] = Relaton::Logger::Log.new($stderr, levels: [:debug, :info, :warn, :error, :fatal])
109
+ ----
110
+
101
111
  === Create DB
102
112
 
103
113
  `Relaton::Db#new(globalcache, localcache)` creates new DB. Returns Relaton::Db instance.
@@ -109,29 +119,17 @@ end
109
119
  ----
110
120
  # Do not cache any entries retrieved
111
121
  db = Relaton::Db.new(nil, nil)
112
- => #<Relaton::Db:0x007faaaba77648
113
- @db=nil,
114
- @db_name=nil,
115
- @local_db=nil,
116
- @local_db_name=nil,
122
+ => #<Relaton::Db:0x0000000127622a50
117
123
  ...
118
124
 
119
125
  # Use only the global cache for any entries retrieved
120
126
  db = Relaton::Db.new("globalcache", nil)
121
- => #<Relaton::Db:0x007faabc0e7b30
122
- @db=#<Relaton::DbCache:0x007faabc0e7ab8 @dir="globalcache", @ext="xml">,
123
- @db_name="globalcache",
124
- @local_db=nil,
125
- @local_db_name=nil,
127
+ => #<Relaton::Db:0x00000001277cd120
126
128
  ...
127
129
 
128
130
  # Use both a local and a global cache
129
131
  db = Relaton::Db.new("globalcache", "localcache")
130
- => #<Relaton::Db:0x007faabc900628
131
- @db=#<Relaton::DbCache:0x007faabc900060 @dir="globalcache", @ext="xml">,
132
- @db_name="globalcache",
133
- @local_db=#<Relaton::DbCache:0x007faabc8fa5c0 @dir="localcache", @ext="xml">,
134
- @local_db_name="localcache",
132
+ => #<Relaton::Db:0x0000000127aaf6e0
135
133
  ...
136
134
  ----
137
135
 
@@ -157,7 +155,7 @@ db.mv("new_local_dir", type: :local)
157
155
 
158
156
  `Relaton::Db#clear` removes all entries form DB
159
157
 
160
- === Fetch documens
158
+ === Fetch documents
161
159
 
162
160
  ==== Fetch document by references
163
161
 
@@ -169,13 +167,15 @@ There are 3 fetching methods:
169
167
 
170
168
  Arguments:
171
169
 
172
- * `reference` - (String) reference to fethc document
173
- * `year` - (String or nil) year to filter relult (optional)
174
- * `options` - (Hash) hash of options. Alloved options:
170
+ * `reference` - (String) reference to fetch document
171
+ * `year` - (String or nil) year to filter result (optional)
172
+ * `options` - (Hash) hash of options. Allowed options:
175
173
  - `:all_parts` - (Boolean) should be `true` if all-parts reference is required
176
- - `:keep_yer` - (Boolean) should be `true` if undated reference should return an actual reference with the year
174
+ - `:keep_year` - (Boolean) should be `true` if undated reference should return an actual reference with the year
177
175
  - `:retries` - (Number) number of network retries. Default 1
178
176
  - `:no_cache` - (Boolean) should be `true` if cache should be ignored
177
+ - `:publication_date_after` - (String) filter for documents published on or after this date (inclusive, `"YYYY-MM-DD"`)
178
+ - `:publication_date_before` - (String) filter for documents published before this date (exclusive, `"YYYY-MM-DD"`)
179
179
 
180
180
  [source,ruby]
181
181
  ----
@@ -185,34 +185,34 @@ x = db.fetch("IEEE 19011")
185
185
  => nil
186
186
 
187
187
  x = db.fetch("ISO 19011")
188
- [relaton-iso] (ISO 19011) fetching...
189
- [relaton-iso] (ISO 19011) found `ISO 19011 (all parts)`
190
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ab2f00
188
+ [relaton-iso] INFO: (ISO 19011) Fetching from Relaton repository ...
189
+ [relaton-iso] INFO: (ISO 19011) Found: `ISO 19011:2018`
190
+ => #<Relaton::Iso::ItemData:0x0000000128631e00
191
191
  ...
192
192
 
193
193
  x = db.fetch("ISO 19011", "2011", retries: 3)
194
- [relaton-iso] (ISO 19011) fetching...
195
- [relaton-iso] (ISO 19011) found `ISO 19011:2011`
196
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d2593068
194
+ [relaton-iso] INFO: (ISO 19011:2011) Fetching from Relaton repository ...
195
+ [relaton-iso] INFO: (ISO 19011:2011) Found: `ISO 19011:2011`
196
+ => #<Relaton::Iso::ItemData:0x000000013af95020
197
197
  ...
198
198
 
199
199
  x = db.fetch("ISO 19115", nil, all_parts: true)
200
- [relaton-iso] (ISO 19115) fetching...
201
- [relaton-iso] (ISO 19115) found `ISO 19115 (all parts)`
202
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ae8bf0
200
+ [relaton-iso] INFO: (ISO 19115 (all parts)) Fetching from Relaton repository ...
201
+ [relaton-iso] INFO: (ISO 19115 (all parts)) Found: `ISO 19115 (all parts)`
202
+ => #<Relaton::Iso::ItemData:0x00000001276f7f98
203
203
  ...
204
204
 
205
- # Fetchig from local cache
205
+ # Fetching from local cache
206
206
 
207
207
  x = db.fetch("ISO 19011")
208
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fde5f48a9f0
208
+ => #<Relaton::Db:0x00000001390b0b00
209
209
  ...
210
210
 
211
211
  x = db.fetch_db("ISO 5749")
212
212
  => nil
213
213
 
214
214
  # Fetching asynchronously
215
- # RELATON_FETCH_PARALLEL environment variable can be used to ovveride default number of parallel fetches
215
+ # RELATON_FETCH_PARALLEL environment variable can be used to override default number of parallel fetches
216
216
 
217
217
  # prepare queue for results
218
218
  results = Queue.new
@@ -235,6 +235,37 @@ refs.size.times do
235
235
  end
236
236
  ----
237
237
 
238
+ ==== Fetch with publication date filter
239
+
240
+ The `:publication_date_after` and `:publication_date_before` options restrict results to documents published within a date range. The range is inclusive of `:publication_date_after` and exclusive of `:publication_date_before`.
241
+
242
+ When a date filter is used, the cache is checked first for an existing entry whose publication date satisfies the range. If no match is found, a date-specific cache entry is created.
243
+
244
+ [source,ruby]
245
+ ----
246
+ # Fetch documents published on or after 2018-01-01
247
+ x = db.fetch("IEC 80000-6", nil, publication_date_after: Date.parse("2018-01-01"))
248
+ [relaton-iec] INFO: (IEC 80000-6) Fetching from Relaton repository ...
249
+ [relaton-iec] INFO: (IEC 80000-6) Found: `IEC 80000-6:2022`
250
+ => #<Relaton::Iec::ItemData:0x000000013f311920
251
+ ...
252
+
253
+ # Fetch documents published before 2020-01-01
254
+ x = db.fetch("IEC 80000-6", nil, publication_date_before: Date.parse("2020-01-01"))
255
+ [relaton-iec] INFO: (IEC 80000-6) Fetching from Relaton repository ...
256
+ [relaton-iec] INFO: (IEC 80000-6) Found: `IEC 80000-6:2008`
257
+ => #<Relaton::Iec::ItemData:0x00000001282b5290
258
+ ...
259
+
260
+ # Fetch documents published within a range
261
+ x = db.fetch("IEC 80000-6", nil, publication_date_after: Date.parse("2018-01-01"), publication_date_before: Date.parse("2020-01-01"))
262
+ [relaton-iec] INFO: (IEC 80000-6) Fetching from Relaton repository ...
263
+ [relaton-iec] INFO: (IEC 80000-6) Not found.
264
+ [relaton-iec] INFO: (IEC 80000-6) TIP: No match for type, but matches exist: `IEC 80000-6:2008`, `IEC 80000-6:2022`.
265
+ [relaton-iec] INFO: (IEC 80000-6) TIP: No match for type, but matches exist: `IEC 80000-6:2008`, `IEC 80000-6:2022`.
266
+ => nil
267
+ ----
268
+
238
269
  ==== Fetch by URN
239
270
 
240
271
  This functionality works only for IEC documents.
@@ -242,9 +273,9 @@ This functionality works only for IEC documents.
242
273
  [source,ruby]
243
274
  ----
244
275
  x = db.fetch "urn:iec:std:iec:60050-102:2007:::"
245
- [relaton-iec] (IEC 60050-102) fetching...
246
- [relaton-iec] (IEC 60050-102) found `IEC 60050-102:2007`
247
- => #<RelatonIec::IecBibliographicItem:0x007fbd6c3790e8
276
+ [relaton-iec] INFO: (IEC 60050-102:2007) Fetching from Relaton repository ...
277
+ [relaton-iec] INFO: (IEC 60050-102:2007) Found: `IEC 60050-102:2007`
278
+ => #<Relaton::Iec::ItemData:0x0000000130e37a98
248
279
  ...
249
280
  ----
250
281
 
@@ -256,56 +287,52 @@ This functionality works only for ISO, IEC, ITU, and NIST documents.
256
287
  [source,ruby]
257
288
  ----
258
289
  bib = db.fetch "ISO 19115-1 + Amd 1"
259
- [relaton-iso] (ISO 19115-1) fetching...
260
- [relaton-iso] (ISO 19115-1) found `ISO 19115-1:2014`
261
- [relaton-iso] (ISO 19115-1/Amd 1) fetching...
262
- [relaton-iso] (ISO 19115-1/Amd 1) found ISO `19115-1:2014/Amd 1:2018`
263
- => #<RelatonIsoBib::IsoBibliographicItem:0x007f95a929a748
290
+ [relaton-iso] INFO: (ISO 19115-1) Fetching from Relaton repository ...
291
+ [relaton-iso] INFO: (ISO 19115-1) Found: `ISO 19115-1:2014`
292
+ [relaton-iso] INFO: (ISO 19115-1/Amd 1) Fetching from Relaton repository ...
293
+ [relaton-iso] INFO: (ISO 19115-1/Amd 1) Found: `ISO 19115-1:2014/Amd 1:2018`
294
+ => #<Relaton::Iso::ItemData:0x000000012782e4c0
295
+ ...
264
296
 
265
- bib.docidentifier[0].id
297
+ bib.docidentifier[0].content.to_s
266
298
  => "ISO 19115-1 + Amd 1"
267
299
 
268
300
  bib.relation[0].type
269
301
  => "updates"
270
302
 
271
- bib.relation[0].bibitem.docidentifier[0].id
303
+ bib.relation[0].bibitem.docidentifier[0].content.to_s
272
304
  => "ISO 19115-1"
273
305
 
274
306
  bib.relation[1].type
275
307
  => "derivedFrom"
276
308
 
277
- bib.relation[1].bibitem.docidentifier[0].id
278
- => "ISO 19115-1/Amd 1:2018"
309
+ bib.relation[1].bibitem.docidentifier[0].content.to_s
310
+ => "ISO 19115-1/Amd 1"
311
+ ----
279
312
 
280
- bib.docidentifier[0].id
313
+ ==== Fetch applied documents
314
+ [source,ruby]
315
+ ----
316
+ bib = db.fetch "ISO 19115-1, Amd 1"
317
+ => #<Relaton::Iso::ItemData:0x00000001265d5f08
318
+
319
+ bib.docidentifier[0].content.to_s
281
320
  => "ISO 19115-1, Amd 1"
282
321
 
283
322
  bib.relation[0].type
284
323
  => "updates"
285
324
 
286
- bib.relation[0].bibitem.docidentifier[0].id
325
+ bib.relation[0].bibitem.docidentifier[0].content.to_s
287
326
  => "ISO 19115-1"
288
327
 
289
328
  bib.relation[1].type
290
329
  => "complements"
291
330
 
292
- bib.relation[1].description
331
+ bib.relation[1].description.content
293
332
  => "amendment"
294
333
 
295
- bib.relation[1].bibitem.docidentifier[0].id
296
- => "ISO 19115-1/Amd 1:2018"
297
- ----
298
-
299
- ==== Fetch applied documents
300
- [source,ruby]
301
- ----
302
- bib = db.fetch "ISO 19115-1, Amd 1"
303
- => ["Chinese Standard", "GB/T 1.1"]
304
- [relaton-iso] (ISO 19115-1) fetching...
305
- [relaton-iso] (ISO 19115-1) found ISO `19115-1:2014`
306
- [relaton-iso] (ISO 19115-1/Amd 1) fetching...
307
- [relaton-iso] (ISO 19115-1/Amd 1) found ISO `19115-1:2014/Amd 1:2018`
308
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fb09b36d1b8
334
+ bib.relation[1].bibitem.docidentifier[0].content.to_s
335
+ => "ISO 19115-1/Amd 1"
309
336
  ...
310
337
  ----
311
338
 
@@ -319,28 +346,28 @@ bib = db.fetch "ISO 19115-1, Amd 1"
319
346
 
320
347
  [source,ruby]
321
348
  ----
322
- # query for all entries in a cahche
349
+ # query for all entries in a cache
323
350
 
324
351
  items = db.fetch_all
325
- => [#<RelatonIec::IecBibliographicItem:0x007facda8fdc28
352
+ => [#<Relaton::Iso::ItemData:0x00000001265d5c88
326
353
  ...
327
354
 
328
355
  items.size
329
356
  => 6
330
357
 
331
- # query for all entries in a cahche for a certain string
358
+ # query for all entries in a cache for a certain string
332
359
 
333
360
  items = db.fetch_all("mathematical terminology")
334
- => [#<RelatonIec::IecBibliographicItem:0x007ffeae5bd240
361
+ => [<Relaton::Iec::ItemData:0x0000000125dabd50
335
362
  ...
336
363
 
337
364
  items.size
338
365
  => 1
339
366
 
340
- items[0].docidentifier[0].id
367
+ items[0].docidentifier[0].content.to_s
341
368
  => "IEC 60050-102:2007"
342
369
 
343
- # query for all entries in a cahche for a certain string and edition
370
+ # query for all entries in a cache for a certain string and edition
344
371
 
345
372
  items = db.fetch_all("system", edition: "2")
346
373
  => [#<RelatonIsoBib::IsoBibliographicItem:0x007ffebe2d1be8
@@ -352,17 +379,17 @@ items.size
352
379
  items[0].docidentifier[0].id
353
380
  => "ISO 19011:2011"
354
381
 
355
- # query for all entries in a cahche for a certain string and year
382
+ # query for all entries in a cache for a certain string and year
356
383
 
357
- items = db.fetch_all("system", year: 2018)
358
- => [#<RelatonIsoBib::IsoBibliographicItem:0x007ffeae645fa0
384
+ items = db.fetch_all("Electromagnetism", edition: "2")
385
+ => [#<Relaton::Iec::ItemData:0x0000000123a93e80
359
386
  ...
360
387
 
361
388
  items.size
362
389
  => 1
363
390
 
364
- items[0].docidentifier[0].id
365
- => "ISO 19011 (all parts)"
391
+ items[0].docidentifier[0].content.to_s
392
+ => "IEC 80000-6:2022"
366
393
  ----
367
394
 
368
395
  === Get document type
@@ -376,29 +403,29 @@ db.docid_type("CN(GB/T 1.1)")
376
403
  [source,ruby]
377
404
  ----
378
405
  x.to_xml
379
- => "<bibitem id="ISO19115(allparts)" type="standard">
406
+ => "<bibitem id="IEC600501022007" type="standard" schema-version="v1.4.1">
380
407
  ...
381
408
  </bibitem>"
382
409
 
383
410
  db.to_xml
384
411
  => "<?xml version"1.0" encoding="UTF-8"?>
385
412
  <documents>
386
- <bibdata type="standard">
413
+ <bibdata type="standard" schema-version="v1.4.1">
387
414
  ...
388
415
  </bibdata>
389
- <bibdata type="standard">
416
+ <bibdata type="standard" schema-version="v1.4.1">
390
417
  ...
391
418
  </bibdata>
392
419
  ...
393
420
  </documents"
394
421
 
395
422
  x.to_xml bibdata: true
396
- => "<bibdata type="standard">
423
+ => "<bibdata type="standard" schema-version="v1.4.1">
397
424
  ...
398
425
  </bibdata>"
399
426
 
400
427
  db.load_entry("ISO(ISO 19011)")
401
- => "<bibdata type="standard">
428
+ => "<bibdata type="standard" schema-version="v1.4.1">
402
429
  ...
403
430
  </bibdata>"
404
431
  ----
@@ -407,7 +434,7 @@ db.load_entry("ISO(ISO 19011)")
407
434
  [source,ruby]
408
435
  ----
409
436
  db.save_entry("ISO(ISO 19011)", nil)
410
- => nil
437
+ => true
411
438
 
412
439
  db.load_entry("ISO(ISO 19011)")
413
440
  => nil
@@ -8,10 +8,9 @@ module Relaton
8
8
  @configuration ||= self::Configuration.new
9
9
  end
10
10
  end
11
- extend Config
12
-
13
- class Configuration # < RelatonBib::Configuration
14
11
 
12
+ # < RelatonBib::Configuration
13
+ class Configuration
15
14
  attr_accessor :use_api, :api_host
16
15
 
17
16
  def initialize