relaton-cli 1.16.0 → 1.17.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.
- 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
- data/relaton-cli.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fd1d595711558f13d1861c3d1077054c9666f19aa2ce534f4c28cb28468fa08
|
4
|
+
data.tar.gz: 7bd64a7c60d3b71b2dcc255d18b967e36acfdd2c75e7af1636f428e188fd260f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42471b6f147ed05d83238ee91357cf5a6154727eba2f8760e7f7b00965fb689e8cfe1a065fdf82f93a9b9d12d46f9b56e0c612ddbcf371d8ad428e7a7e0b9212
|
7
|
+
data.tar.gz: e003e6e51b727b0b9bfa6a6c157eb4f142f9b3481bf2e598d74f48e30f4ba8125ef45918def68d10832bd0b95e1e716e5754242aaa651e9008868eb47770bf12
|
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
data/relaton-cli.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = ">= 2.7.0"
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "liquid", "~> 5"
|
26
|
-
spec.add_runtime_dependency "relaton", "~> 1.
|
26
|
+
spec.add_runtime_dependency "relaton", "~> 1.17.0"
|
27
27
|
spec.add_runtime_dependency "thor"
|
28
28
|
spec.add_runtime_dependency "thor-hollaback"
|
29
29
|
end
|
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.
|
4
|
+
version: 1.17.0
|
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-
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.17.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.17.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: thor
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|