relaton-cli 0.2.0 → 0.2.1

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
- SHA256:
3
- metadata.gz: c65fdfca202de14e05173d9c20a7fac23b11f33a45bb496adcfd5a67eb51c5d4
4
- data.tar.gz: 790a6d8d9af1e2b72d59a430db1e7a37ab3f3cf67b6083abbac1b87713f30104
2
+ SHA1:
3
+ metadata.gz: 8d4d41d778eecd0614bc7d9f086db2362d594725
4
+ data.tar.gz: 5a66a9da159d1c903c35764727e0755e52511919
5
5
  SHA512:
6
- metadata.gz: f59e8cc8d04a9251a4e2dda174d0cbcbd371439d2d292f3ef7e83ba0ba007d4cd2c9294d381fe7b81b7124a5f39cb1d0a1f492db0b230c962c3b2c8753be8bdc
7
- data.tar.gz: 2c8c6a3515dd92143a4b824aeaeb4bf7aac3f48ee95ec94b5916966bb3d0f08c8f8c4f9ccc21b8d426c467a77aed9aab97efceeb998815b24d1231b4b2d9dd6c
6
+ metadata.gz: 429b613fd45f18bf24a5af73b01c4091dcfbb93e820af393af1b58c338e99a69f34a22adc6ac2a282e250ccf54827eb2fdb02ba5b759be34cc7a2c18fc4f2f21
7
+ data.tar.gz: affff06b90bfcd54bc299aedacf129cbf1e12181146fedda6300d6890b12fc7b05ee31492a8b68475da8de09410d55e43b413a8e0c0b46a82469b33bd834a447
data/.gitignore CHANGED
@@ -11,3 +11,5 @@
11
11
  /.rubocop-https*
12
12
 
13
13
  .rspec_status
14
+ .vscode/
15
+ .byebug_history
@@ -14,6 +14,7 @@ module Relaton
14
14
  html
15
15
  uri
16
16
  rxl
17
+ txt
17
18
  revdate
18
19
  abstract
19
20
  technical_committee
@@ -85,6 +85,8 @@ module Relaton
85
85
  doc = Cli.relaton.fetch(code, options[:year])
86
86
  doc ? doc.to_xml : "No matching bibliographic entry found"
87
87
  end
88
+ rescue RelatonBib::RequestError => e
89
+ e.message
88
90
  end
89
91
 
90
92
  def supported_type_message
@@ -112,9 +112,16 @@ module Relaton
112
112
  xml = nokogiri_document(nil, file)
113
113
  xml.remove_namespaces!
114
114
 
115
- bib = xml.at("//bibdata") || next
115
+ if (bib = xml.at("//bibdata"))
116
+ bib = nokogiri_document(bib.to_xml)
117
+ elsif (rfc = xml.at("//rfc"))
118
+ require "relaton_ietf/scrapper"
119
+ ietf = RelatonIetf::Scrapper.bib_item rfc, "rfc"
120
+ bib = nokogiri_document ietf.to_xml(bibdata: true)
121
+ else
122
+ next
123
+ end
116
124
 
117
- bib = nokogiri_document(bib.to_xml)
118
125
  bib.remove_namespaces!
119
126
  bib.root.add_namespace(nil, "xmlns")
120
127
 
@@ -126,10 +133,15 @@ module Relaton
126
133
  end
127
134
 
128
135
  def concatenate_files
129
- xml_files = [convert_rxl_to_xml, convert_yamls_to_xml]
136
+ xml_files = [convert_rxl_to_xml, convert_yamls_to_xml, convert_xml_to_xml]
130
137
 
131
138
  xml_files.flatten.map do |xml|
132
139
  doc = nokogiri_document(xml[:content])
140
+ if (rfc = doc.at("//rfc"))
141
+ require "relaton_ietf/scrapper"
142
+ ietf = RelatonIetf::Scrapper.bib_item rfc, "rfc"
143
+ doc = nokogiri_document ietf.to_xml(bibdata: true)
144
+ end
133
145
  bibdata_instance(doc, xml[:file]) if doc.root.name == "bibdata"
134
146
  end.compact
135
147
  end
@@ -165,7 +177,7 @@ module Relaton
165
177
  end
166
178
 
167
179
  def build_bibdata_relaton(bibdata, file)
168
- ["xml", "pdf", "doc", "html", "rxl"].each do |type|
180
+ ["xml", "pdf", "doc", "html", "rxl", "txt"].each do |type|
169
181
  file = Pathname.new(file).sub_ext(".#{type}")
170
182
  bibdata.send("#{type}=", file) if File.file?(file)
171
183
  end
@@ -194,6 +206,12 @@ module Relaton
194
206
  end
195
207
  end
196
208
 
209
+ def convert_xml_to_xml
210
+ select_files_with("{xml}").map do |file|
211
+ { file: file, content: File.read(file, encoding: "utf-8") }
212
+ end
213
+ end
214
+
197
215
  def select_files_with(extension)
198
216
  files = File.join(source, "**", "*.#{extension}")
199
217
  Dir[files].reject { |file| File.directory?(file) }
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "0.2.0".freeze
3
+ VERSION = "0.2.1".freeze
4
4
  end
5
5
  end
@@ -77,7 +77,12 @@ module Relaton
77
77
  value = find_text("./on", revdate) || find_text("./form", revdate)
78
78
 
79
79
  if revdate && value
80
- { datetype: revdate["type"], revdate: Date.parse(value.strip).to_s }
80
+ date = if value.size > 7
81
+ Date.parse(value.strip)
82
+ else
83
+ Date.strptime(value.strip, "%Y-%m")
84
+ end
85
+ { datetype: revdate["type"], revdate: date.to_s }
81
86
  end
82
87
  rescue
83
88
  warn "[relaton] parsing published date '#{revdate.text}' failed."
data/relaton-cli.gemspec CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
31
31
  spec.add_development_dependency "rspec-core", "~> 3.4"
32
32
  spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "ruby-debug-ide"
34
+ spec.add_development_dependency "debase"
33
35
 
34
36
  spec.add_runtime_dependency "relaton", "~> 0.4"
35
37
  spec.add_runtime_dependency "thor"
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.2.0
4
+ version: 0.2.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: 2019-06-15 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: ruby-debug-ide
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: debase
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'
111
139
  - !ruby/object:Gem::Dependency
112
140
  name: relaton
113
141
  requirement: !ruby/object:Gem::Requirement
@@ -214,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
242
  version: '0'
215
243
  requirements: []
216
244
  rubyforge_project:
217
- rubygems_version: 2.7.6
245
+ rubygems_version: 2.6.12
218
246
  signing_key:
219
247
  specification_version: 4
220
248
  summary: Relaton Command-line Interface