relaton-cli 0.7.0 → 0.8.4

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: f64d80902cdeac95d97fd9b0df66ef413903c2395fc5dc18b5654aca8c83e5c0
4
- data.tar.gz: ae59ddb87405cc169ba7d315e31ce1f712517704cdba5cf8ec3f40ad0289466e
3
+ metadata.gz: 3f0916d1d6fef45c2de0f3d48059ac096c8999968f07932501958b8a1a19fd69
4
+ data.tar.gz: 48f4cd861c5b449a15a8752237ccef556a2213e7c7e5676c97eb53350668d53a
5
5
  SHA512:
6
- metadata.gz: 10f93960db82d97c4a6c306d22d6ce08ff18d2ce5a2d9c1e64c6a2e3b64d46a9f1861f5ab8f57ed1c48d415c6c02db6fc31acb78dfc58685d0d4b36ba09bc14c
7
- data.tar.gz: c7e85111953a782ed2baa51089a1020a6e30d085a9ee512f488d488e7a1752717022403428cd3d88d4f48c1e2b1cd71df64f6a9337f158673583819a815f3370
6
+ metadata.gz: b0bdbb4bcf160f3360e7c336fe68ec02d30f5ed23caef2ad94f1cfc08725b61b6774eaba5cd7f10fb3630c4cbe1b99bcec1268ac603d4b38106003652d72c351
7
+ data.tar.gz: 1ae1189d0e97dac1d1d46c567b16f45dd0a3493fc15437812840a1ea3fac06cf163f504431a421f21760f1dd19bce9f1fc9c857504c5e1d21985ce39447ac607
@@ -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.7.0".freeze
3
+ VERSION = "0.8.4".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)
data/relaton-cli.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "debase"
35
35
  spec.add_development_dependency "simplecov"
36
36
 
37
- spec.add_runtime_dependency "relaton", "~> 0.9.0"
37
+ spec.add_runtime_dependency "relaton", "~> 0.10.0"
38
38
  spec.add_runtime_dependency "thor"
39
39
  spec.add_runtime_dependency "liquid"
40
40
  # spec.add_runtime_dependency 'byebug'
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.7.0
4
+ version: 0.8.4
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-17 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.9.0
159
+ version: 0.10.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.9.0
166
+ version: 0.10.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: thor
169
169
  requirement: !ruby/object:Gem::Requirement