relaton-cli 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d05ee41c481b709bb9d24b0336ad662322799482a7973cc6019c9b16d1c426f
4
- data.tar.gz: 25ddc1e8025dd5cf36c3d1788f807d012f5a78522429e977bad281d4bac81f9e
3
+ metadata.gz: 6d1136ef4b30917aa5a29aa324cfacacc3be729c3a83f6aa3a41ddefc93e12c2
4
+ data.tar.gz: 8a727b79dce16e15467463d5bbf648a37fa6d49e988e904aa4826025e6b9c9e3
5
5
  SHA512:
6
- metadata.gz: 2a6105a3cd8ce03c33035a19361755e5ed3dec1c26c4d0423309c56850be5d5ea0786d2e0c8fa59669a7a860df012d97f62a4585d15e8c2e896bdc3e491cc4bf
7
- data.tar.gz: acfd92a715fe36a393f9dbd0c6cb0db0c3bee4dc5525c853948073bbe3ee8d91b1b58d43ee69fdc5ffc416e9fe78805dffdda21b9c0e8f624e9f548dd7a1aabf
6
+ metadata.gz: b8eececfadffa4cdf1e9eb57cb47e3241bfbcb6547e779026f61dc72625e751f9acd93946922b22d0159ffd4f60ec24c8abaa4011313d35ad62fe236399abb9a
7
+ data.tar.gz: e083e9481f91c42544e65426d05983bdc21841e5b8adf4ff4a90c7942cefbe65168842b22cc4e9e75d5d9cb6b6b46c6374a0233a6d8d6ac0147c2f53994aea65
@@ -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
@@ -5,4 +5,3 @@ source "https://rubygems.org"
5
5
 
6
6
  # Specify your gem's dependencies in gemspec
7
7
  gemspec
8
-
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/ubuntu/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=ubuntu"]
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.
@@ -12,6 +10,7 @@ Please refer to https://github.com/relaton/relaton.
12
10
 
13
11
  == Commands
14
12
 
13
+ Each command has an option `--verbose` (short form is `-v`). Use the option to get warnings in the commands outpput.
15
14
  The following commands are provided.
16
15
 
17
16
  === relaton concatenate
@@ -43,14 +42,17 @@ suports an additional `-x` or `--extension` options to use different extension.
43
42
 
44
43
  [source,console]
45
44
  ----
46
- $ relaton fetch CODE -t TYPE -f FORMAT -y YEAR
45
+ $ relaton fetch CODE -t TYPE -f FORMAT -y YEAR -r RETRIES --all-parts --keep-year
47
46
  ----
48
47
 
49
48
  Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
50
49
 
51
50
  * `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`.
51
+ * `FORMAT` is optional, and specifies the output format; the recognised values for `FORMAT` are `xml` (default), yaml, `bibtex`.
52
+ * `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`.
53
+ * `RETRIES` is optional, number of network retries (default 1).
54
+ * `--all-parts` fetch all parts.
55
+ * `--keep-year` undated reference should return actual reference with year.
54
56
 
55
57
  === relaton extract
56
58
 
@@ -306,4 +308,108 @@ $ relaton collection import FILE -c COLLECTION -d DIRECTORY
306
308
  Import document or collection from XML `FILE` into `COLLECTION`.
307
309
 
308
310
  * `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`.
