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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8049656d1afb46e4ba336f812b0eb6261525e64b6d127b313c03a8c5ce4c72e
4
- data.tar.gz: bcfa7ebc31360fd27f2ccb2f21f1e864fc283433bdba045ff6c8e7393aabc25b
3
+ metadata.gz: 189c177f77c4ebd844d4df2dbe9deb987d90443e3e91ff50d8ebf1a7ce8d3685
4
+ data.tar.gz: 73a886c43a4b0262a6f96725143a5714dae88440715122a36360e343d753ea56
5
5
  SHA512:
6
- metadata.gz: 8a49edaeb34c75d64fcdb63ac642a3882086c0d994f169a0691f9f86fe27b7a1be4680f2295bbf80301b6089d76154bdfa734364ecbb2909ee0d630dd4cc616a
7
- data.tar.gz: 2ead71208ec783d66af83bfcc89901d3d9da70e441d9464cb6f5f6b57838c5e5cde8bec940d4856804abe0260e60c6e30cfda9c7becec50c60a0b31fc66edf63
6
+ metadata.gz: 7d7e76cfa44de6d91dc4ce1f631c68b845fa152de4ecbfa76a5deebb59e706784c0f0a5c1dea302336e153d751217e612f42c324498336390ce67891f4f773fa
7
+ data.tar.gz: ea44768cba9f5a88b46f03c588237d0de5fe91d0fb4952b5761236fafcabe1ec5992b921ecbd87052e3082e0f45c24ee074409825c0f32f934055ffac7eb2b93
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  .vscode/
14
14
  .byebug_history
15
15
  Gemfile.lock
16
+ .DS_Store
@@ -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
@@ -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 (refs = doc.xpath("//rfc//reference")).any?
144
+ if (rfc = doc.at("/rfc"))
146
145
  require "relaton_ietf/scrapper"
147
- mem + refs.map do |rfc|
148
- ietf = RelatonIetf::Scrapper.fetch_rfc rfc
149
- d = nokogiri_document ietf.to_xml(bibdata: true)
150
- bibdata_instance(d, xml[:file])
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.compact
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, ouputdir, content)
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.inject(string.downcase) { |res, char| res.gsub(char, "-") }
270
+ bad_chars.reduce(string.downcase) { |res, char| res.gsub(char, "-") }
274
271
  end
275
272
  end
276
273
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Cli
3
- VERSION = "1.1.1".freeze
3
+ VERSION = "1.1.2".freeze
4
4
  end
5
5
  end
@@ -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
 
@@ -54,7 +54,7 @@
54
54
 
55
55
  <div class="doc-bib">
56
56
  <div class="doc-bib-relaton">
57
- <a href="{{ document.relaton }}">Relaton XML</a>
57
+ <a href="{{ document.rxl }}">Relaton XML</a>
58
58
  </div>
59
59
  </div>
60
60
 
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.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-10 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug