relaton-cli 1.16.0 → 1.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/README.adoc +6 -5
- data/lib/relaton/cli/command.rb +15 -14
- data/lib/relaton/cli/config.rb +12 -0
- data/lib/relaton/cli/data_fetcher.rb +1 -1
- data/lib/relaton/cli/subcommand_collection.rb +5 -4
- data/lib/relaton/cli/subcommand_db.rb +3 -3
- data/lib/relaton/cli/util.rb +11 -0
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7cc2a49bdf10f53e244e9953bed1ac4590f4cc2ea14685c768200425d1fb71
|
4
|
+
data.tar.gz: 8e2e6b11df808211aee56ac2ae1ee1edfd3aa5e159e72ca95a403255af24034f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc4a898e2fa561aa3b8b91d74f1897fdd22f765c9a3c36c1d14f94d018c7644599e513a7a946408ba8f2dccc91a694744ed9e27df07d1b3e4d6af30eb8599b7f
|
7
|
+
data.tar.gz: 1b1730b2fc45f5d1af3477e58d4163b3b4a84460b4e587d1ccd9a881a672337a9e053fa0b938a83952a652345fec0abd74ac65ad9cc3a647ccdaa946439a4639
|
data/docs/README.adoc
CHANGED
@@ -42,17 +42,18 @@ suports an additional `-x` or `--extension` options to use different extension.
|
|
42
42
|
|
43
43
|
[source,console]
|
44
44
|
----
|
45
|
-
$ relaton fetch CODE -t TYPE -f FORMAT -y YEAR -r RETRIES --all-parts --keep-year
|
45
|
+
$ relaton fetch CODE -t TYPE -f FORMAT -y YEAR -r RETRIES --all-parts --keep-year --no-cache
|
46
46
|
----
|
47
47
|
|
48
48
|
Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
49
49
|
|
50
50
|
* `YEAR` is optional and specifies the year of publication of the standard.
|
51
51
|
* `FORMAT` is optional, and specifies the output format; the recognized values for `FORMAT` are `xml` (default), yaml, `bibtex`.
|
52
|
-
* `TYPE` is optional and specifies the standards class library to be used, that the identifier is part of. The recognized values for `TYPE` are `3GPP, BIPM, BSI, CC, CEN, CIE, CN, ECMA, IANA, IEC, IEEE, IETF, IHO, ISO, ITU, NIST, OGC, OMG, UN, W3C`.
|
52
|
+
* `TYPE` is optional and specifies the standards class library to be used, that the identifier is part of. The recognized values for `TYPE` are `3GPP, BIPM, BSI, CC, CCSDS, CEN, CIE, CN, ECMA, IANA, IEC, IEEE, IETF, IHO, ISO, ITU, NIST, OASIS, OGC, OMG, UN, W3C, XSF`.
|
53
53
|
* `RETRIES` is optional, number of network retries (default 1).
|
54
54
|
* `--all-parts` fetch all parts.
|
55
55
|
* `--keep-year` undated reference should return an actual reference with year.
|
56
|
+
* `--no-cache` do not use cache.
|
56
57
|
|
57
58
|
=== relaton fetch-data
|
58
59
|
|
@@ -392,10 +393,10 @@ Creates a new database in a directory `DIR` (optional, deafult is `/home/USER/.r
|
|
392
393
|
|
393
394
|
----
|
394
395
|
$ relaton db create
|
395
|
-
Database is in
|
396
|
+
[relaton-cli] Database is in `/Users/user/.relaton/cache`
|
396
397
|
|
397
398
|
$ relaton db create cachedb
|
398
|
-
Database is in
|
399
|
+
[relaton-cli] Database is in `/Users/user/RubyProjects/relaton-cli/cachedb`
|
399
400
|
----
|
400
401
|
|
401
402
|
==== Move database
|
@@ -408,7 +409,7 @@ Move database to another place `DIR`.
|
|
408
409
|
|
409
410
|
----
|
410
411
|
$ relaton db mv cache_dir
|
411
|
-
Database is moved to
|
412
|
+
[relaton-cli] Database is moved to `/Users/user/RubyProjects/relaton-cli/cache_dir`
|
412
413
|
----
|
413
414
|
|
414
415
|
==== Clear database
|
data/lib/relaton/cli/command.rb
CHANGED
@@ -20,16 +20,17 @@ module Relaton
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
|
23
|
-
option :type, aliases: :t,
|
24
|
-
|
25
|
-
option :format, aliases: :f,
|
26
|
-
|
23
|
+
option :type, aliases: :t,
|
24
|
+
desc: "Type of standard to get bibliographic entry for"
|
25
|
+
option :format, aliases: :f,
|
26
|
+
desc: "Output format (xml, yaml, bibtex). Default xml."
|
27
27
|
option :year, aliases: :y, type: :numeric, desc: "Year the standard was published"
|
28
28
|
option :"all-parts", type: :boolean, desc: "Fetch all parts"
|
29
|
-
option :"keep-year", type: :boolean,
|
30
|
-
|
31
|
-
option :retries, aliases: :r, type: :numeric,
|
32
|
-
|
29
|
+
option :"keep-year", type: :boolean,
|
30
|
+
desc: "Undated reference should return actual reference with year"
|
31
|
+
option :retries, aliases: :r, type: :numeric,
|
32
|
+
desc: "Number of network retries. Default 1."
|
33
|
+
option :"no-cache", type: :boolean, desc: "Ignore cache"
|
33
34
|
|
34
35
|
def fetch(code)
|
35
36
|
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
@@ -160,10 +161,9 @@ module Relaton
|
|
160
161
|
|
161
162
|
no_commands do
|
162
163
|
def relaton_config
|
163
|
-
|
164
|
-
log_types << :warning if options[:verbose]
|
164
|
+
log_type = options[:verbose] ? ::Logger::INFO : ::Logger::WARN
|
165
165
|
Relaton.configure do |conf|
|
166
|
-
conf.
|
166
|
+
conf.logger.level = log_type
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
@@ -177,12 +177,13 @@ module Relaton
|
|
177
177
|
# @option options [String, NilClass] :format
|
178
178
|
# @option options [Integer, NilClass] :year
|
179
179
|
# @return [String, nil]
|
180
|
-
def fetch_document(code, options) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
180
|
+
def fetch_document(code, options) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize,Metrics/MethodLength
|
181
181
|
year = options[:year]&.to_s
|
182
|
+
dup_opts = options.dup.transform_keys { |k| k.to_s.gsub("-", "_").to_sym }
|
182
183
|
if (processor = Relaton::Registry.instance.by_type options[:type]&.upcase)
|
183
|
-
doc = Relaton.db.fetch_std code, year, processor.short,
|
184
|
+
doc = Relaton.db.fetch_std code, year, processor.short, **dup_opts
|
184
185
|
elsif options[:type] then return
|
185
|
-
else doc = Relaton.db.fetch(code, year,
|
186
|
+
else doc = Relaton.db.fetch(code, year, **dup_opts)
|
186
187
|
end
|
187
188
|
return "No matching bibliographic entry found" unless doc
|
188
189
|
|
@@ -4,7 +4,7 @@ module Relaton
|
|
4
4
|
def fetch(source, options)
|
5
5
|
processor = Relaton::Registry.instance.find_processor_by_dataset source
|
6
6
|
unless processor
|
7
|
-
warn "
|
7
|
+
Util.warn "WARNING: no processor found for `#{source}`"
|
8
8
|
return
|
9
9
|
end
|
10
10
|
|
@@ -18,7 +18,7 @@ module Relaton
|
|
18
18
|
file_path = File.join dir, file
|
19
19
|
col = Relaton::Bibcollection.new options
|
20
20
|
if File.exist? file_path
|
21
|
-
warn "Collection
|
21
|
+
Util.warn "Collection `#{file}` aready exist"
|
22
22
|
else
|
23
23
|
FileUtils.mkdir_p dir # unless Dir.exist? dir
|
24
24
|
File.write file_path, col.to_yaml, encoding: "UTF-8"
|
@@ -114,7 +114,7 @@ module Relaton
|
|
114
114
|
coll = read_collection colfile
|
115
115
|
coll << doc
|
116
116
|
File.write colfile, coll.to_yaml, encoding: "UTF-8"
|
117
|
-
else warn "No matching bibliographic entry found"
|
117
|
+
else Util.warn "No matching bibliographic entry found"
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -161,11 +161,12 @@ module Relaton
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# @param file [String]
|
164
|
-
# @return [Hash]
|
164
|
+
# @return [Hash, nil]
|
165
165
|
def read_yaml(file)
|
166
166
|
YAML.load_file file if File.file? file
|
167
167
|
rescue Psych::SyntaxError
|
168
|
-
warn "
|
168
|
+
Util.warn "WARNING: the file `#{file}` isn't a collection."
|
169
|
+
nil
|
169
170
|
end
|
170
171
|
|
171
172
|
# @param file [String]
|
@@ -10,7 +10,7 @@ module Relaton
|
|
10
10
|
def create(dir = nil)
|
11
11
|
db = Relaton.db (dir && File.expand_path(dir))
|
12
12
|
path = db.instance_variable_get(:@db).dir
|
13
|
-
warn "Cache DB is in
|
13
|
+
Util.warn "Cache DB is in `#{path}`"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "mv DIR", "Move cache DB to a new directory"
|
@@ -20,7 +20,7 @@ module Relaton
|
|
20
20
|
path = Relaton.db.mv new_path
|
21
21
|
if path
|
22
22
|
File.write Cli::RelatonDb::DBCONF, path, encoding: "UTF-8"
|
23
|
-
warn "Cache DB is moved to
|
23
|
+
Util.warn "Cache DB is moved to `#{path}`"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -29,7 +29,7 @@ module Relaton
|
|
29
29
|
def clear
|
30
30
|
db = Relaton.db
|
31
31
|
db.clear
|
32
|
-
warn "Cache DB is cleared"
|
32
|
+
Util.warn "Cache DB is cleared"
|
33
33
|
end
|
34
34
|
|
35
35
|
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE " \
|
data/lib/relaton/cli/version.rb
CHANGED
data/lib/relaton/cli.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -98,11 +98,13 @@ files:
|
|
98
98
|
- lib/relaton/cli.rb
|
99
99
|
- lib/relaton/cli/base_convertor.rb
|
100
100
|
- lib/relaton/cli/command.rb
|
101
|
+
- lib/relaton/cli/config.rb
|
101
102
|
- lib/relaton/cli/data_fetcher.rb
|
102
103
|
- lib/relaton/cli/full_text_search.rb
|
103
104
|
- lib/relaton/cli/relaton_file.rb
|
104
105
|
- lib/relaton/cli/subcommand_collection.rb
|
105
106
|
- lib/relaton/cli/subcommand_db.rb
|
107
|
+
- lib/relaton/cli/util.rb
|
106
108
|
- lib/relaton/cli/version.rb
|
107
109
|
- lib/relaton/cli/xml_convertor.rb
|
108
110
|
- lib/relaton/cli/xml_to_html_renderer.rb
|