311
+ * `DIRECTORY` is optional, and specifies path to a directory with collections. Default is `$HOME/.relaton/collections`.
312
+
313
+ === Cache DB manipulation
314
+
315
+ ==== Create cache DB
316
+
317
+ ----
318
+ $ relaton db create DIR
319
+ ----
320
+
321
+ 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.
322
+
323
+ ----
324
+ $ relaton db create
325
+ Cache DB is in "/Users/user/.relaton/cache"
326
+
327
+ $ relaton db create cachedb
328
+ Cache DB is in "/Users/user/RubyProjects/relaton-cli/cachedb"
329
+ ----
330
+
331
+ ==== Move cache DB
332
+
333
+ ----
334
+ $ relaton db mv DIR
335
+ ----
336
+
337
+ Move cache DB to another place `DIR`.
338
+
339
+ ----
340
+ $ relaton db mv cache_dir
341
+ Cache DB is moved to "/Users/user/RubyProjects/relaton-cli/cache_dir"
342
+ ----
343
+
344
+ ==== Clear cache DB
345
+
346
+ Delete all entries from a chache DB.
347
+
348
+ ----
349
+ $ relaton db clear
350
+ ----
351
+
352
+ ==== Fetch from cache DB
353
+
354
+ ----
355
+ $ relaton db fetch -t TYPE -f FORMAT -y YEAR
356
+ ----
357
+
358
+ Fetch an entry from a cache DB. See [relaton fetch](#relaton-fetch) for the arguments explanation.
359
+
360
+ ==== Fetch all
361
+
362
+ Fetch all entries from a chache DB.
363
+
364
+ ----
365
+ $ relaton db fetch_all TEXT -e EDITION -y YEAR -f FORMAT
366
+ ----
367
+
368
+ * `TEXT` (optional) search for a certan string
369
+ * `EDITION` (optional) filter documets with a certain edition
370
+ * `YEAR` (optional) filter documents by a year
371
+ * `FORMAT` (optional) specify the output format. Recognised values are `xml` (default), yaml, `bibtex`.
372
+
373
+ ----
374
+ $ relaton db fetch_all
375
+ <bibitem id="ISO/IECDIR1" type="international-standard">
376
+ ...
377
+
378
+ $ relaton db fetch_all 'Procedures for the technical work'
379
+ <bibitem id="ISO/IECDIR1" type="international-standard">
380
+ <fetched>2021-04-01</fetched>
381
+ <title type="title-main" format="text/plain" language="en" script="Latn">Procedures for the technical work</title>
382
+ ...
383
+
384
+ $ relaton db fetch_all -e 3
385
+ <bibitem id="ISO2146-2010" type="standard">
386
+ ...
387
+ <edition>3</edition>
388
+ ...
389
+
390
+ $ relaton db fetch_all -e 8 -y 2018
391
+ <bibitem id="ISO/IECDIR2IEC" type="international-standard">
392
+ <fetched>2021-04-01</fetched>
393
+ <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>
394
+ <uri type="obp">https://www.iec.ch/members_experts/refdocs/iec/isoiecdir2%7Bed8.0.RLV%7Den.pdf</uri>
395
+ <docidentifier type="ISO">ISO/IEC DIR 2 IEC</docidentifier>
396
+ <date type="published">
397
+ <on>2018-05-01</on>
398
+ </date>
399
+ <edition>8</edition>
400
+ ...
401
+ ----
402
+
403
+ ==== Get document type
404
+
405
+ ----
406
+ $ relaton db doctype REF
407
+ ----
408
+
409
+ Takes a reference `REF` and retuern a document type.
410
+
411
+ ----
412
+ $ relaton db doctype 'CN(GB/T 1.1)'
413
+ Chinese Standard
414
+ GB/T 1.1
415
+ ----
data/lib/relaton/cli.rb CHANGED
@@ -1,18 +1,38 @@
1
1
  require "thor"
2
+ require "thor/hollaback"
2
3
  require "relaton"
3
4
  require_relative "cli/command"
4
5
 
5
6
  module Relaton
6
- def self.db
7
- Cli.relaton
7
+ def self.db(dir = nil)
8
+ Cli.relaton dir
8
9
  end
9
10
 
10
11
  module Cli
11
12
  class RelatonDb
12
13
  include Singleton
13
14
 
14
- def db
15
- @db ||= Relaton::Db.new("#{Dir.home}/.relaton/cache", nil)
15
+ DBCONF = "#{Dir.home}/.relaton/dbpath".freeze
16
+
17
+ # @param dir [String, nil]
18
+ # @return [Relaton::Db]
19
+ def db(dir)
20
+ if dir
21
+ File.write DBCONF, dir, encoding: "UTF-8"
22
+ @db = Relaton::Db.new dir, nil
23
+ else
24
+ @db ||= Relaton::Db.new dbpath, nil
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ # @return [String] path to DB
31
+ def dbpath
32
+ if File.exist?(DBCONF)
33
+ File.read(DBCONF, encoding: "UTF-8")
34
+ else "#{Dir.home}/.relaton/cache"
35
+ end
16
36
  end
17
37
  end
18
38
 
@@ -28,8 +48,10 @@ module Relaton
28
48
  # easier we have added it as a class method so we can use this
29
49
  # whenever necessary.
30
50
  #
31
- def relaton
32
- RelatonDb.instance.db
51
+ # @param dir [String, nil]
52
+ # @return [Relaton::Db]
53
+ def relaton(dir)
54
+ RelatonDb.instance.db dir
33
55
  end
34
56
 
35
57
  # @param content [Nokogiri::XML::Document]
@@ -2,21 +2,30 @@ 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
+ class_before :relaton_config
13
+ class_option :verbose, aliases: :v, type: :boolean, desc: "Output warnings"
14
+
10
15
  desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
11
- option :type, aliases: :t, required: true, desc: "Type of standard to "\
16
+ option :type, aliases: :t, desc: "Type of standard to "\
12
17
  "get bibliographic entry for"
13
- option :format, aliases: :f, desc: "Output format (xml, bibtex). "\
18
+ option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
14
19
  "Default xml."
15
20
  option :year, aliases: :y, type: :numeric, desc: "Year the standard was "\
16
21
  "published"
22
+ option :"all-parts", type: :boolean, desc: "Fetch all parts"
23
+ option :"keep-year", type: :boolean, desc: "Undated reference should "\
24
+ "return actual reference with year"
25
+ option :retries, aliases: :r, type: :numeric, desc: "Number of network "\
26
+ "retries. Default 1."
17
27
 
18
28
  def fetch(code)
19
- Relaton.db
20
29
  io = IO.new(STDOUT.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
21
30
  io.puts(fetch_document(code, options) || supported_type_message)
22
31
  end
@@ -35,8 +44,6 @@ module Relaton
35
44
  option :title, aliases: :t, desc: "Title of resulting Relaton collection"
36
45
  option :organization, aliases: :g, desc: "Organization owner of Relaton "\
37
46
  "collection"
38
- option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
39
- "YAML format"
40
47
  option :extension, aliases: :x, desc: "File extension of destination "\
41
48
  "Relaton file, defaults to 'rxl'"
42
49
 
@@ -48,8 +55,6 @@ module Relaton
48
55
  "Relaton Collection into multiple files"
49
56
  option :extension, aliases: :x, default: "rxl", desc: "File extension "\
50
57
  "of Relaton XML files, defaults to 'rxl'"
51
- option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton "\
52
- "YAML format"
53
58
 
54
59
  def split(source, outdir)
55
60
  Relaton::Cli::RelatonFile.split(source, outdir, options)
@@ -139,34 +144,60 @@ module Relaton
139
144
  desc "collection SUBCOMMAND", "Collection manipulations"
140
145
  subcommand "collection", SubcommandCollection
141
146
 
142
- private
143
-
144
- # @param code [String]
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"
147
+ desc "db SUBCOMMAND", "Cache DB manipulation"
148
+ subcommand "db", SubcommandDb
149
+
150
+ no_commands do
151
+ def relaton_config
152
+ log_types = %i[info error]
153
+ log_types << :warning if options[:verbose]
154
+ Relaton.configure do |conf|
155
+ conf.logs = log_types
156
156
  end
157
157
  end
158
- rescue RelatonBib::RequestError => e
159
- e.message
160
158
  end
159
+ end
161
160
 
162
- def supported_type_message
163
- ["Recognised types:", registered_types.sort.join(", ")].join(" ")
161
+ private
162
+
163
+ # @param code [String]
164
+ # @param options [Hash]
165
+ # @option options [String] :type
166
+ # @option options [String, NilClass] :format
167
+ # @option options [Integer, NilClass] :year
168
+ # @return [String, nil]
169
+ def fetch_document(code, options) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
170
+ year = options[:year]&.to_s
171
+ if (processor = Relaton::Registry.instance.by_type options[:type]&.upcase)
172
+ doc = Relaton.db.fetch_std code, year, processor.short, options.dup
173
+ elsif options[:type] then return
174
+ else doc = Relaton.db.fetch(code, year, options.dup)
164
175
  end
176
+ return "No matching bibliographic entry found" unless doc
177
+
178
+ serialize doc, options[:format]
179
+ rescue RelatonBib::RequestError => e
180
+ e.message
181
+ end
165
182
 
166
- def registered_types
167
- @registered_types ||=
168
- Relaton::Registry.instance.processors.each.map { |_n, pr| pr.prefix }
183
+ # @param doc [RelatonBib::BibliographicItem]
184
+ # @param format [String]
185
+ # @return [String]
186
+ def serialize(doc, format)
187
+ case format
188
+ when "yaml", "yml" then doc.to_hash.to_yaml
189
+ when "bibtex" then doc.to_bibtex
190
+ else doc.to_xml
169
191
  end
170
192
  end
193
+
194
+ def supported_type_message
195
+ ["Recognised types:", registered_types.sort.join(", ")].join(" ")
196
+ end
197
+
198
+ def registered_types
199
+ @registered_types ||=
200
+ Relaton::Registry.instance.processors.each.map { |_n, pr| pr.prefix }
201
+ end
171
202
  end
172
203
  end
@@ -150,7 +150,7 @@ module Relaton
150
150
  mem << bibdata_instance(doc, xml[:file])
151
151
  else mem
152
152
  end
153
- end.uniq &:id
153
+ end
154
154
  end
155
155
 
156
156
  def concatenate_and_write_to_files
@@ -3,6 +3,9 @@ require "relaton/cli/full_text_search"
3
3
  module Relaton
4
4
  module Cli
5
5
  class SubcommandCollection < Thor
6
+ include Relaton::Cli
7
+ class_option :verbose, aliases: :v, type: :boolean, desc: "Output warnings"
8
+
6
9
  desc "create COLLECTION", "Create collection"
7
10
  option :dir, aliases: :d, desc: "Directory to store collection. Default "\
8
11
  "is $HOME/.relaton/collections."
@@ -104,21 +107,21 @@ module Relaton
104
107
  option :dir, aliases: :d, desc: "Directory with collections. Default is "\
105
108
  "$HOME/.relaton/collections."
106
109
 
107
- def fetch(code)
108
- doc = Cli.relaton.fetch(code, options[:year]&.to_s)
110
+ def fetch(code) # rubocop:disable Metrics/AbcSize
111
+ doc = Relaton.db.fetch(code, options[:year]&.to_s)
109
112
  if doc
110
113
  colfile = File.join directory, options[:collection]
111
114
  coll = read_collection colfile
112
115
  coll << doc
113
116
  File.write colfile, coll.to_yaml, encoding: "UTF-8"
114
- else "No matching bibliographic entry found"
117
+ else warn "No matching bibliographic entry found"
115
118
  end
116
119
  end
117
120
 
118
121
  desc "import FILE", "Import document or collection from an XML file "\
119
122
  "into another collection"
120
- option :collection, aliases: :c, required: true, desc: "Collection "\
121
- "to store a document. If collection doesn't exist then it'll be created."
123
+ option :collection, aliases: :c, required: true, desc: "Collection to "\
124
+ "store a document. If collection doesn't exist then it'll be created."
122
125
  option :dir, aliases: :d, desc: "Directory with collections. Default is "\
123
126
  "$HOME/.relaton/collections."
124
127
 
@@ -0,0 +1,74 @@
1
+ module Relaton
2
+ module Cli
3
+ class SubcommandDb < Thor
4
+ include Relaton::Cli
5
+ class_option :verbose, aliases: :v, type: :boolean, desc: "Output warnings"
6
+
7
+ desc "create DIR", "Create new cache DB. Default DIR is "\
8
+ "/home/user/.relaon/cache/"
9
+
10
+ def create(dir = nil)
11
+ db = Relaton.db (dir && File.expand_path(dir))
12
+ path = db.instance_variable_get(:@db).dir
13
+ warn "Cache DB is in \"#{path}\""
14
+ end
15
+
16
+ desc "mv DIR", "Move cache DB to a new directory"
17
+
18
+ def mv(dir)
19
+ new_path = File.expand_path dir
20
+ path = Relaton.db.mv new_path
21
+ if path
22
+ File.write Cli::RelatonDb::DBCONF, path, encoding: "UTF-8"
23
+ warn "Cache DB is moved to \"#{path}\""
24
+ end
25
+ end
26
+
27
+ desc "clear", "Clear cache DB"
28
+
29
+ def clear
30
+ Relaton.db.clear
31
+ warn "Cache DB is cleared"
32
+ end
33
+
34
+ desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE from "\
35
+ "cache DB"
36
+ option :type, aliases: :t, desc: "Type of standard to "\
37
+ "get bibliographic entry for"
38
+ option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
39
+ "Default xml."
40
+ option :year, aliases: :y, type: :numeric, desc: "Year the standard was "\
41
+ "published"
42
+
43
+ def fetch(code)
44
+ io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
45
+ opts = options.merge(fetch_db: true)
46
+ io.puts(fetch_document(code, opts) || supported_type_message)
47
+ end
48
+
49
+ desc "fetch_all TEXT", "Query for all documents in a cache DB for a "\
50
+ "certain string"
51
+ option :edition, aliases: :e, desc: "Filter entries by edition"
52
+ option :year, aliases: :y, desc: "Filter entries by year"
53
+ option :format, aliases: :f, desc: "Output format (xml, yaml, bibtex). "\
54
+ "Default xml."
55
+
56
+ def fetch_all(text = nil) # rubocop:disable Metrics/AbcSize
57
+ io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
58
+ opts = options.each_with_object({}) do |(k, v), o|
59
+ o[k.to_sym] = v unless k == "format"
60
+ end
61
+ Relaton.db.fetch_all(text, **opts).each do |doc|
62
+ io.puts serialize(doc, options[:format])
63
+ end
64
+ end
65
+
66
+ desc "doctype REF", "Detect document type from REF"
67
+
68
+ def doctype(ref)
69
+ io = IO.new($stdout.fcntl(::Fcntl::F_DUPFD), mode: "w:UTF-8")
70
+ io.puts Relaton.db.docid_type(ref)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "1.7.0".freeze
3
+ VERSION = "1.8.0".freeze
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ module Relaton::Cli
32
32
  # @param options [Hash]
33
33
  # @return [String] HTML
34
34
  def self.render(file, options)
35
- new(options).render(file)
35
+ new(**options).render(file)
36
36
  end
37
37
 
38
38
  private
@@ -37,7 +37,7 @@ module Relaton
37
37
  processor.hash_to_bib content
38
38
  else
39
39
  RelatonBib::BibliographicItem.new(
40
- RelatonBib::HashConverter::hash_to_bib(content)
40
+ **RelatonBib::HashConverter::hash_to_bib(content)
41
41
  )
42
42
  end
43
43
  end
data/relaton-cli.gemspec CHANGED
@@ -23,20 +23,20 @@ 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", "~> 12.0"
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", "~> 1.7.0"
38
+ spec.add_runtime_dependency "liquid", "~> 4"
39
+ spec.add_runtime_dependency "relaton", ">=1.8.0"
40
40
  spec.add_runtime_dependency "thor"
41
- # spec.add_runtime_dependency 'byebug'
41
+ spec.add_runtime_dependency "thor-hollaback"
42
42
  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.7.0
4
+ version: 1.8.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: 2020-11-27 00:00:00.000000000 Z
11
+ date: 2021-05-17 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: '12.0'
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: '12.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '3.4'
125
111
  - !ruby/object:Gem::Dependency
126
- name: ruby-debug-ide
112
+ name: simplecov
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -137,7 +123,7 @@ dependencies:
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
139
125
  - !ruby/object:Gem::Dependency
140
- name: simplecov
126
+ name: vcr
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - ">="
@@ -151,7 +137,7 @@ dependencies:
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
153
139
  - !ruby/object:Gem::Dependency
154
- name: vcr
140
+ name: webmock
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - ">="
@@ -165,49 +151,49 @@ dependencies:
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
167
153
  - !ruby/object:Gem::Dependency
168
- name: webmock
154
+ name: liquid
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
- - - ">="
157
+ - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
159
+ version: '4'
160
+ type: :runtime
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
- - - ">="
164
+ - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: '0'
166
+ version: '4'
181
167
  - !ruby/object:Gem::Dependency
182
- name: liquid
168
+ name: relaton
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - ">="
186
172
  - !ruby/object:Gem::Version
187
- version: '0'
173
+ version: 1.8.0
188
174
  type: :runtime
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - ">="
193
179
  - !ruby/object:Gem::Version
194
- version: '0'
180
+ version: 1.8.0
195
181
  - !ruby/object:Gem::Dependency
196
- name: relaton
182
+ name: thor
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
- - - "~>"
185
+ - - ">="
200
186
  - !ruby/object:Gem::Version
201
- version: 1.7.0
187
+ version: '0'
202
188
  type: :runtime
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
- - - "~>"
192
+ - - ">="
207
193
  - !ruby/object:Gem::Version
208
- version: 1.7.0
194
+ version: '0'
209
195
  - !ruby/object:Gem::Dependency
210
- name: thor
196
+ name: thor-hollaback
211
197
  requirement: !ruby/object:Gem::Requirement
212
198
  requirements:
213
199
  - - ">="
@@ -230,9 +216,7 @@ extra_rdoc_files:
230
216
  - docs/README.adoc
231
217
  - LICENSE
232
218
  files:
233
- - ".github/workflows/macos.yml"
234
- - ".github/workflows/ubuntu.yml"
235
- - ".github/workflows/windows.yml"
219
+ - ".github/workflows/rake.yml"
236
220
  - ".gitignore"
237
221
  - ".hound.yml"
238
222
  - ".rspec"
@@ -256,6 +240,7 @@ files:
256
240
  - lib/relaton/cli/full_text_search.rb
257
241
  - lib/relaton/cli/relaton_file.rb
258
242
  - lib/relaton/cli/subcommand_collection.rb
243
+ - lib/relaton/cli/subcommand_db.rb
259
244
  - lib/relaton/cli/version.rb
260
245
  - lib/relaton/cli/xml_convertor.rb
261
246
  - lib/relaton/cli/xml_to_html_renderer.rb
@@ -284,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
269
  - !ruby/object:Gem::Version
285
270
  version: '0'
286
271
  requirements: []
287
- rubygems_version: 3.0.6
272
+ rubygems_version: 3.2.3
288
273
  signing_key:
289
274
  specification_version: 4
290
275
  summary: Relaton Command-line Interface
@@ -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