relaton-un 1.2.0 → 1.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
2
  SHA256:
3
- metadata.gz: 8126ad17a8daeba18d98bf60b9b058cac2a7980d2bf9dc86135753c7c6d465f4
4
- data.tar.gz: b69257fbdfb2688ccb6a093b5cfd19478c6663d7b894cad2943d493db013d3aa
3
+ metadata.gz: 4bd7b73723491abfe38ea7c1018dbb1844114f5c22160dd11af15cd6a858e899
4
+ data.tar.gz: ef0e87e1c151a3affb21b16d3257b7d5a025fbbe81354749f1b21897532b4b9c
5
5
  SHA512:
6
- metadata.gz: 23647bafcdd4658c5b28fb522856428821814d477e47fbbc27367d5817a9d56048a8716cfd6312b4d81aa245a73409e3d831024f74cb667f73fa7b4489f2f9cb
7
- data.tar.gz: 8ead46ec5d80a0a751dc4c39da26a07d2371358505f6eea8b442d4448459a225787e10d7af807e13283296dfd162d8353972dcbe1ec5821ef94116b9a383366f
6
+ metadata.gz: 8347b35ddab7041cf6c7478457731d9e76ae8e84acfb9bbe9d10e17fcec7cbe71aeb3f7ef2e35b979ceb544066c7c7a2ea302dde95796a092f1115391b97587c
7
+ data.tar.gz: 7b003c2eb2f8c3baa4110c01292d68d044a19359a30b297ee885080db0e979f587e59f7478733c15376de4dc4dad92a7c16d7292ef3fb92a76019808341210d9
@@ -9,6 +9,7 @@ module RelatonUn
9
9
  ret = super
10
10
  return if ret.nil?
11
11
 
12
+ ret[:submissionlanguage] = array ret[:submissionlanguage]
12
13
  session_hash_to_bib ret
13
14
  ret
14
15
  end
@@ -75,6 +75,7 @@ module RelatonUn
75
75
  distribution: fetch_distribution,
76
76
  editorialgroup: fetch_editorialgroup,
77
77
  classification: fetch_classification,
78
+ job_number: hit[:job_number],
78
79
  )
79
80
  end
80
81
  # rubocop:enable Metrics/MethodLength
@@ -88,11 +89,6 @@ module RelatonUn
88
89
 
89
90
  # @return [Array<RelatonBib::TypedTitleString>]
90
91
  def fetch_title
91
- # fs = RelatonBib::FormattedString.new(
92
- # content: hit[:title], language: "en", script: "Latn",
93
- # )
94
- # [RelatonBib::TypedTitleString.new(type: "main", title: fs)]
95
- # [{ title_main: hit[:title], language: "en", script: "Latn" }]
96
92
  RelatonBib::TypedTitleString.from_string hit[:title], "en", "Latn"
97
93
  end
98
94
 
@@ -103,7 +103,8 @@ module RelatonUn
103
103
  link: link(en),
104
104
  session: session(item),
105
105
  agenda: agenda(item),
106
- distribution: distribution(item)
106
+ distribution: distribution(item),
107
+ job_number: job_number(item),
107
108
  }
108
109
  end
109
110
 
@@ -155,6 +156,10 @@ module RelatonUn
155
156
  item.at("//label[.='Distribution:']/following-sibling::span")&.text
156
157
  end
157
158
 
159
+ def job_number(item)
160
+ item.at("//span[contains(@id, 'cfJobNumE')]")&.text
161
+ end
162
+
158
163
  # rubocop:disable Metrics/MethodLength
159
164
 
160
165
  # @param req [Net::HTTP::Get, Net::HTTP::Post]
@@ -1,5 +1,7 @@
1
1
  module RelatonUn
2
2
  class UnBibliographicItem < RelatonBib::BibliographicItem
3
+ include RelatonBib
4
+
3
5
  TYPES = %w[
4
6
  recommendation plenary addendum communication corrigendum reissue agenda
5
7
  budgetary sec-gen-notes expert-report resolution
@@ -12,18 +14,23 @@ module RelatonUn
12
14
  attr_reader :session
13
15
 
14
16
  # @return [String, NilClass]
15
- attr_reader :distribution
17
+ attr_reader :distribution, :job_number
18
+
19
+ # @return [Array<String>]
20
+ attr_reader :submissionlanguage
16
21
 
17
22
  # @param session [RelatonUn::Session, NilClass]
18
- # @param distribution [String]
23
+ # @param distribution [String, nil]
24
+ # @param job_number [String, nil]
19
25
  def initialize(**args)
20
26
  if args[:distribution] && !DISTRIBUTIONS.has_value?(args[:distribution])
21
27
  warn "[relaton-un] WARNING: invalid distribution: #{args[:distribution]}"
22
28
  end
29
+ @submissionlanguage = args.delete :submissionlanguage
23
30
  @distribution = args.delete :distribution
24
31
  @session = args.delete :session
32
+ @job_number = args.delete :job_number
25
33
  super **args
26
- # @doctype = args[:doctype]
27
34
  end
28
35
 
29
36
  # @param builder [Nokogiri::XML::Builder]
@@ -31,9 +38,13 @@ module RelatonUn
31
38
  def to_xml(builder = nil, **opts)
32
39
  super(builder, **opts) do |b|
33
40
  b.ext do
41
+ b.doctype doctype if doctype
42
+ submissionlanguage&.each { |sl| b.submissionlanguage sl }
34
43
  editorialgroup&.to_xml b
44
+ ics&.each { |i| i.to_xml b }
35
45
  b.distribution distribution if distribution
36
46
  session&.to_xml b if session
47
+ b.job_number job_number if job_number
37
48
  end
38
49
  end
39
50
  end
@@ -41,7 +52,12 @@ module RelatonUn
41
52
  # @return [Hash]
42
53
  def to_hash
43
54
  hash = super
55
+ if submissionlanguage&.any?
56
+ hash["submissionlanguage"] = single_element_array submissionlanguage
57
+ end
58
+ hash["distribution"] = distribution if distribution
44
59
  hash["session"] = session.to_hash if session
60
+ hash["job_number"] = job_number if job_number
45
61
  hash
46
62
  end
47
63
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonUn
2
- VERSION = "1.2.0".freeze
2
+ VERSION = "1.2.1".freeze
3
3
  end
@@ -13,19 +13,22 @@ module RelatonUn
13
13
  # @return [Hash]
14
14
  def item_data(item)
15
15
  data = super
16
- data[:session] = fetch_session item
17
- 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
18
23
  data
19
24
  end
20
25
 
21
26
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
22
27
 
23
- # @param item [Nokogiri::XML::Element]
28
+ # @param ext [Nokogiri::XML::Element]
24
29
  # @return [RelatonUn::Session]
25
- def fetch_session(item)
26
- session = item.at "./ext/session"
27
- return unless session
28
-
30
+ def fetch_session(ext)
31
+ session = ext.at "./session"
29
32
  RelatonUn::Session.new(
30
33
  session_number: session.at("number")&.text,
31
34
  session_date: session.at("session-date")&.text,
@@ -45,9 +48,15 @@ module RelatonUn
45
48
  eg = ext.at("./editorialgroup")
46
49
  return unless eg
47
50
 
48
- committee = eg&.xpath("committee")&.map &:text
51
+ committee = eg.xpath("committee").map &:text
49
52
  EditorialGroup.new committee
50
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
51
60
  end
52
61
  end
53
62
  end
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.2.0
4
+ version: 1.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: 2020-06-26 00:00:00.000000000 Z
11
+ date: 2020-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase