relaton 1.7.pre7 → 1.7.0

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/macos.yml +34 -0
  3. data/.github/workflows/ubuntu.yml +32 -0
  4. data/.github/workflows/windows.yml +35 -0
  5. data/docs/README.adoc +3 -233
  6. data/lib/relaton/config.rb +2 -3
  7. data/lib/relaton/db.rb +35 -247
  8. data/lib/relaton/db_cache.rb +6 -28
  9. data/lib/relaton/processor.rb +0 -11
  10. data/lib/relaton/registry.rb +1 -1
  11. data/lib/relaton/version.rb +1 -1
  12. data/lib/relaton.rb +7 -8
  13. data/relaton.gemspec +6 -8
  14. data/spec/relaton/db_cache_spec.rb +1 -1
  15. data/spec/relaton/db_spec.rb +0 -145
  16. data/spec/relaton/processor_spec.rb +0 -4
  17. data/spec/relaton/regirtry_spec.rb +44 -54
  18. data/spec/relaton_spec.rb +19 -120
  19. data/spec/vcr_cassetes/19133_2005.yml +20 -20
  20. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +10 -10
  21. data/spec/vcr_cassetes/fisp_140.yml +6 -6
  22. data/spec/vcr_cassetes/gb_t_20223_2006.yml +11 -15
  23. data/spec/vcr_cassetes/ieee_528_2019.yml +17 -17
  24. data/spec/vcr_cassetes/iho_b_11.yml +15 -15
  25. data/spec/vcr_cassetes/iso_111111119115_1.yml +5 -5
  26. data/spec/vcr_cassetes/iso_19115.yml +22 -22
  27. data/spec/vcr_cassetes/iso_19115_1.yml +20 -20
  28. data/spec/vcr_cassetes/iso_19115_1_2.yml +39 -39
  29. data/spec/vcr_cassetes/iso_awi_24229.yml +22 -22
  30. data/spec/vcr_cassetes/ogc_19_025r1.yml +1902 -2554
  31. data/spec/vcr_cassetes/ogm_ami4ccm_1_0.yml +7 -7
  32. data/spec/vcr_cassetes/rfc_8341.yml +15 -47
  33. data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
  34. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -30
  35. data/spec/vcr_cassetes/w3c_json_ld11.yml +12 -12
  36. metadata +51 -61
  37. data/.github/workflows/rake.yml +0 -46
  38. data/globalcache/iec/iec_60050_102_2007.xml +0 -58
  39. data/globalcache/iec/version +0 -1
  40. data/lib/relaton/workers_pool.rb +0 -23
  41. data/spec/vcr_cassetes/cie_001_1980.yml +0 -120
  42. data/spec/vcr_cassetes/ecma_6.yml +0 -159
  43. data/spec/vcr_cassetes/hist_cmbined_included.yml +0 -105
  44. data/spec/vcr_cassetes/iec_60050_102_2007.yml +0 -285
  45. data/spec/vcr_cassetes/iec_combined_included.yml +0 -945
  46. data/spec/vcr_cassetes/iso_combined_applied.yml +0 -361
  47. data/spec/vcr_cassetes/iso_combined_included.yml +0 -361
  48. data/spec/vcr_cassetes/itu_combined_included.yml +0 -1296
  49. data/spec/vcr_cassetes/rfc_unsuccess.yml +0 -70
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 669c9390b4e3b0a3be1a928f3a13db65cff18d9e36d1ee434662ebccab367402
4
- data.tar.gz: 9d285c4d6e00df82eb38baff1a191d8a4527456d689556312db1bef74c1fc364
3
+ metadata.gz: c04670d96d910f7279ae306322df75cc9939ce240c37fb237716f97877207029
4
+ data.tar.gz: f25fc7f76f03fa90dcbe18c881b8781353e55dc9f867af5464cdcd0423d76be9
5
5
  SHA512:
6
- metadata.gz: f0489929bc69ac678f9a3b5b2f4a73961102d72e9f0917807a422dbf495d3319b94e84c11cdfb46fc9cc423a523f04af20a1bacdd6964988e9deb2a87676470a
7
- data.tar.gz: 792fa2b3c0cf6f95362ff7039c867ec57766fe691fb75dd71e0413b77c3982b3bfdf7ee57748ae4de9aaea18b2e76a1f0c3ae67eb9c01a81ec594865e4a20531
6
+ metadata.gz: e858712ad2f9691936dfd5af9563896be74447eb4985cd1b56ede9a2e283fb6205f1ef791a9d4bc2921376e0346a8ac826ec1666abf3199f212d483bc007628e
7
+ data.tar.gz: '08b9ada0c3c65394c8301c5bbc9b0cb025ba0cf94c64dd042aec313fbb124740a6f55e91a3d8a5e2e1952f79517130ffc28b0cd2fc4b5ca8106998723e74fb9c'
@@ -0,0 +1,34 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: macos
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-macos:
13
+ name: Test on Ruby ${{ matrix.ruby }} macOS
14
+ runs-on: macos-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ run: |
28
+ sudo gem install bundler --force
29
+ ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
30
+ ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
31
+ bundle install --jobs 4 --retry 3
32
+ - name: Run specs
33
+ run: |
34
+ bundle exec rake
@@ -0,0 +1,32 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: ubuntu
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-linux:
13
+ name: Test on Ruby ${{ matrix.ruby }} Ubuntu
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ run: |
28
+ gem install bundler
29
+ bundle install --jobs 4 --retry 3
30
+ - name: Run specs
31
+ run: |
32
+ bundle exec rake
@@ -0,0 +1,35 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: windows
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ branches: [ '**' ]
10
+
11
+ jobs:
12
+ test-windows:
13
+ name: Test on Ruby ${{ matrix.ruby }} Windows
14
+ runs-on: windows-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ steps:
20
+ - uses: actions/checkout@master
21
+ - name: Use Ruby
22
+ uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ architecture: 'x64'
26
+ - name: Update gems
27
+ shell: pwsh
28
+ run: |
29
+ gem install bundler
30
+ bundle config --local path vendor/bundle
31
+ bundle update
32
+ bundle install --jobs 4 --retry 3
33
+ - name: Run specs
34
+ run: |
35
+ bundle exec rake
data/docs/README.adoc CHANGED
@@ -62,13 +62,6 @@ e.g. `get("ISO 19115-1", "2014", all_parts: true)` is transformed into a referen
62
62
 
63
63
  == Usage
64
64
 
65
- === Create DB
66
-
67
- `Relaton::Db#new(globalcache, localcache)` creates new DB. Returns Relaton::Db instance.
68
-
69
- * `globalcache` - (String or nil) path to globalcache directory
70
- * `localcache` - (String or nil) path to localcache directory
71
-
72
65
  [source,ruby]
73
66
  ----
74
67
  require "relaton"
@@ -100,51 +93,7 @@ db = Relaton::Db.new("globalcache", "localcache")
100
93
  @local_db=#<Relaton::DbCache:0x007faabc8fa5c0 @dir="localcache", @ext="xml">,
101
94
  @local_db_name="localcache",
102
95
  ...
103
- ----
104
-
105
- === Modify DB
106
-
107
- ==== Move DB
108
-
109
- `Relaton::Db#mv(new_dir, type: :global)` moves DB directory to new location. Returns path to new directory if successful, or `nil` if target directiory exists.
110
-
111
- * `new_dir` - (String) new cache location
112
- * `type` - (Symbol) type of cache DB. Allowed values are: `:global`, `:local`. Default is `:global`.
113
-
114
- [source,ruby]
115
- ----
116
- db.mv("new_global_dir")
117
- => "new_global_dir"
118
-
119
- db.mv("new_local_dir", type: :local)
120
- => "new_local_dir"
121
- ----
122
96
 
123
- ==== Clear DB
124
-
125
- `Relaton::Db#clear` removes all entries form DB
126
-
127
- === Fetch documens
128
-
129
- ==== Fetch document by references
130
-
131
- There are 3 fetching methods:
132
-
133
- * `Relaton::Db#fetch(reference, year, options)` - fetches document from local cache or remote source.
134
- * `Relaton::Db#fetch_db(reference, year, options)` - fetches document from local cache
135
- * `Relaton::Db#fetch_async(reference, year, options, &block)` - fetches document asynchronously
136
-
137
- Arguments:
138
-
139
- * `reference` - (String) reference to fethc document
140
- * `year` - (String or nil) year to filter relult (optional)
141
- * `options` - (Hash) hash of options. Alloved options:
142
- - `:all_parts` - (Boolean) should be `true` if all-parts reference is required
143
- - `:keep_yer` - (Boolean) should be `true` if undated reference should return actual reference with year
144
- - `:retries` - (Number) number of network retries. Default 1
145
-
146
- [source,ruby]
147
- ----
148
97
  x = db.fetch("IEEE 19011")
