relaton-cli 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06df07e066e1a948056b44297e588302b2638c6ccdcd51c3cdaabf08cae52d35
4
- data.tar.gz: a4e4c343228b83d0cf8b275a774c829a878492a233777ca5c06d7b8f555ae2e8
3
+ metadata.gz: 2b8db31870f272c13e8704dfb09b08a7e56ea703478db5683d72fccb3c92981a
4
+ data.tar.gz: 15fa2d2786a1c0d0f50054da7e7b0eb8a87a06b64cef492693938243534d9b75
5
5
  SHA512:
6
- metadata.gz: 109b7223d5bcd7984e1557420c57529647caf1667b30f0f371d63c7a25541dab840da76968e882e06b76bc2096a66566317634e51c3b540de7ef1ec92f696239
7
- data.tar.gz: b69daf5854b6c0b484ebcfbfffe79932aede75fc8ed63221d8d2ded7cbf7bafcfc5144fe9e75ba5412a64cb2be548585041a8177ca38f4b5a82053902c4c6804
6
+ metadata.gz: 3ab548b6a6ffd205c9f549bea24e9620a13a8faa3dc9928b88368b085c2b7147add716e59c1efe8aa8137809a79c040ef305d6eb0529b9dfb131a419f24d76d3
7
+ data.tar.gz: fbb82682d1f7917d10148404ffa046adaed0048bbb330c840cad22a9f0c08fc80cc9c508febedb5355fe51c34656e24d28af6bf587a6d6a8f7585caa3695b06a
@@ -8,6 +8,7 @@ module Relaton
8
8
  class Command < Thor
9
9
  desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
10
10
  option :type, aliases: :t, required: true, desc: "Type of standard to get bibliographic entry for"
11
+ option :format, aliases: :f, desc: "Output format (xml, bibtex). Default xml."
11
12
  option :year, aliases: :y, type: :numeric, desc: "Year the standard was published"
12
13
 
13
14
  def fetch(code)
@@ -92,10 +93,19 @@ module Relaton
92
93
 
93
94
  private
94
95
 
96
+ # @param code [String]
97
+ # @param options [Hash]
98
+ # @option options [String] :type
99
+ # @option options [String, NilClass] :format
100
+ # @option options [Integer, NilClass] :year
95
101
  def fetch_document(code, options)
96
102
  if registered_types.include?(options[:type])
97
103
  doc = Cli.relaton.fetch(code, options[:year]&.to_s)
98
- doc ? doc.to_xml : "No matching bibliographic entry found"
104
+ if doc
105
+ options[:format] == "bibtex" ? doc.to_bibtex : doc.to_xml
106
+ else
107
+ "No matching bibliographic entry found"
108
+ end
99
109
  end
100
110
  rescue RelatonBib::RequestError => e
101
111
  e.message
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "1.0.0".freeze
3
+ VERSION = "1.0.1".freeze
4
4
  end
5
5
  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.0.0
4
+ version: 1.0.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: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug