relaton-un 1.0.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -0
- data/.rubocop.yml +2 -2
- data/README.adoc +23 -10
- data/grammars/biblio.rng +36 -6
- data/grammars/isodoc.rng +574 -22
- data/grammars/un.rng +111 -0
- data/lib/relaton_un.rb +1 -1
- data/lib/relaton_un/editorialgroup.rb +13 -0
- data/lib/relaton_un/hash_converter.rb +2 -1
- data/lib/relaton_un/hit.rb +4 -7
- data/lib/relaton_un/hit_collection.rb +30 -15
- data/lib/relaton_un/processor.rb +1 -1
- data/lib/relaton_un/session.rb +32 -10
- data/lib/relaton_un/un_bibliographic_item.rb +42 -7
- data/lib/relaton_un/version.rb +1 -1
- data/lib/relaton_un/xml_parser.rb +26 -25
- data/relaton_un.gemspec +1 -1
- metadata +10 -10
data/grammars/un.rng
CHANGED
@@ -119,6 +119,9 @@
|
|
119
119
|
<optional>
|
120
120
|
<ref name="session"/>
|
121
121
|
</optional>
|
122
|
+
<optional>
|
123
|
+
<ref name="job_number"/>
|
124
|
+
</optional>
|
122
125
|
</define>
|
123
126
|
<define name="preface">
|
124
127
|
<element name="preface">
|
@@ -138,6 +141,109 @@
|
|
138
141
|
<ref name="Basic-Section"/>
|
139
142
|
</element>
|
140
143
|
</define>
|
144
|
+
<define name="Clause-Section">
|
145
|
+
<optional>
|
146
|
+
<attribute name="id">
|
147
|
+
<data type="ID"/>
|
148
|
+
</attribute>
|
149
|
+
</optional>
|
150
|
+
<optional>
|
151
|
+
<attribute name="language"/>
|
152
|
+
</optional>
|
153
|
+
<optional>
|
154
|
+
<attribute name="script"/>
|
155
|
+
</optional>
|
156
|
+
<optional>
|
157
|
+
<attribute name="inline-header">
|
158
|
+
<data type="boolean"/>
|
159
|
+
</attribute>
|
160
|
+
</optional>
|
161
|
+
<optional>
|
162
|
+
<attribute name="obligation">
|
163
|
+
<choice>
|
164
|
+
<value>normative</value>
|
165
|
+
<value>informative</value>
|
166
|
+
</choice>
|
167
|
+
</attribute>
|
168
|
+
</optional>
|
169
|
+
<optional>
|
170
|
+
<attribute name="unnumbered">
|
171
|
+
<data type="boolean"/>
|
172
|
+
</attribute>
|
173
|
+
</optional>
|
174
|
+
<optional>
|
175
|
+
<ref name="section-title"/>
|
176
|
+
</optional>
|
177
|
+
<group>
|
178
|
+
<group>
|
179
|
+
<zeroOrMore>
|
180
|
+
<ref name="BasicBlock"/>
|
181
|
+
</zeroOrMore>
|
182
|
+
<zeroOrMore>
|
183
|
+
<ref name="note"/>
|
184
|
+
</zeroOrMore>
|
185
|
+
</group>
|
186
|
+
<zeroOrMore>
|
187
|
+
<choice>
|
188
|
+
<ref name="clause-subsection"/>
|
189
|
+
<ref name="terms"/>
|
190
|
+
<ref name="definitions"/>
|
191
|
+
</choice>
|
192
|
+
</zeroOrMore>
|
193
|
+
</group>
|
194
|
+
</define>
|
195
|
+
<define name="Annex-Section">
|
196
|
+
<optional>
|
197
|
+
<attribute name="id">
|
198
|
+
<data type="ID"/>
|
199
|
+
</attribute>
|
200
|
+
</optional>
|
201
|
+
<optional>
|
202
|
+
<attribute name="language"/>
|
203
|
+
</optional>
|
204
|
+
<optional>
|
205
|
+
<attribute name="script"/>
|
206
|
+
</optional>
|
207
|
+
<optional>
|
208
|
+
<attribute name="inline-header">
|
209
|
+
<data type="boolean"/>
|
210
|
+
</attribute>
|
211
|
+
</optional>
|
212
|
+
<optional>
|
213
|
+
<attribute name="obligation">
|
214
|
+
<choice>
|
215
|
+
<value>normative</value>
|
216
|
+
<value>informative</value>
|
217
|
+
</choice>
|
218
|
+
</attribute>
|
219
|
+
</optional>
|
220
|
+
<optional>
|
221
|
+
<attribute name="unnumbered">
|
222
|
+
<data type="boolean"/>
|
223
|
+
</attribute>
|
224
|
+
</optional>
|
225
|
+
<optional>
|
226
|
+
<ref name="section-title"/>
|
227
|
+
</optional>
|
228
|
+
<group>
|
229
|
+
<group>
|
230
|
+
<zeroOrMore>
|
231
|
+
<ref name="BasicBlock"/>
|
232
|
+
</zeroOrMore>
|
233
|
+
<zeroOrMore>
|
234
|
+
<ref name="note"/>
|
235
|
+
</zeroOrMore>
|
236
|
+
</group>
|
237
|
+
<zeroOrMore>
|
238
|
+
<choice>
|
239
|
+
<ref name="annex-subsection"/>
|
240
|
+
<ref name="terms"/>
|
241
|
+
<ref name="definitions"/>
|
242
|
+
<ref name="references"/>
|
243
|
+
</choice>
|
244
|
+
</zeroOrMore>
|
245
|
+
</group>
|
246
|
+
</define>
|
141
247
|
</include>
|
142
248
|
<define name="session">
|
143
249
|
<element name="session">
|
@@ -227,6 +333,11 @@
|
|
227
333
|
</choice>
|
228
334
|
</element>
|
229
335
|
</define>
|
336
|
+
<define name="job_number">
|
337
|
+
<element name="job_number">
|
338
|
+
<text/>
|
339
|
+
</element>
|
340
|
+
</define>
|
230
341
|
<define name="un-standard">
|
231
342
|
<element name="un-standard">
|
232
343
|
<ref name="bibdata"/>
|
data/lib/relaton_un.rb
CHANGED
@@ -10,6 +10,11 @@ module RelatonUn
|
|
10
10
|
@committee = committee
|
11
11
|
end
|
12
12
|
|
13
|
+
# @return [true]
|
14
|
+
def presence?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
13
18
|
# @param builder [Nokogiri::XML::Builder]
|
14
19
|
def to_xml(builder)
|
15
20
|
builder.editorialgroup do |b|
|
@@ -21,5 +26,13 @@ module RelatonUn
|
|
21
26
|
def to_hash
|
22
27
|
single_element_array(committee.map { |c| { "committee" => c } })
|
23
28
|
end
|
29
|
+
|
30
|
+
# @param prefix [String]
|
31
|
+
# @return [String]
|
32
|
+
def to_asciibib(prefix)
|
33
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
34
|
+
pref += "editorialgroup"
|
35
|
+
committee.map { |c| "#{pref}.committee:: #{c}\n" }.join
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RelatonUn
|
2
|
-
class HashConverter <
|
2
|
+
class HashConverter < RelatonBib::HashConverter
|
3
3
|
class << self
|
4
4
|
# @override RelatonIsoBib::HashConverter.hash_to_bib
|
5
5
|
# @param args [Hash]
|
@@ -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
|
data/lib/relaton_un/hit.rb
CHANGED
@@ -59,7 +59,7 @@ module RelatonUn
|
|
59
59
|
# rubocop:disable Metrics/MethodLength
|
60
60
|
|
61
61
|
# @return [RelatonUn::UnBibliographicItem]
|
62
|
-
def un_bib_item
|
62
|
+
def un_bib_item # rubocop:disable Metrics/AbcSize
|
63
63
|
UnBibliographicItem.new(
|
64
64
|
type: "standard",
|
65
65
|
fetched: Date.today.to_s,
|
@@ -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,7 @@ module RelatonUn
|
|
88
89
|
|
89
90
|
# @return [Array<RelatonBib::TypedTitleString>]
|
90
91
|
def fetch_title
|
91
|
-
|
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" }]
|
92
|
+
RelatonBib::TypedTitleString.from_string hit[:title], "en", "Latn"
|
96
93
|
end
|
97
94
|
|
98
95
|
# @return [Array<RelatonBib::BibliographicDate>]
|
@@ -134,7 +131,7 @@ module RelatonUn
|
|
134
131
|
def fetch_editorialgroup
|
135
132
|
tc = hit[:ref].match(/^[\S]+/).to_s.split(/\/|-/).reduce([]) do |m, v|
|
136
133
|
if BODY[v] then m << BODY[v]
|
137
|
-
elsif v
|
134
|
+
elsif v.match? /(AC|C|CN|CONF|GC|SC|Sub|WG).\d+|PC/ then m << v
|
138
135
|
else m
|
139
136
|
end
|
140
137
|
end.uniq
|
@@ -6,18 +6,23 @@ require "http-cookie"
|
|
6
6
|
module RelatonUn
|
7
7
|
# Page of hit collection.
|
8
8
|
class HitCollection < RelatonBib::HitCollection
|
9
|
-
AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X
|
10
|
-
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
9
|
+
AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) "\
|
10
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
|
11
11
|
DOMAIN = "https://documents.un.org"
|
12
|
-
BOUNDARY = "----
|
12
|
+
BOUNDARY = "----WebKitFormBoundaryVarT9Z7AFUzw2lma"
|
13
13
|
|
14
14
|
# @param text [String] reference to search
|
15
15
|
def initialize(text)
|
16
16
|
super
|
17
17
|
@uri = URI.parse DOMAIN
|
18
18
|
@jar = HTTP::CookieJar.new
|
19
|
-
@http = Net::HTTP.new @uri.host, @uri.port
|
19
|
+
@http = Net::HTTP.new @uri.host, @uri.port # , "localhost", "8000"
|
20
20
|
@http.use_ssl = true
|
21
|
+
# @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
22
|
+
# @http.cert_store = OpenSSL::X509::Store.new
|
23
|
+
# ca_file = "/Users/andrej/Library/Preferences/httptoolkit/ca.pem"
|
24
|
+
# @http.cert_store.set_default_paths
|
25
|
+
# @http.cert_store.add_file ca_file
|
21
26
|
@http.read_timeout = 120
|
22
27
|
if (form_resp = get_page)
|
23
28
|
doc = Nokogiri::HTML page_resp(form_resp, text).body
|
@@ -48,19 +53,21 @@ module RelatonUn
|
|
48
53
|
# @param form [Nokogiri::HTML::Document]
|
49
54
|
# @param text [String]
|
50
55
|
# @return [Array<String>]
|
51
|
-
def form_data(form, text)
|
56
|
+
def form_data(form, text) # rubocop:disable Metrics/CyclomaticComplexity
|
52
57
|
fd = form.xpath(
|
53
|
-
"//input[@type!='radio']"
|
54
|
-
"//input[@type='radio'][@checked]"
|
55
|
-
"//select[@name!='view:_id1:_id2:cbLang']"
|
56
|
-
"//textarea"
|
58
|
+
"//input[@type!='radio']|"\
|
59
|
+
"//input[@type='radio'][@checked]|"\
|
60
|
+
"//select[@name!='view:_id1:_id2:cbLang']|"\
|
61
|
+
"//textarea"
|
57
62
|
).reduce([]) do |m, i|
|
58
63
|
v = case i[:name]
|
59
64
|
when "view:_id1:_id2:txtSymbol" then text
|
65
|
+
when "view:_id1:_id2:rgTrunc" then "R"
|
60
66
|
when "view:_id1:_id2:cbType" then "FP"
|
61
67
|
when "view:_id1:_id2:cbSort" then "R"
|
62
68
|
when "$$xspsubmitid" then "view:_id1:_id2:_id130"
|
63
|
-
when "$$xspsubmitscroll" then "0|
|
69
|
+
when "$$xspsubmitscroll" then "0|102"
|
70
|
+
when "view:_id1" then "view:_id1"
|
64
71
|
else i[:value]
|
65
72
|
end
|
66
73
|
m << %{--#{BOUNDARY}}
|
@@ -77,7 +84,7 @@ module RelatonUn
|
|
77
84
|
form = Nokogiri::HTML form_resp.body
|
78
85
|
req = Net::HTTP::Post.new form.at("//form")[:action]
|
79
86
|
set_headers req
|
80
|
-
req["Content-Type"] = "multipart/form-data
|
87
|
+
req["Content-Type"] = "multipart/form-data; boundary=#{BOUNDARY}"
|
81
88
|
req.body = form_data(form, text).join("\r\n")
|
82
89
|
resp = @http.request req
|
83
90
|
get_page URI.parse(resp["location"]).request_uri
|
@@ -91,7 +98,7 @@ module RelatonUn
|
|
91
98
|
|
92
99
|
# @param item [Nokogiri::XML::Element]
|
93
100
|
# @return [Hash]
|
94
|
-
def hit_data(item)
|
101
|
+
def hit_data(item) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
95
102
|
en = item.at("//span[.='ENGLISH']/../..")
|
96
103
|
{
|
97
104
|
ref: item.at("div/div/a")&.text&.sub("\u00A0", ""),
|
@@ -103,7 +110,8 @@ module RelatonUn
|
|
103
110
|
link: link(en),
|
104
111
|
session: session(item),
|
105
112
|
agenda: agenda(item),
|
106
|
-
distribution: distribution(item)
|
113
|
+
distribution: distribution(item),
|
114
|
+
job_number: job_number(item),
|
107
115
|
}
|
108
116
|
end
|
109
117
|
|
@@ -155,18 +163,25 @@ module RelatonUn
|
|
155
163
|
item.at("//label[.='Distribution:']/following-sibling::span")&.text
|
156
164
|
end
|
157
165
|
|
166
|
+
def job_number(item)
|
167
|
+
item.at("//span[contains(@id, 'cfJobNumE')]")&.text
|
168
|
+
end
|
169
|
+
|
158
170
|
# rubocop:disable Metrics/MethodLength
|
159
171
|
|
160
172
|
# @param req [Net::HTTP::Get, Net::HTTP::Post]
|
161
|
-
def set_headers(req)
|
173
|
+
def set_headers(req) # rubocop:disable Metrics/AbcSize
|
162
174
|
set_cookie req
|
163
175
|
req["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,"\
|
164
|
-
"image/webp,image/apng,*/*;q=0.8,application/signed-exchange;
|
176
|
+
"image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;"\
|
177
|
+
"v=b3;q=0.9"
|
165
178
|
req["Accept-Encoding"] = "gzip, deflate, br"
|
179
|
+
req["Accept-Language"] = "en-US;q=0.8,en;q=0.7"
|
166
180
|
req["Cache-Control"] = "max-age=0"
|
167
181
|
req["Connection"] = "keep-alive"
|
168
182
|
req["Origin"] = "https://documents.un.org"
|
169
183
|
req["Referer"] = "https://documents.un.org/prod/ods.nsf/home.xsp"
|
184
|
+
req["Sec-Fetch-Dest"] = "document"
|
170
185
|
req["Sec-Fetch-Mode"] = "navigate"
|
171
186
|
req["Sec-Fetch-Site"] = "same-origin"
|
172
187
|
req["Sec-Fetch-User"] = "?1"
|
data/lib/relaton_un/processor.rb
CHANGED
@@ -29,7 +29,7 @@ module RelatonUn
|
|
29
29
|
# @return [RelatonIsoBib::IsoBibliographicItem]
|
30
30
|
def hash_to_bib(hash)
|
31
31
|
item_hash = ::RelatonUn::HashConverter.hash_to_bib(hash)
|
32
|
-
::
|
32
|
+
::RelatonUn::UnBibliographicItem.new item_hash
|
33
33
|
end
|
34
34
|
|
35
35
|
# Returns hash of XML grammar
|
data/lib/relaton_un/session.rb
CHANGED
@@ -3,7 +3,7 @@ module RelatonUn
|
|
3
3
|
include RelatonBib
|
4
4
|
|
5
5
|
# @return [String, NilClass]
|
6
|
-
attr_reader :session_number, :
|
6
|
+
attr_reader :session_number, :collaborator, :agenda_id, :item_footnote
|
7
7
|
|
8
8
|
# @return [Date, NilClass]
|
9
9
|
attr_reader :session_date
|
@@ -16,7 +16,7 @@ module RelatonUn
|
|
16
16
|
# @param item_number [Array<String>]
|
17
17
|
# @pqrqm item_name [Array<String>]
|
18
18
|
# @pqrqm subitem_name [Array<String>]
|
19
|
-
# @param
|
19
|
+
# @param collaborator [String]
|
20
20
|
# @param agenda_id [String]
|
21
21
|
# @param item_footnote [String]
|
22
22
|
def initialize(**args)
|
@@ -25,12 +25,12 @@ module RelatonUn
|
|
25
25
|
@item_number = args.fetch(:item_number, [])
|
26
26
|
@item_name = args.fetch(:item_name, [])
|
27
27
|
@subitem_name = args.fetch(:subitem_name, [])
|
28
|
-
@
|
28
|
+
@collaborator = args[:collaborator]
|
29
29
|
@agenda_id = args[:agenda_id]
|
30
30
|
@item_footnote = args[:item_footnote]
|
31
31
|
end
|
32
32
|
|
33
|
-
# rubocop:disable Metrics/AbcSize
|
33
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize
|
34
34
|
|
35
35
|
# @param [Nokogiri::XML::Builder]
|
36
36
|
def to_xml(builder)
|
@@ -40,26 +40,48 @@ module RelatonUn
|
|
40
40
|
item_number.each { |n| b.send "item-number", n }
|
41
41
|
item_name.each { |n| b.send "item-name", n }
|
42
42
|
subitem_name.each { |n| b.send "subitem-name", n }
|
43
|
-
b.
|
43
|
+
b.collaborator collaborator if collaborator
|
44
44
|
b.send "agenda-id", agenda_id if agenda_id
|
45
45
|
b.send "item-footnote", item_footnote if item_footnote
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
# rubocop:disable Metrics/
|
49
|
+
# rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength
|
50
50
|
# @return [Hash]
|
51
51
|
def to_hash
|
52
52
|
hash = {}
|
53
53
|
hash["session_number"] = session_number if session_number
|
54
54
|
hash["session_date"] = session_date.to_s if session_date
|
55
|
-
|
55
|
+
if item_number.any?
|
56
|
+
hash["item_number"] = single_element_array(item_number)
|
57
|
+
end
|
56
58
|
hash["item_name"] = single_element_array(item_name) if item_name.any?
|
57
|
-
|
58
|
-
|
59
|
+
if subitem_name.any?
|
60
|
+
hash["subitem_name"] = single_element_array(subitem_name)
|
61
|
+
end
|
62
|
+
hash["collaborator"] = collaborator if collaborator
|
59
63
|
hash["agenda_id"] = agenda_id if agenda_id
|
60
64
|
hash["item_footnote"] = item_footnote if item_footnote
|
61
65
|
hash
|
62
66
|
end
|
63
|
-
# rubocop:enable Metrics/
|
67
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
68
|
+
|
69
|
+
# @param prefix [String]
|
70
|
+
# @return [String]
|
71
|
+
def to_asciibib(prefix = "")
|
72
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
73
|
+
pref += "session"
|
74
|
+
out = ""
|
75
|
+
out += "#{pref}.session_number:: #{session_number}\n" if session_number
|
76
|
+
out += "#{pref}.session_date:: #{session_date}\n" if session_date
|
77
|
+
item_number.each { |n| out += "#{pref}.item_number:: #{n}\n" }
|
78
|
+
item_name.each { |n| out += "#{pref}.item_name:: #{n}\n" }
|
79
|
+
subitem_name.each { |n| out += "#{pref}.subitem_name:: #{n}\n" }
|
80
|
+
out += "#{pref}.collaborator:: #{collaborator}\n" if collaborator
|
81
|
+
out += "#{pref}.agenda_id:: #{agenda_id}\n" if agenda_id
|
82
|
+
out += "#{pref}.item_footnote:: #{item_footnote}\n" if item_footnote
|
83
|
+
out
|
84
|
+
end
|
85
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
|
64
86
|
end
|
65
87
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module RelatonUn
|
2
|
-
class UnBibliographicItem <
|
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,33 +14,66 @@ 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
|
-
warn "[relaton-un] WARNING: invalid distribution:
|
27
|
+
warn "[relaton-un] WARNING: invalid distribution: "\
|
28
|
+
"#{args[:distribution]}"
|
22
29
|
end
|
30
|
+
@submissionlanguage = args.delete :submissionlanguage
|
23
31
|
@distribution = args.delete :distribution
|
24
32
|
@session = args.delete :session
|
33
|
+
@job_number = args.delete :job_number
|
25
34
|
super **args
|
26
35
|
end
|
27
36
|
|
28
37
|
# @param builder [Nokogiri::XML::Builder]
|
29
38
|
# @param bibdata [TrueClasss, FalseClass, NilClass]
|
30
|
-
def to_xml(builder = nil, **opts)
|
39
|
+
def to_xml(builder = nil, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
31
40
|
super(builder, **opts) do |b|
|
32
|
-
b.
|
33
|
-
|
41
|
+
b.ext do
|
42
|
+
b.doctype doctype if doctype
|
43
|
+
submissionlanguage&.each { |sl| b.submissionlanguage sl }
|
44
|
+
editorialgroup&.to_xml b
|
45
|
+
ics&.each { |i| i.to_xml b }
|
46
|
+
b.distribution distribution if distribution
|
47
|
+
session&.to_xml b if session
|
48
|
+
b.job_number job_number if job_number
|
49
|
+
end
|
34
50
|
end
|
35
51
|
end
|
36
52
|
|
37
53
|
# @return [Hash]
|
38
54
|
def to_hash
|
39
55
|
hash = super
|
56
|
+
if submissionlanguage&.any?
|
57
|
+
hash["submissionlanguage"] = single_element_array submissionlanguage
|
58
|
+
end
|
59
|
+
hash["distribution"] = distribution if distribution
|
40
60
|
hash["session"] = session.to_hash if session
|
61
|
+
hash["job_number"] = job_number if job_number
|
41
62
|
hash
|
42
63
|
end
|
64
|
+
|
65
|
+
# @param prefix [String]
|
66
|
+
# @return [String]
|
67
|
+
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize
|
68
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
69
|
+
out = super
|
70
|
+
submissionlanguage.each do |sl|
|
71
|
+
out += "#{pref}submissionlanguage:: #{sl}\n"
|
72
|
+
end
|
73
|
+
out += "#{pref}distribution:: #{distribution}\n" if distribution
|
74
|
+
out += session.to_asciibib prefix if session
|
75
|
+
out += "#{pref}job_number:: #{job_number}\n" if job_number
|
76
|
+
out
|
77
|
+
end
|
43
78
|
end
|
44
79
|
end
|