relaton-cli 1.6.0 → 1.7.pre3
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 +46 -0
- data/Gemfile +0 -1
- data/docs/README.adoc +112 -7
- data/lib/relaton/cli.rb +27 -6
- data/lib/relaton/cli/command.rb +55 -31
- data/lib/relaton/cli/relaton_file.rb +1 -1
- data/lib/relaton/cli/subcommand_collection.rb +2 -2
- data/lib/relaton/cli/subcommand_db.rb +73 -0
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_to_html_renderer.rb +1 -1
- data/lib/relaton/cli/yaml_convertor.rb +1 -1
- data/relaton-cli.gemspec +5 -6
- metadata +19 -48
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -32
- data/.github/workflows/windows.yml +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6c0e11fa51a48417dd591d2835b2637a79f9a021e58f1f1fb6e818d12e90ac3
|
4
|
+
data.tar.gz: da5753170d30401fab1a0b013a338ee3cd48da9d209a5ee17e83700f0999e59d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cee2b8248080c68d64cc58e780e0aa77ba0ad9bd06d6e42ce4e8eda81c639bb2e5dd301e177cad0bdc12f3bd7d588a7f2b7f1eab9c426d1c81e6ef53e66e61a4
|
7
|
+
data.tar.gz: ed00bade15a250b8dcaa6d531c58ca1b979ad5a73175eb97a63593f1525ae62c4002f477e3bd84a717fdc571919e43f8021980c40d0e6dc9aba1282b050c6a51
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
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
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
with:
|
35
|
+
submodules: true
|
36
|
+
|
37
|
+
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
38
|
+
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
39
|
+
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
40
|
+
|
41
|
+
- uses: ruby/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
ruby-version: ${{ matrix.ruby }}
|
44
|
+
bundler-cache: true
|
45
|
+
|
46
|
+
- run: bundle exec rake
|
data/Gemfile
CHANGED
data/docs/README.adoc
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
= Relaton CLI (relaton-cli): Relaton Command-line Interface
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-cli.svg["Gem Version", link="https://rubygems.org/gems/relaton-cli"]
|
4
|
-
image:https://github.com/relaton/relaton-cli/workflows/
|
5
|
-
image:https://github.com/relaton/relaton-cli/workflows/macos/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=macos"]
|
6
|
-
image:https://github.com/relaton/relaton-cli/workflows/windows/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=windows"]
|
4
|
+
image:https://github.com/relaton/relaton-cli/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=rake"]
|
7
5
|
image:https://codeclimate.com/github/metanorma/relaton-cli/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-cli"]
|
8
6
|
|
9
7
|
Documentation in development.
|
@@ -43,14 +41,17 @@ suports an additional `-x` or `--extension` options to use different extension.
|
|
43
41
|
|
44
42
|
[source,console]
|
45
43
|
----
|
46
|
-
$ relaton fetch CODE -t TYPE -f FORMAT -y YEAR
|
44
|
+
$ relaton fetch CODE -t TYPE -f FORMAT -y YEAR -r RETRIES --all-parts --keep-year
|
47
45
|
----
|
48
46
|
|
49
47
|
Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
50
48
|
|
51
49
|
* `YEAR` is optional, and specifies the year of publication of the standard.
|
52
|
-
* `FORMAT` is optional, and specifies the output format; the recognised values for `FORMAT` are `xml` (default), `bibtex`.
|
53
|
-
* `TYPE` specifies the standards class library to be used, that the identifier is part of. The recognised values for `TYPE` are `BIPM`, `CC`, `CN`, `IEC`, `IEEE`, `IETF`, `IHO`, `ISO`, `ITU`, `NIST`, `OGC`, `OMG`, `UN`, `W3C`.
|
50
|
+
* `FORMAT` is optional, and specifies the output format; the recognised values for `FORMAT` are `xml` (default), yaml, `bibtex`.
|
51
|
+
* `TYPE` is optional, specifies the standards class library to be used, that the identifier is part of. The recognised values for `TYPE` are `BIPM`, `CC`, `CIE`, `CN`, `ECMA`, `IEC`, `IEEE`, `IETF`, `IHO`, `ISO`, `ITU`, `NIST`, `OGC`, `OMG`, `UN`, `W3C`.
|
52
|
+
* `RETRIES` is optional, number of network retries (default 1).
|
53
|
+
* `--all-parts` fetch all parts.
|
54
|
+
* `--keep-year` undated reference should return actual reference with year.
|
54
55
|
|
55
56
|
=== relaton extract
|
56
57
|
|
@@ -306,4 +307,108 @@ $ relaton collection import FILE -c COLLECTION -d DIRECTORY
|
|
306
307
|
Import document or collection from XML `FILE` into `COLLECTION`.
|
307
308
|
|
308
309
|
* `COLLECTION` is optional. If collection doesn't exist then it will be created.
|
309
|
-
* `DIRECTORY` is optional, and specifies path to a directory with collections. Default is `$HOME/.relaton/collections`.
|
310
|
+
* `DIRECTORY` is optional, and specifies path to a directory with collections. Default is `$HOME/.relaton/collections`.
|
311
|
+
|
312
|
+
=== Cache DB manipulation
|
313
|
+
|
314
|
+
==== Create caache DB
|
315
|
+
|
316
|
+
----
|
317
|
+
$ relaton db create DIR
|
318
|
+
----
|
319
|
+
|
320
|
+
Creates a new cache DB in a directory `DIR` (optional, deafult is `/home/USER/.relaton/dbpath`). In case the target directory exists it will be used as a cache DB.
|
321
|
+
|
322
|
+
----
|
323
|
+
$ relaton db create
|
324
|
+
Cache DB is in "/Users/user/.relaton/cache"
|
325
|
+
|
326
|
+
$ relaton db create cachedb
|
327
|
+
Cache DB is in "/Users/user/RubyProjects/relaton-cli/cachedb"
|
328
|
+
----
|
329
|
+
|
330
|
+
==== Move cache DB
|
331
|
+
|
332
|
+
----
|
333
|
+
$ relaton db mv DIR
|
334
|
+
----
|
335
|
+
|
336
|
+
Move cache DB to another place `DIR`.
|
337
|
+
|
338
|
+
----
|
339
|
+
$ relaton db mv cache_dir
|
340
|
+
Cache DB is moved to "/Users/user/RubyProjects/relaton-cli/cache_dir"
|
341
|
+
----
|
342
|
+
|
343
|
+
==== Clear cache DB
|
344
|
+
|
345
|
+
Delete all entries from a chache DB.
|
346
|
+
|
347
|
+
----
|
348
|
+
$ relaton db clear
|
349
|
+
----
|
350
|
+
|
351
|
+
==== Fetch from cache DB
|
352
|
+
|
353
|
+
----
|
354
|
+
$ relaton db fetch -t TYPE -f FORMAT -y YEAR
|
355
|
+
----
|
356
|
+
|
357
|
+
Fetch an entry from a cache DB. See [relaton fetch](#relaton-fetch) for the arguments explanation.
|
358
|
+
|
359
|
+
==== Fetch all
|
360
|
+
|
361
|
+
Fetch all entries from a chache DB.
|
362
|
+
|
363
|
+
----
|
364
|
+
$ relaton db fetch_all TEXT -e EDITION -y YEAR -f FORMAT
|
365
|
+
----
|
366
|
+
|
367
|
+
* `TEXT` (optional) search for a certan string
|
368
|
+
* `EDITION` (optional) filter documets with a certain edition
|
369
|
+
* `YEAR` (optional) filter documents by a year
|
370
|
+
* `FORMAT` (optional) specify the output format. Recognised values are `xml` (default), yaml, `bibtex`.
|
371
|
+
|
372
|
+
----
|
373
|
+
$ relaton db fetch_all
|
374
|
+
<bibitem id="ISO/IECDIR1" type="international-standard">
|
375
|
+
...
|
376
|
+
|
377
|
+
$ relaton db fetch_all 'Procedures for the technical work'
|
378
|
+
<bibitem id="ISO/IECDIR1" type="international-standard">
|
379
|
+
<fetched>2021-04-01</fetched>
|
380
|
+
<title type="title-main" format="text/plain" language="en" script="Latn">Procedures for the technical work</title>
|
381
|
+
...
|
382
|
+
|
383
|
+
$ relaton db fetch_all -e 3
|
384
|
+
<bibitem id="ISO2146-2010" type="standard">
|
385
|
+
...
|
386
|
+
<edition>3</edition>
|
387
|
+
...
|
388
|
+
|
389
|
+
$ relaton db fetch_all -e 8 -y 2018
|
390
|
+
<bibitem id="ISO/IECDIR2IEC" type="international-standard">
|
391
|
+
<fetched>2021-04-01</fetched>
|
392
|
+
<title type="title-main" format="text/plain" language="en" script="Latn">Principles and rules for the structure and drafting of ISO and IEC documents</title>
|
393
|
+
<uri type="obp">https://www.iec.ch/members_experts/refdocs/iec/isoiecdir2%7Bed8.0.RLV%7Den.pdf</uri>
|
394
|
+
<docidentifier type="ISO">ISO/IEC DIR 2 IEC</docidentifier>
|
395
|
+
<date type="published">
|
396
|
+
<on>2018-05-01</on>
|
397
|
+
</date>
|
398
|
+
<edition>8</edition>
|
399
|
+
...
|
400
|
+
----
|
401
|
+
|
402
|
+
==== Get document type
|
403
|
+
|
404
|
+
----
|
405
|
+
$ relaton db doctype REF
|
406
|
+
----
|
407
|
+
|
408
|
+
Takes a reference `REF` and retuern a document type.
|
409
|
+
|
410
|
+
----
|
411
|
+
$ relaton db doctype 'CN(GB/T 1.1)'
|
412
|
+
Chinese Standard
|
413
|
+
GB/T 1.1
|
414
|
+
----
|
data/lib/relaton/cli.rb
CHANGED
@@ -3,16 +3,35 @@ require "relaton"
|
|
3
3
|
require_relative "cli/command"
|
4
4
|
|
5
5
|
module Relaton
|
6
|
-
def self.db
|
7
|
-
Cli.relaton
|
6
|
+
def self.db(dir = nil)
|
7
|
+
Cli.relaton dir
|
8
8
|
end
|
9
9
|
|
10
10
|
module Cli
|
11
11
|
class RelatonDb
|
12
12
|
include Singleton
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
DBCONF = "#{Dir.home}/.relaton/dbpath".freeze
|
15
|
+
|
16
|
+
# @param dir [String, nil]
|
17
|
+
# @return [Relaton::Db]
|
18
|
+
def db(dir)
|
19
|
+
if dir
|
20
|
+
File.write DBCONF, dir, encoding: "UTF-8"
|
21
|
+
@db = Relaton::Db.new dir, nil
|
22
|
+
else
|
23
|
+
@db ||= Relaton::Db.new dbpath, nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @return [String] path to DB
|
30
|
+
def dbpath
|
31
|
+
if File.exist?(DBCONF)
|
32
|
+
File.read(DBCONF, encoding: "UTF-8")
|
33
|
+
else "#{Dir.home}/.relaton/cache"
|
34
|
+
end
|
16
35
|
end
|
17
36
|
end
|
18
37
|
|
@@ -28,8 +47,10 @@ module Relaton
|
|
28
47
|
# easier we have added it as a class method so we can use this
|
29
48
|
# whenever necessary.
|
30
49
|
#
|
31
|
-
|
32
|
-
|
50
|
+
# @param dir [String, nil]
|
51
|
+
# @return [Relaton::Db]
|
52
|
+
def relaton(dir)
|
53
|
+
RelatonDb.instance.db dir
|
33
54
|
end
|
34
55
|
|
35
56
|
# @param content [Nokogiri::XML::Document]
|
data/lib/relaton/cli/command.rb
CHANGED
@@ -2,21 +2,29 @@ require "relaton/cli/relaton_file"
|
|
2
2
|
require "relaton/cli/xml_convertor"
|
3
3
|
require "relaton/cli/yaml_convertor"
|
4
4
|
require "relaton/cli/subcommand_collection"
|
5
|
+
require "relaton/cli/subcommand_db"
|
5
6
|
require "fcntl"
|
6
7
|
|
7
8
|
module Relaton
|
8
9
|
module Cli
|
9
10
|
class Command < Thor
|
11
|
+
include Relaton::Cli
|
12
|
+
|
10
13
|
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
|
11
|
-
option :type, aliases: :t,
|
14
|
+
option :type, aliases: :t, desc: "Type of standard to "\
|
12
15
|
"get bibliographic entry for"
|
13
|
-
option :format, aliases: :f, desc: "Output format (xml, bibtex). "\
|
16
|
+
option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
|
14
17
|
"Default xml."
|
15
18
|
option :year, aliases: :y, type: :numeric, desc: "Year the standard was "\
|
16
19
|
"published"
|
20
|
+
option :"all-parts", type: :boolean, desc: "Fetch all parts"
|
21
|
+
option :"keep-year", type: :boolean, desc: "Undated reference should "\
|
22
|
+
"return actual reference with year"
|
23
|
+
option :retries, aliases: :r, type: :numeric, desc: "Number of network "\
|
24
|
+
"retries. Default 1."
|
17
25
|
|
18
26
|
def fetch(code)
|
19
|
-
Relaton.db
|
27
|
+
# Relaton.db
|
20
28
|
io = IO.new(STDOUT.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
21
29
|
io.puts(fetch_document(code, options) || supported_type_message)
|
22
30
|
end
|
@@ -35,8 +43,8 @@ module Relaton
|
|
35
43
|
option :title, aliases: :t, desc: "Title of resulting Relaton collection"
|
36
44
|
option :organization, aliases: :g, desc: "Organization owner of Relaton "\
|
37
45
|
"collection"
|
38
|
-
option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
|
39
|
-
|
46
|
+
# option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
|
47
|
+
# "YAML format"
|
40
48
|
option :extension, aliases: :x, desc: "File extension of destination "\
|
41
49
|
"Relaton file, defaults to 'rxl'"
|
42
50
|
|
@@ -48,8 +56,8 @@ module Relaton
|
|
48
56
|
"Relaton Collection into multiple files"
|
49
57
|
option :extension, aliases: :x, default: "rxl", desc: "File extension "\
|
50
58
|
"of Relaton XML files, defaults to 'rxl'"
|
51
|
-
option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
|
52
|
-
|
59
|
+
# option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
|
60
|
+
# "YAML format"
|
53
61
|
|
54
62
|
def split(source, outdir)
|
55
63
|
Relaton::Cli::RelatonFile.split(source, outdir, options)
|
@@ -139,34 +147,50 @@ module Relaton
|
|
139
147
|
desc "collection SUBCOMMAND", "Collection manipulations"
|
140
148
|
subcommand "collection", SubcommandCollection
|
141
149
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
# @param options [Hash]
|
146
|
-
# @option options [String] :type
|
147
|
-
# @option options [String, NilClass] :format
|
148
|
-
# @option options [Integer, NilClass] :year
|
149
|
-
def fetch_document(code, options)
|
150
|
-
if registered_types.include?(options[:type])
|
151
|
-
doc = Cli.relaton.fetch(code, options[:year]&.to_s)
|
152
|
-
if doc
|
153
|
-
options[:format] == "bibtex" ? doc.to_bibtex : doc.to_xml
|
154
|
-
else
|
155
|
-
"No matching bibliographic entry found"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
rescue RelatonBib::RequestError => e
|
159
|
-
e.message
|
160
|
-
end
|
150
|
+
desc "db SUBCOMMAND", "Cache DB manipulation"
|
151
|
+
subcommand "db", SubcommandDb
|
152
|
+
end
|
161
153
|
|
162
|
-
|
163
|
-
|
154
|
+
private
|
155
|
+
|
156
|
+
# @param code [String]
|
157
|
+
# @param options [Hash]
|
158
|
+
# @option options [String] :type
|
159
|
+
# @option options [String, NilClass] :format
|
160
|
+
# @option options [Integer, NilClass] :year
|
161
|
+
# @return [String, nil]
|
162
|
+
def fetch_document(code, options) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
163
|
+
year = options[:year]&.to_s
|
164
|
+
if (processor = Relaton::Registry.instance.by_type options[:type]&.upcase)
|
165
|
+
doc = Relaton.db.fetch_std code, year, processor.short, options.dup
|
166
|
+
elsif options[:type] then return
|
167
|
+
else doc = Relaton.db.fetch(code, year, options.dup)
|
164
168
|
end
|
169
|
+
return "No matching bibliographic entry found" unless doc
|
170
|
+
|
171
|
+
serialize doc, options[:format]
|
172
|
+
rescue RelatonBib::RequestError => e
|
173
|
+
e.message
|
174
|
+
end
|
165
175
|
|
166
|
-
|
167
|
-
|
168
|
-
|
176
|
+
# @param doc [RelatonBib::BibliographicItem]
|
177
|
+
# @param format [String]
|
178
|
+
# @return [String]
|
179
|
+
def serialize(doc, format)
|
180
|
+
case format
|
181
|
+
when "yaml", "yml" then doc.to_hash.to_yaml
|
182
|
+
when "bibtex" then doc.to_bibtex
|
183
|
+
else doc.to_xml
|
169
184
|
end
|
170
185
|
end
|
186
|
+
|
187
|
+
def supported_type_message
|
188
|
+
["Recognised types:", registered_types.sort.join(", ")].join(" ")
|
189
|
+
end
|
190
|
+
|
191
|
+
def registered_types
|
192
|
+
@registered_types ||=
|
193
|
+
Relaton::Registry.instance.processors.each.map { |_n, pr| pr.prefix }
|
194
|
+
end
|
171
195
|
end
|
172
196
|
end
|
@@ -105,13 +105,13 @@ module Relaton
|
|
105
105
|
"$HOME/.relaton/collections."
|
106
106
|
|
107
107
|
def fetch(code)
|
108
|
-
doc =
|
108
|
+
doc = Relaton.db.fetch(code, options[:year]&.to_s)
|
109
109
|
if doc
|
110
110
|
colfile = File.join directory, options[:collection]
|
111
111
|
coll = read_collection colfile
|
112
112
|
coll << doc
|
113
113
|
File.write colfile, coll.to_yaml, encoding: "UTF-8"
|
114
|
-
else "No matching bibliographic entry found"
|
114
|
+
else warn "No matching bibliographic entry found"
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Relaton
|
2
|
+
module Cli
|
3
|
+
class SubcommandDb < Thor
|
4
|
+
include Relaton::Cli
|
5
|
+
|
6
|
+
desc "create DIR", "Create new cache DB. Default DIR is "\
|
7
|
+
"/home/user/.relaon/cache/"
|
8
|
+
|
9
|
+
def create(dir = nil)
|
10
|
+
db = Relaton.db (dir && File.expand_path(dir))
|
11
|
+
path = db.instance_variable_get(:@db).dir
|
12
|
+
warn "Cache DB is in \"#{path}\""
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "mv DIR", "Move cache DB to a new directory"
|
16
|
+
|
17
|
+
def mv(dir)
|
18
|
+
new_path = File.expand_path dir
|
19
|
+
path = Relaton.db.mv new_path
|
20
|
+
if path
|
21
|
+
File.write Cli::RelatonDb::DBCONF, path, encoding: "UTF-8"
|
22
|
+
warn "Cache DB is moved to \"#{path}\""
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "clear", "Clear cache DB"
|
27
|
+
|
28
|
+
def clear
|
29
|
+
Relaton.db.clear
|
30
|
+
warn "Cache DB is cleared"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE from "\
|
34
|
+
"cache DB"
|
35
|
+
option :type, aliases: :t, desc: "Type of standard to "\
|
36
|
+
"get bibliographic entry for"
|
37
|
+
option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
|
38
|
+
"Default xml."
|
39
|
+
option :year, aliases: :y, type: :numeric, desc: "Year the standard was "\
|
40
|
+
"published"
|
41
|
+
|
42
|
+
def fetch(code)
|
43
|
+
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
44
|
+
opts = options.merge(fetch_db: true)
|
45
|
+
io.puts(fetch_document(code, opts) || supported_type_message)
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "fetch_all TEXT", "Query for all documents in a cache DB for a "\
|
49
|
+
"certain string"
|
50
|
+
option :edition, aliases: :e, desc: "Filter entries by edition"
|
51
|
+
option :year, aliases: :y, desc: "Filter entries by year"
|
52
|
+
option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
|
53
|
+
"Default xml."
|
54
|
+
|
55
|
+
def fetch_all(text = nil) # rubocop:disable Metrics/AbcSize
|
56
|
+
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
57
|
+
opts = options.each_with_object({}) do |(k, v), o|
|
58
|
+
o[k.to_sym] = v unless k == "format"
|
59
|
+
end
|
60
|
+
Relaton.db.fetch_all(text, **opts).each do |doc|
|
61
|
+
io.puts serialize(doc, options[:format])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "doctype REF", "Detect document type from REF"
|
66
|
+
|
67
|
+
def doctype(ref)
|
68
|
+
io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
|
69
|
+
io.puts Relaton.db.docid_type(ref)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/relaton/cli/version.rb
CHANGED
data/relaton-cli.gemspec
CHANGED
@@ -23,20 +23,19 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = ">= 2.4.0"
|
24
24
|
|
25
25
|
spec.add_development_dependency "byebug", "~> 11.0"
|
26
|
-
spec.add_development_dependency "debase"
|
26
|
+
# spec.add_development_dependency "debase"
|
27
27
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
28
28
|
spec.add_development_dependency "pry"
|
29
|
-
spec.add_development_dependency "rake"
|
29
|
+
spec.add_development_dependency "rake"
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
31
|
spec.add_development_dependency "rspec-command", "~> 1.0.3"
|
32
32
|
spec.add_development_dependency "rspec-core", "~> 3.4"
|
33
|
-
spec.add_development_dependency "ruby-debug-ide"
|
33
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
34
34
|
spec.add_development_dependency "simplecov"
|
35
35
|
spec.add_development_dependency "vcr"
|
36
36
|
spec.add_development_dependency "webmock"
|
37
37
|
|
38
|
-
spec.add_runtime_dependency "liquid"
|
39
|
-
spec.add_runtime_dependency "relaton", "
|
38
|
+
spec.add_runtime_dependency "liquid", "~> 4"
|
39
|
+
spec.add_runtime_dependency "relaton", "1.7.pre7"
|
40
40
|
spec.add_runtime_dependency "thor"
|
41
|
-
# spec.add_runtime_dependency 'byebug'
|
42
41
|
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.7.pre3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '11.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: debase
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: equivalent-xml
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +56,16 @@ dependencies:
|
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +108,6 @@ dependencies:
|
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '3.4'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: ruby-debug-ide
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
111
|
- !ruby/object:Gem::Dependency
|
140
112
|
name: simplecov
|
141
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,30 +154,30 @@ dependencies:
|
|
182
154
|
name: liquid
|
183
155
|
requirement: !ruby/object:Gem::Requirement
|
184
156
|
requirements:
|
185
|
-
- - "
|
157
|
+
- - "~>"
|
186
158
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
159
|
+
version: '4'
|
188
160
|
type: :runtime
|
189
161
|
prerelease: false
|
190
162
|
version_requirements: !ruby/object:Gem::Requirement
|
191
163
|
requirements:
|
192
|
-
- - "
|
164
|
+
- - "~>"
|
193
165
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
166
|
+
version: '4'
|
195
167
|
- !ruby/object:Gem::Dependency
|
196
168
|
name: relaton
|
197
169
|
requirement: !ruby/object:Gem::Requirement
|
198
170
|
requirements:
|
199
|
-
- -
|
171
|
+
- - '='
|
200
172
|
- !ruby/object:Gem::Version
|
201
|
-
version: 1.
|
173
|
+
version: 1.7.pre7
|
202
174
|
type: :runtime
|
203
175
|
prerelease: false
|
204
176
|
version_requirements: !ruby/object:Gem::Requirement
|
205
177
|
requirements:
|
206
|
-
- -
|
178
|
+
- - '='
|
207
179
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
180
|
+
version: 1.7.pre7
|
209
181
|
- !ruby/object:Gem::Dependency
|
210
182
|
name: thor
|
211
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,9 +202,7 @@ extra_rdoc_files:
|
|
230
202
|
- docs/README.adoc
|
231
203
|
- LICENSE
|
232
204
|
files:
|
233
|
-
- ".github/workflows/
|
234
|
-
- ".github/workflows/ubuntu.yml"
|
235
|
-
- ".github/workflows/windows.yml"
|
205
|
+
- ".github/workflows/rake.yml"
|
236
206
|
- ".gitignore"
|
237
207
|
- ".hound.yml"
|
238
208
|
- ".rspec"
|
@@ -256,6 +226,7 @@ files:
|
|
256
226
|
- lib/relaton/cli/full_text_search.rb
|
257
227
|
- lib/relaton/cli/relaton_file.rb
|
258
228
|
- lib/relaton/cli/subcommand_collection.rb
|
229
|
+
- lib/relaton/cli/subcommand_db.rb
|
259
230
|
- lib/relaton/cli/version.rb
|
260
231
|
- lib/relaton/cli/xml_convertor.rb
|
261
232
|
- lib/relaton/cli/xml_to_html_renderer.rb
|
@@ -280,11 +251,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
251
|
version: 2.4.0
|
281
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
253
|
requirements:
|
283
|
-
- - "
|
254
|
+
- - ">"
|
284
255
|
- !ruby/object:Gem::Version
|
285
|
-
version:
|
256
|
+
version: 1.3.1
|
286
257
|
requirements: []
|
287
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.2.3
|
288
259
|
signing_key:
|
289
260
|
specification_version: 4
|
290
261
|
summary: Relaton Command-line Interface
|
data/.github/workflows/macos.yml
DELETED
@@ -1,34 +0,0 @@
|
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,35 +0,0 @@
|
|
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
|