149
98
  [relaton-ieee] ("IEEE 19011") fetching...
150
99
  [relaton-ieee] WARNING: no match found online for IEEE 19011. The code must be exactly like it is on the standards website.
@@ -156,7 +105,7 @@ x = db.fetch("ISO 19011")
156
105
  => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ab2f00
157
106
  ...
158
107
 
159
- x = db.fetch("ISO 19011", "2011", retries: 3)
108
+ x = db.fetch("ISO 19011", "2011")
160
109
  [relaton-iso] ("ISO 19011") fetching...
161
110
  [relaton-iso] ("ISO 19011") found ISO 19011:2011
162
111
  => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d2593068
@@ -168,185 +117,9 @@ x = db.fetch("ISO 19115", nil, all_parts: true)
168
117
  => #<RelatonIsoBib::IsoBibliographicItem:0x007fb1d0ae8bf0
169
118
  ...
170
119
 
171
- # Fetchig from local cache
172
-
173
- x = db.fetch("ISO 19011")
174
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fde5f48a9f0
175
- ...
176
-
177
- x = db.fetch_db("ISO 5749")
178
- => nil
179
-
180
- # Fetching asynchronously
181
-
182
- # prepare queue for results
183
- results = Queue.new
184
-
185
- # fetch document
186
- db.fetch_async("ISO 19115") do |result|
187
- results << { "ISO 19115" => result }
188
- end
189
- # fetch other documets the same way
190
-
191
- # wait until documets fetching
192
- while x = results.pop
193
- # do thatever you need with result x
194
- end
195
- ----
196
-
197
- ==== Fetch by URN
198
-
199
- This functionality works only for IEC documents.
200
-
201
- [source,ruby]
202
- ----
203
- x = db.fetch "urn:iec:std:iec:60050-102:2007:::"
204
- [relaton-iec] ("IEC 60050-102") fetching...
205
- [relaton-iec] ("IEC 60050-102") found IEC 60050-102:2007
206
- => #<RelatonIec::IecBibliographicItem:0x007fbd6c3790e8
207
- ...
208
- ----
209
-
210
- === Fetch combined documents
211
-
212
- This functionality works only for ISO, IEC, ITU, and NIST documents.
213
-
214
- ==== Fetch included documents
215
- [source,ruby]
216
- ----
217
- bib = db.fetch "ISO 19115-1 + Amd 1"
218
- [relaton-iso] ("ISO 19115-1") fetching...
219
- [relaton-iso] ("ISO 19115-1") found ISO 19115-1:2014
220
- [relaton-iso] ("ISO 19115-1/Amd 1") fetching...
221
- [relaton-iso] ("ISO 19115-1/Amd 1") found ISO 19115-1:2014/Amd 1:2018
222
- => #<RelatonIsoBib::IsoBibliographicItem:0x007f95a929a748
223
-
224
- bib.docidentifier[0].id
225
- => "ISO 19115-1 + Amd 1"
226
-
227
- bib.relation[0].type
228
- => "updates"
229
-
230
- bib.relation[0].bibitem.docidentifier[0].id
231
- => "ISO 19115-1"
232
-
233
- bib.relation[1].type
234
- => "derivedFrom"
235
-
236
- bib.relation[1].bibitem.docidentifier[0].id
237
- => "ISO 19115-1/Amd 1:2018"
238
-
239
- bib.docidentifier[0].id
240
- => "ISO 19115-1, Amd 1"
241
-
242
- bib.relation[0].type
243
- => "updates"
244
-
245
- bib.relation[0].bibitem.docidentifier[0].id
246
- => "ISO 19115-1"
247
-
248
- bib.relation[1].type
249
- => "complements"
250
-
251
- bib.relation[1].description
252
- => "amendment"
253
-
254
- bib.relation[1].bibitem.docidentifier[0].id
255
- => "ISO 19115-1/Amd 1:2018"
256
- ----
257
-
258
- ==== Fetch applied documents
259
- [source,ruby]
260
- ----
261
- bib = db.fetch "ISO 19115-1, Amd 1"
262
- => ["Chinese Standard", "GB/T 1.1"]
263
- [relaton-iso] ("ISO 19115-1") fetching...
264
- [relaton-iso] ("ISO 19115-1") found ISO 19115-1:2014
265
- [relaton-iso] ("ISO 19115-1/Amd 1") fetching...
266
- [relaton-iso] ("ISO 19115-1/Amd 1") found ISO 19115-1:2014/Amd 1:2018
267
- => #<RelatonIsoBib::IsoBibliographicItem:0x007fb09b36d1b8
268
- ...
269
- ----
270
-
271
- ==== Fetch all documents from cache
272
-
273
- `Relaton::Db#fetch_all(text = nil, edition: nil, year: nil)` - fetches all document from local cache
274
-
275
- * `text` - (String) filter entries by a text (optional)
276
- * `edition` - (String) filter entries by an edition (optional)
277
- * `year` - (Integer) filter entries by a year (optional)
278
-
279
- [source,ruby]
280
- ----
281
- # query for all entries in a cahche
282
-
283
- items = db.fetch_all
284
- => [#<RelatonIec::IecBibliographicItem:0x007facda8fdc28
285
- ...
286
-
287
- items.size
288
- => 6
289
-
290
- # query for all entries in a cahche for a certain string
291
-
292
- items = db.fetch_all("mathematical terminology")
293
- => [#<RelatonIec::IecBibliographicItem:0x007ffeae5bd240
294
- ...
295
-
296
- items.size
297
- => 1
298
-
299
- items[0].docidentifier[0].id
300
- => "IEC 60050-102:2007"
301
-
302
- # query for all entries in a cahche for a certain string and edition
303
-
304
- items = db.fetch_all("system", edition: "2")
305
- => [#<RelatonIsoBib::IsoBibliographicItem:0x007ffebe2d1be8
306
- ...
307
-
308
- items.size
309
- => 1
310
-
311
- items[0].docidentifier[0].id
312
- => "ISO 19011:2011"
313
-
314
- # query for all entries in a cahche for a certain string and year
315
-
316
- items = db.fetch_all("system", year: 2018)
317
- => [#<RelatonIsoBib::IsoBibliographicItem:0x007ffeae645fa0
318
- ...
319
-
320
- items.size
321
- => 1
322
-
323
- items[0].docidentifier[0].id
324
- => "ISO 19011 (all parts)"
325
- ----
326
-
327
- === Static DB
328
-
329
- This gem has a static DB which is distributed with it. Now the static contains documents:
330
- ----
331
- ISO/IEC DIR 1 IEC SUP
332
- ISO/IEC DIR 1 ISO SUP
333
- ISO/IEC DIR 1
334
- ISO/IEC DIR 2 IEC
335
- ISO/IEC DIR 2 ISO
336
- ISO/IEC DIR IEC SUP
337
- ISO/IEC DIR 1 JTC SUP
338
- ----
339
-
340
- === Get document type
341
- [source,ruby]
342
- ----
343
120
  db.docid_type("CN(GB/T 1.1)")
344
121
  => ["Chinese Standard", "GB/T 1.1"]
345
- ----
346
122
 
347
- === Serializing
348
- [source,ruby]
349
- ----
350
123
  x.to_xml
351
124
  => "<bibitem id="ISO19115(allparts)" type="standard">
352
125
  ...
@@ -372,15 +145,12 @@ x.to_xml bibdata: true
372
145
  db.load_entry("ISO(ISO 19011)")
373
146
  => "<bibdata type="standard">
374
147
  ...
375
- </bibdata>"
376
- ----
148
+ <?bibdata>"
377
149
 
378
- === Entry manipulation
379
- [source,ruby]
380
- ----
381
150
  db.save_entry("ISO(ISO 19011)", nil)
382
151
  => nil
383
152
 
384
153
  db.load_entry("ISO(ISO 19011)")
385
154
  => nil
155
+
386
156
  ----
@@ -12,11 +12,10 @@ module Relaton
12
12
  end
13
13
 
14
14
  class Configuration
15
- attr_accessor :logs, :use_api
15
+ attr_accessor :logs
16
16
 
17
17
  def initialize
18
- @logs = %i(warning error)
19
- @use_api = false # @TODO change to true when we start using api.relaton.org
18
+ @logs ||= %i(warning error)
20
19
  end
21
20
  end
22
21