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 +5 -5
- data/.gitignore +2 -0
- data/lib/relaton/bibdata.rb +1 -0
- data/lib/relaton/cli/command.rb +2 -0
- data/lib/relaton/cli/relaton_file.rb +22 -4
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/xml_document.rb +6 -1
- data/relaton-cli.gemspec +2 -0
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d4d41d778eecd0614bc7d9f086db2362d594725
|
4
|
+
data.tar.gz: 5a66a9da159d1c903c35764727e0755e52511919
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 429b613fd45f18bf24a5af73b01c4091dcfbb93e820af393af1b58c338e99a69f34a22adc6ac2a282e250ccf54827eb2fdb02ba5b759be34cc7a2c18fc4f2f21
|
7
|
+
data.tar.gz: affff06b90bfcd54bc299aedacf129cbf1e12181146fedda6300d6890b12fc7b05ee31492a8b68475da8de09410d55e43b413a8e0c0b46a82469b33bd834a447
|
data/.gitignore
CHANGED
data/lib/relaton/bibdata.rb
CHANGED
data/lib/relaton/cli/command.rb
CHANGED
@@ -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")
|
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) }
|
data/lib/relaton/cli/version.rb
CHANGED
data/lib/relaton/xml_document.rb
CHANGED
@@ -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
|
-
|
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.
|
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-
|
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.
|
245
|
+
rubygems_version: 2.6.12
|
218
246
|
signing_key:
|
219
247
|
specification_version: 4
|
220
248
|
summary: Relaton Command-line Interface
|