relaton-cli 0.8.0 → 0.8.5

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: 7f3f1068167e41ee92061daddb839f00405fb515e7ded6018beb56677e6b8062
4
- data.tar.gz: ab93c3caccc0153751af71ee0856bb3d440baa7e844123cca2445d475f6a7f02
3
+ metadata.gz: e0530904a05044b494f2201804192f271cb2e74a08de8896119ae52867fee775
4
+ data.tar.gz: '08817d6f72628b6503d5536f236be59c47266136767e70ed0522ef3168dd916b'
5
5
  SHA512:
6
- metadata.gz: c862ab2b9cc8015c94020924aab802ad376502e41a429e9d15af9b45bbd4d953a108250f0422e8b46893351d97e9dcceb3565d7a70c7f26835f0ed2169d70cec
7
- data.tar.gz: 468582587449b34a76042812672f8f339c4970082a9b786a1f6ee6736edd53347f6ada1c090220e34a76a06044b20239b5cde47ff6ec35c6a44b329bc42b8a10
6
+ metadata.gz: 84edf40ecd9cf391548640708f9c21d32628ad8c409054b30c749f0fd266ebd6d30ee707d7fd007d7516bbf2eec156982e73b898a0db531cedd5f85848f982ae
7
+ data.tar.gz: d20fd413254c6b073f659fb4cce1cc4278503b7e7ac20f99a35a69f53803a543e5e9aa488d5f603175220c8e604163a4e2072eb5e243e74dadfa9db103a9865e
@@ -46,7 +46,8 @@ module Relaton
46
46
  end
47
47
 
48
48
  def self.from_xml(source)
49
- new(Relaton::Cli.parse_xml(source))
49
+ bi = Relaton::Cli.parse_xml(source)
50
+ new(bi) if bi
50
51
  end
51
52
 
52
53
  def to_xml(opts = {})
@@ -53,9 +53,9 @@ module Relaton
53
53
  )
54
54
  end
55
55
 
56
- # def xml_content(file)
57
- # File.read(file, encoding: "utf-8")
58
- # end
56
+ def xml_content(file)
57
+ File.read(file, encoding: "utf-8")
58
+ end
59
59
 
60
60
  def install_dependencies(dependencies)
61
61
  dependencies.each { |dependency| require(dependency) }
@@ -126,9 +126,11 @@ module Relaton
126
126
  bib.root.add_namespace(nil, "xmlns")
127
127
 
128
128
  bibdata = Relaton::Bibdata.from_xml(bib.root)
129
- build_bibdata_relaton(bibdata, file)
129
+ if bibdata
130
+ build_bibdata_relaton(bibdata, file)
130
131
 
131
- write_to_file(bibdata.send(output_type), outdir, build_filename(file))
132
+ write_to_file(bibdata.send(output_type), outdir, build_filename(file))
133
+ end
132
134
  end
133
135
  end
134
136
 
@@ -143,7 +145,7 @@ module Relaton
143
145
  ietf = RelatonIetf::Scrapper.fetch_rfc rfc
144
146
  doc = nokogiri_document ietf.to_xml(bibdata: true)
145
147
  end
146
- bibdata_instance(doc, xml[:file]) if doc.root.name == "bibdata"
148
+ bibdata_instance(doc, xml[:file]) if doc&.root&.name == "bibdata"
147
149
  end.compact
148
150
  end
149
151
 
@@ -183,7 +185,7 @@ module Relaton
183
185
  def bibdata_instance(document, file)
184
186
  document = clean_nokogiri_document(document)
185
187
  bibdata = Relaton::Bibdata.from_xml document.root
186
- build_bibdata_relaton(bibdata, file)
188
+ build_bibdata_relaton(bibdata, file) if bibdata
187
189
 
188
190
  bibdata
189
191
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "0.8.0".freeze
3
+ VERSION = "0.8.5".freeze
4
4
  end
5
5
  end
@@ -61,7 +61,17 @@ module Relaton::Cli
61
61
 
62
62
  # TODO: This should be recursive, but it's not
63
63
  def hash_to_liquid(hash)
64
- hash.map { |key, value| [key.to_s, empty2nil(value)] }.to_h
64
+ hash.map do |key, value|
65
+ if key == "title" && value.is_a?(Array)
66
+ title = value.detect { |t| t["type"] == "main" } || value.first
67
+ v = title ? title["content"] : nil
68
+ elsif key == "title" && value.is_a?(Hash)
69
+ v = value["content"]
70
+ else
71
+ v = value
72
+ end
73
+ [key.to_s, empty2nil(v)]
74
+ end.to_h
65
75
  end
66
76
 
67
77
  def empty2nil(value)
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: 0.8.0
4
+ version: 0.8.5
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-02-26 00:00:00.000000000 Z
11
+ date: 2020-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake