relaton-cli 1.7.4 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -11
- data/.rubocop.yml +1 -1
- data/docs/README.adoc +28 -12
- data/lib/relaton/cli/command.rb +27 -18
- data/lib/relaton/cli/data_fetcher.rb +12 -0
- data/lib/relaton/cli/version.rb +1 -1
- data/relaton-cli.gemspec +2 -2
- data/templates/_document.liquid +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39535b9c177165d658eeeab7b43592dbf2deb05575b3fec1ecb1502ec564b555
|
4
|
+
data.tar.gz: 8a7a53cc3d078fa0f9b26279f91f59cb521271b5d67d34fc006f81dabc326dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0e825551c8ec3fef0fca053352791d4d0747c22cf6fcf190af60e6a2e482bfced0c00623adb5c6a2671879d561337d1c2c6f16e82e034443653f25a3e0ed10
|
7
|
+
data.tar.gz: '0846c248faf4471db8a408a56101ac1ca543418365393b312c85492f281e3d3e085c8b25a7008c7075dad8e9e358e0aea8845e8336b1ef0eae0945aee9fffcf4'
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,19 +16,9 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '
|
19
|
+
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
|
-
include:
|
23
|
-
- ruby: '3.0'
|
24
|
-
os: 'ubuntu-latest'
|
25
|
-
experimental: true
|
26
|
-
- ruby: '3.0'
|
27
|
-
os: 'windows-latest'
|
28
|
-
experimental: true
|
29
|
-
- ruby: '3.0'
|
30
|
-
os: 'macos-latest'
|
31
|
-
experimental: true
|
32
22
|
steps:
|
33
23
|
- uses: actions/checkout@v2
|
34
24
|
with:
|
data/.rubocop.yml
CHANGED
data/docs/README.adoc
CHANGED
@@ -54,7 +54,23 @@ Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
|
54
54
|
* `--all-parts` fetch all parts.
|
55
55
|
* `--keep-year` undated reference should return actual reference with year.
|
56
56
|
|
57
|
-
=== relaton
|
57
|
+
=== relaton fetch-data
|
58
|
+
|
59
|
+
[source,console]
|
60
|
+
----
|
61
|
+
$ relaton fetch-data DATASET -o DIR -f FORMAT
|
62
|
+
----
|
63
|
+
|
64
|
+
Fetch all the documents from a `DATASET` source and save them to a folder `DIR` in format `FORMAT`.
|
65
|
+
|
66
|
+
Foloowing datasets are availabe:
|
67
|
+
|
68
|
+
* `nist-tech-pubs` - https://raw.githubusercontent.com/usnistgov/NIST-Tech-Pubs/nist-pages/xml/allrecords.xml
|
69
|
+
|
70
|
+
Options:
|
71
|
+
|
72
|
+
* `DIR` - floder name to store documents (default `./data`).
|
73
|
+
* `FORMAT` - format in which the documents are saved. Possimle formats are: `yaml`, `xml` (default `yaml`).
|
58
74
|
|
59
75
|
[source,console]
|
60
76
|
----
|
@@ -310,38 +326,38 @@ Import document or collection from XML `FILE` into `COLLECTION`.
|
|
310
326
|
* `COLLECTION` is optional. If collection doesn't exist then it will be created.
|
311
327
|
* `DIRECTORY` is optional, and specifies path to a directory with collections. Default is `$HOME/.relaton/collections`.
|
312
328
|
|
313
|
-
===
|
329
|
+
=== Dadabase manipulation
|
314
330
|
|
315
|
-
==== Create
|
331
|
+
==== Create database
|
316
332
|
|
317
333
|
----
|
318
334
|
$ relaton db create DIR
|
319
335
|
----
|
320
336
|
|
321
|
-
Creates a new
|
337
|
+
Creates a new database in a directory `DIR` (optional, deafult is `/home/USER/.relaton/dbpath`). In case the target directory exists it will be used as a database.
|
322
338
|
|
323
339
|
----
|
324
340
|
$ relaton db create
|
325
|
-
|
341
|
+
Database is in "/Users/user/.relaton/cache"
|
326
342
|
|
327
343
|
$ relaton db create cachedb
|
328
|
-
|
344
|
+
Database is in "/Users/user/RubyProjects/relaton-cli/cachedb"
|
329
345
|
----
|
330
346
|
|
331
|
-
==== Move
|
347
|
+
==== Move database
|
332
348
|
|
333
349
|
----
|
334
350
|
$ relaton db mv DIR
|
335
351
|
----
|
336
352
|
|
337
|
-
Move
|
353
|
+
Move database to another place `DIR`.
|
338
354
|
|
339
355
|
----
|
340
356
|
$ relaton db mv cache_dir
|
341
|
-
|
357
|
+
Database is moved to "/Users/user/RubyProjects/relaton-cli/cache_dir"
|
342
358
|
----
|
343
359
|
|
344
|
-
==== Clear
|
360
|
+
==== Clear database
|
345
361
|
|
346
362
|
Delete all entries from a chache DB.
|
347
363
|
|
@@ -349,13 +365,13 @@ Delete all entries from a chache DB.
|
|
349
365
|
$ relaton db clear
|
350
366
|
----
|
351
367
|
|
352
|
-
==== Fetch from
|
368
|
+
==== Fetch from database
|
353
369
|
|
354
370
|
----
|
355
371
|
$ relaton db fetch -t TYPE -f FORMAT -y YEAR
|
356
372
|
----
|
357
373
|
|
358
|
-
Fetch an entry from a
|
374
|
+
Fetch an entry from a database. See [relaton fetch](#relaton-fetch) for the arguments explanation.
|
359
375
|
|
360
376
|
==== Fetch all
|
361
377
|
|
data/lib/relaton/cli/command.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "relaton/cli/relaton_file"
|
2
2
|
require "relaton/cli/xml_convertor"
|
3
3
|
require "relaton/cli/yaml_convertor"
|
4
|
+
require "relaton/cli/data_fetcher"
|
4
5
|
require "relaton/cli/subcommand_collection"
|
5
6
|
require "relaton/cli/subcommand_db"
|
6
7
|
require "fcntl"
|
@@ -14,19 +15,19 @@ module Relaton
|
|
14
15
|
|
15
16
|
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
|
16
17
|
option :type, aliases: :t, desc: "Type of standard to "\
|
17
|
-
|
18
|
+
"get bibliographic entry for"
|
18
19
|
option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
|
19
|
-
|
20
|
+
"Default xml."
|
20
21
|
option :year, aliases: :y, type: :numeric, desc: "Year the standard was "\
|
21
|
-
|
22
|
+
"published"
|
22
23
|
option :"all-parts", type: :boolean, desc: "Fetch all parts"
|
23
24
|
option :"keep-year", type: :boolean, desc: "Undated reference should "\
|
24
|
-
|
25
|
+
"return actual reference with year"
|
25
26
|
option :retries, aliases: :r, type: :numeric, desc: "Number of network "\
|
26
27
|
"retries. Default 1."
|
27
28
|
|
28
29
|
def fetch(code)
|
29
|
-
io = IO.new(
|
30
|
+
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
30
31
|
io.puts(fetch_document(code, options) || supported_type_message)
|
31
32
|
end
|
32
33
|
|
@@ -43,7 +44,7 @@ module Relaton
|
|
43
44
|
"DIRECTORY (containing Relaton-XML or YAML) into a Relaton Collection"
|
44
45
|
option :title, aliases: :t, desc: "Title of resulting Relaton collection"
|
45
46
|
option :organization, aliases: :g, desc: "Organization owner of Relaton "\
|
46
|
-
|
47
|
+
"collection"
|
47
48
|
option :extension, aliases: :x, desc: "File extension of destination "\
|
48
49
|
"Relaton file, defaults to 'rxl'"
|
49
50
|
|
@@ -61,15 +62,15 @@ module Relaton
|
|
61
62
|
end
|
62
63
|
|
63
64
|
desc "yaml2xml YAML", "Convert Relaton YAML into Relaton Collection XML "\
|
64
|
-
|
65
|
+
"or separate files"
|
65
66
|
option :extension, aliases: :x, default: "rxl", desc: "File extension "\
|
66
67
|
"of Relaton XML files, defaults to 'rxl'"
|
67
68
|
option :prefix, aliases: :p, desc: "Filename prefix of individual "\
|
68
|
-
|
69
|
+
"Relaton XML files, defaults to empty"
|
69
70
|
option :outdir, aliases: :o, desc: "Output to the specified directory "\
|
70
71
|
"with individual Relaton Bibdata XML files"
|
71
72
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY "\
|
72
|
-
|
73
|
+
"prior to execution"
|
73
74
|
option :overwrite, aliases: :f, type: :boolean, default: false,
|
74
75
|
desc: "Overwrite the existing file"
|
75
76
|
|
@@ -78,15 +79,15 @@ module Relaton
|
|
78
79
|
end
|
79
80
|
|
80
81
|
desc "xml2yaml XML", "Convert Relaton XML into Relaton Bibdata / "\
|
81
|
-
|
82
|
+
"Bibcollection YAML (and separate files)"
|
82
83
|
option :extension, aliases: :x, default: "yaml", desc: "File extension "\
|
83
84
|
"of Relaton YAML files, defaults to 'yaml'"
|
84
85
|
option :prefix, aliases: :p, desc: "Filename prefix of Relaton XML "\
|
85
|
-
|
86
|
+
"files, defaults to empty"
|
86
87
|
option :outdir, aliases: :o, desc: "Output to the specified directory "\
|
87
|
-
|
88
|
+
"with individual Relaton Bibdata YAML files"
|
88
89
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY "\
|
89
|
-
|
90
|
+
"prior to execution"
|
90
91
|
option :overwrite, aliases: :f, type: :boolean, default: false,
|
91
92
|
desc: "Overwrite the existing file"
|
92
93
|
|
@@ -95,9 +96,9 @@ module Relaton
|
|
95
96
|
end
|
96
97
|
|
97
98
|
desc "xml2html RELATON-INDEX-XML", "Convert Relaton Collection XML into "\
|
98
|
-
|
99
|
+
"HTML"
|
99
100
|
option :stylesheet, aliases: :s, desc: "Stylesheet file path for "\
|
100
|
-
|
101
|
+
"rendering HTML index"
|
101
102
|
option :templatedir, aliases: :t, desc: "Liquid template directory for "\
|
102
103
|
"rendering Relaton items and collection"
|
103
104
|
option :overwrite, aliases: :f, type: :boolean, default: false,
|
@@ -108,9 +109,9 @@ module Relaton
|
|
108
109
|
end
|
109
110
|
|
110
111
|
desc "yaml2html RELATON-INDEX-YAML", "Concatenate Relaton Collection "\
|
111
|
-
|
112
|
+
"YAML into HTML"
|
112
113
|
option :stylesheet, aliases: :s, desc: "Stylesheet file path for "\
|
113
|
-
|
114
|
+
"rendering HTML index"
|
114
115
|
option :templatedir, aliases: :t, desc: "Liquid template directory for "\
|
115
116
|
"rendering Relaton items and collection"
|
116
117
|
option :overwrite, aliases: :f, type: :boolean, default: false,
|
@@ -137,10 +138,18 @@ module Relaton
|
|
137
138
|
when "asciibib" then "adoc"
|
138
139
|
else options[:format]
|
139
140
|
end
|
140
|
-
output = options[:output] || file.sub(/(?<=\.)[
|
141
|
+
output = options[:output] || file.sub(/(?<=\.)[^.]+$/, ext)
|
141
142
|
File.write output, result, encoding: "UTF-8"
|
142
143
|
end
|
143
144
|
|
145
|
+
desc "fetch-data SOURCE", "Fetch all the documents from a source"
|
146
|
+
option :output, aliases: :o, desc: "Output dir. Default: ./data/"
|
147
|
+
option :format, aliases: :f, desc: "Output format (yaml, xml). Default: yaml"
|
148
|
+
|
149
|
+
def fetch_data(source)
|
150
|
+
DataFetcher.fetch source, options
|
151
|
+
end
|
152
|
+
|
144
153
|
desc "collection SUBCOMMAND", "Collection manipulations"
|
145
154
|
subcommand "collection", SubcommandCollection
|
146
155
|
|
data/lib/relaton/cli/version.rb
CHANGED
data/relaton-cli.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.bindir = "exe"
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
|
-
spec.required_ruby_version = ">= 2.
|
23
|
+
spec.required_ruby_version = ">= 2.5.0"
|
24
24
|
|
25
25
|
spec.add_development_dependency "byebug", "~> 11.0"
|
26
26
|
# spec.add_development_dependency "debase"
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "webmock"
|
37
37
|
|
38
38
|
spec.add_runtime_dependency "liquid", "~> 4"
|
39
|
-
spec.add_runtime_dependency "relaton", ">=1.
|
39
|
+
spec.add_runtime_dependency "relaton", ">= 1.9.1"
|
40
40
|
spec.add_runtime_dependency "thor"
|
41
41
|
spec.add_runtime_dependency "thor-hollaback"
|
42
42
|
end
|
data/templates/_document.liquid
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.
|
4
|
+
version: 1.9.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: 2021-
|
11
|
+
date: 2021-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.
|
173
|
+
version: 1.9.1
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 1.
|
180
|
+
version: 1.9.1
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: thor
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- lib/relaton/cli.rb
|
238
238
|
- lib/relaton/cli/base_convertor.rb
|
239
239
|
- lib/relaton/cli/command.rb
|
240
|
+
- lib/relaton/cli/data_fetcher.rb
|
240
241
|
- lib/relaton/cli/full_text_search.rb
|
241
242
|
- lib/relaton/cli/relaton_file.rb
|
242
243
|
- lib/relaton/cli/subcommand_collection.rb
|
@@ -262,14 +263,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
263
|
requirements:
|
263
264
|
- - ">="
|
264
265
|
- !ruby/object:Gem::Version
|
265
|
-
version: 2.
|
266
|
+
version: 2.5.0
|
266
267
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
268
|
requirements:
|
268
269
|
- - ">="
|
269
270
|
- !ruby/object:Gem::Version
|
270
271
|
version: '0'
|
271
272
|
requirements: []
|
272
|
-
rubygems_version: 3.
|
273
|
+
rubygems_version: 3.2.3
|
273
274
|
signing_key:
|
274
275
|
specification_version: 4
|
275
276
|
summary: Relaton Command-line Interface
|