relaton-un 1.0.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module RelatonUn
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  end
@@ -1,48 +1,43 @@
1
1
  module RelatonUn
2
- class XMLParser < RelatonIsoBib::XMLParser
2
+ class XMLParser < RelatonBib::XMLParser
3
3
  class << self
4
- # @param xml [String]
5
- # @return [RelatonUn::UnBibliographicItem, NilClass]
6
- def from_xml(xml)
7
- doc = Nokogiri::XML xml
8
- doc.remove_namespaces!
9
- item = doc.at("/bibitem|/bibdata")
10
- if item
11
- UnBibliographicItem.new(item_data(item))
12
- else
13
- warn "[relaton-un] WARNING: can't find bibitem or bibdata element in"\
14
- " the XML"
15
- end
16
- end
17
-
18
4
  private
19
5
 
6
+ # @param item_hash [Hash]
7
+ # @return [RelatonBib::BibliographicItem]
8
+ def bib_item(item_hash)
9
+ UnBibliographicItem.new item_hash
10
+ end
11
+
20
12
  # @param item [Nokogiri::XML::Element]
21
13
  # @return [Hash]
22
14
  def item_data(item)
23
15
  data = super
24
- data[:session] = fetch_session item
25
- data[:distribution] = item.at("distribution")&.text
16
+ ext = item.at "./ext"
17
+ return data unless ext
18
+
19
+ data[:submissionlanguage] = fetch_submissionlanguage ext
20
+ data[:session] = fetch_session ext
21
+ data[:distribution] = ext.at("distribution")&.text
22
+ data[:job_number] = ext.at("job_number")&.text
26
23
  data
27
24
  end
28
25
 
29
26
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
30
27
 
31
- # @param item [Nokogiri::XML::Element]
28
+ # @param ext [Nokogiri::XML::Element]
32
29
  # @return [RelatonUn::Session]
33
- def fetch_session(item)
34
- session = item.at "./ext/session"
35
- return unless session
36
-
30
+ def fetch_session(ext) # rubocop:disable Metrics/CyclomaticComplexity
31
+ session = ext.at "./session"
37
32
  RelatonUn::Session.new(
38
33
  session_number: session.at("number")&.text,
39
34
  session_date: session.at("session-date")&.text,
40
35
  item_number: session.xpath("item-number").map(&:text),
41
36
  item_name: session.xpath("item-name").map(&:text),
42
37
  subitem_name: session.xpath("subitem-name").map(&:text),
43
- collaboration: session.at("collaboration")&.text,
38
+ collaborator: session.at("collaborator")&.text,
44
39
  agenda_id: session.at("agenda-id")&.text,
45
- item_footnote: session.at("item-footnote")&.text,
40
+ item_footnote: session.at("item-footnote")&.text
46
41
  )
47
42
  end
48
43
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -53,9 +48,15 @@ module RelatonUn
53
48
  eg = ext.at("./editorialgroup")
54
49
  return unless eg
55
50
 
56
- committee = eg&.xpath("committee")&.map &:text
51
+ committee = eg.xpath("committee").map &:text
57
52
  EditorialGroup.new committee
58
53
  end
54
+
55
+ # @param ext [Nokogiri::XML::Element]
56
+ # @return [Array<String>]
57
+ def fetch_submissionlanguage(ext)
58
+ ext.xpath("./submissionlanguage").map(&:text)
59
+ end
59
60
  end
60
61
  end
61
62
  end
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
 
44
44
  spec.add_dependency "faraday"
45
45
  spec.add_dependency "http-cookie"
46
- spec.add_dependency "relaton-iso-bib", ">= 1.0.1"
46
+ spec.add_dependency "relaton-bib", "~> 1.4.0"
47
47
  spec.add_dependency "unf_ext", ">= 0.0.7.7"
48
48
  end
49
49
  # rubocop:enable Metrics/BlockLength
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -151,19 +151,19 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: relaton-iso-bib
154
+ name: relaton-bib
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.0.1
159
+ version: 1.4.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: 1.0.1
166
+ version: 1.4.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: unf_ext
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +223,7 @@ licenses:
223
223
  metadata:
224
224
  homepage_uri: https://github.com/relaton/relaton-un
225
225
  source_code_uri: https://github.com/relaton/relaton-un
226
- post_install_message:
226
+ post_install_message:
227
227
  rdoc_options: []
228
228
  require_paths:
229
229
  - lib
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubygems_version: 3.0.6
242
- signing_key:
242
+ signing_key:
243
243
  specification_version: 4
244
244
  summary: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
245
245
  model'