relaton-cli 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/relaton/bibcollection.rb +1 -1
- data/lib/relaton/bibdata.rb +5 -17
- data/lib/relaton/cli/relaton_file.rb +8 -11
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_convertor.rb +0 -10
- data/templates/_document.liquid +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 189c177f77c4ebd844d4df2dbe9deb987d90443e3e91ff50d8ebf1a7ce8d3685
|
4
|
+
data.tar.gz: 73a886c43a4b0262a6f96725143a5714dae88440715122a36360e343d753ea56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d7e76cfa44de6d91dc4ce1f631c68b845fa152de4ecbfa76a5deebb59e706784c0f0a5c1dea302336e153d751217e612f42c324498336390ce67891f4f773fa
|
7
|
+
data.tar.gz: ea44768cba9f5a88b46f03c588237d0de5fe91d0fb4952b5761236fafcabe1ec5992b921ecbd87052e3082e0f45c24ee074409825c0f32f934055ffac7eb2b93
|
data/.gitignore
CHANGED
@@ -41,7 +41,7 @@ module Relaton
|
|
41
41
|
)
|
42
42
|
|
43
43
|
items = find_xpath("./relaton-collection/relation", source)&.map do |item|
|
44
|
-
bibdata = find("./bibdata", item)
|
44
|
+
bibdata = find("./bibdata|./bibitem", item)
|
45
45
|
klass = bibdata ? Bibdata : Bibcollection
|
46
46
|
klass.from_xml(bibdata || item)
|
47
47
|
end
|
data/lib/relaton/bibdata.rb
CHANGED
@@ -10,18 +10,6 @@ module Relaton
|
|
10
10
|
@bibitem = bibitem
|
11
11
|
end
|
12
12
|
|
13
|
-
# def method_missing(method, *args)
|
14
|
-
# %r{(?<m>\w+)=$} =~ method
|
15
|
-
# return unless m && %w[xml pdf doc html rxl txt].include?(m)
|
16
|
-
|
17
|
-
# uri = @bibitem.link.detect { |u| u.type == m }
|
18
|
-
# if uri
|
19
|
-
# uri.content = args[0]
|
20
|
-
# else
|
21
|
-
# @bibitem.link << RelatonBib::TypedUri.new(type: m, content: args[0])
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
|
25
13
|
def docidentifier
|
26
14
|
@bibitem.docidentifier.first&.id
|
27
15
|
end
|
@@ -57,11 +45,6 @@ module Relaton
|
|
57
45
|
opts.select { |k, _v| k.is_a? Symbol },
|
58
46
|
)
|
59
47
|
@bibitem.to_xml nil, **options
|
60
|
-
|
61
|
-
# #datetype = stage&.casecmp("published") == 0 ? "published" : "circulated"
|
62
|
-
|
63
|
-
# ret = ref ? "<bibitem id= '#{ref}' type='#{doctype}'>\n" : "<bibdata type='#{doctype}'>\n"
|
64
|
-
# ret += "<fetched>#{Date.today.to_s}</fetched>\n"
|
65
48
|
end
|
66
49
|
|
67
50
|
def to_h
|
@@ -76,6 +59,9 @@ module Relaton
|
|
76
59
|
to_h.to_yaml
|
77
60
|
end
|
78
61
|
|
62
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
63
|
+
# rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity, Style/MissingRespondToMissing
|
64
|
+
|
79
65
|
def method_missing(meth, *args)
|
80
66
|
if @bibitem.respond_to?(meth)
|
81
67
|
@bibitem.send meth, *args
|
@@ -98,5 +84,7 @@ module Relaton
|
|
98
84
|
super
|
99
85
|
end
|
100
86
|
end
|
87
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
88
|
+
# rubocop:enable Metrics/MethodLength, Metrics/PerceivedComplexity, Style/MissingRespondToMissing
|
101
89
|
end
|
102
90
|
end
|
@@ -118,7 +118,6 @@ module Relaton
|
|
118
118
|
bib = nokogiri_document(bib.to_xml)
|
119
119
|
elsif (rfc = xml.at("//rfc"))
|
120
120
|
require "relaton_ietf/scrapper"
|
121
|
-
#ietf = RelatonIetf::Scrapper.bib_item rfc, "rfc"
|
122
121
|
ietf = RelatonIetf::Scrapper.fetch_rfc rfc
|
123
122
|
bib = nokogiri_document ietf.to_xml(bibdata: true)
|
124
123
|
else
|
@@ -142,18 +141,16 @@ module Relaton
|
|
142
141
|
|
143
142
|
xml_files.flatten.reduce([]) do |mem, xml|
|
144
143
|
doc = nokogiri_document(xml[:content])
|
145
|
-
if (
|
144
|
+
if (rfc = doc.at("/rfc"))
|
146
145
|
require "relaton_ietf/scrapper"
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
152
|
-
elsif doc&.root&.name == "bibdata"
|
146
|
+
ietf = RelatonIetf::Scrapper.fetch_rfc rfc
|
147
|
+
d = nokogiri_document ietf.to_xml(bibdata: true)
|
148
|
+
mem << bibdata_instance(d, xml[:file])
|
149
|
+
elsif %w[bibitem bibdata].include? doc&.root&.name
|
153
150
|
mem << bibdata_instance(doc, xml[:file])
|
154
151
|
else mem
|
155
152
|
end
|
156
|
-
end.
|
153
|
+
end.uniq &:id
|
157
154
|
end
|
158
155
|
|
159
156
|
def concatenate_and_write_to_files
|
@@ -170,7 +167,7 @@ module Relaton
|
|
170
167
|
end
|
171
168
|
end
|
172
169
|
|
173
|
-
def find_available_bibrxl_file(name,
|
170
|
+
def find_available_bibrxl_file(name, _ouputdir, content)
|
174
171
|
if options[:extension] == "yaml" || options[:extension] == "yml"
|
175
172
|
bib_rxl = Pathname.new([outdir, name].join("/")).sub_ext(".rxl")
|
176
173
|
content.bib_rxl = bib_rxl.to_s if File.file?(bib_rxl)
|
@@ -270,7 +267,7 @@ module Relaton
|
|
270
267
|
|
271
268
|
def replace_bad_characters(string)
|
272
269
|
bad_chars = ["/", "\\", "?", "%", "*", ":", "|", '"', "<", ">", ".", " "]
|
273
|
-
bad_chars.
|
270
|
+
bad_chars.reduce(string.downcase) { |res, char| res.gsub(char, "-") }
|
274
271
|
end
|
275
272
|
end
|
276
273
|
end
|
data/lib/relaton/cli/version.rb
CHANGED
@@ -34,18 +34,8 @@ module Relaton
|
|
34
34
|
def convert_content(content)
|
35
35
|
if %w[bibitem bibdata].include? content.root.name
|
36
36
|
Bibdata.from_xml(content)
|
37
|
-
# Relaton::Cli.parse_xml(content).to_hash
|
38
37
|
else
|
39
38
|
Bibcollection.from_xml(content)
|
40
|
-
# title = content.at("relaton-collection/title").text
|
41
|
-
# author = content.at("relaton-collection/contributor/organization/name").text
|
42
|
-
# collection = { "root" => { "title" => title, "author" => author } }
|
43
|
-
|
44
|
-
# collection["root"]["items"] = content.xpath("//bibdata").map do |bib|
|
45
|
-
# Relaton::Cli.parse_xml(bib).to_hash
|
46
|
-
# end
|
47
|
-
|
48
|
-
# collection
|
49
39
|
end
|
50
40
|
end
|
51
41
|
|
data/templates/_document.liquid
CHANGED
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.1.
|
4
|
+
version: 1.1.2
|
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-06-
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|