relaton-un 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/macos.yml +32 -0
- data/.github/workflows/ubuntu.yml +32 -0
- data/.github/workflows/windows.yml +35 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.adoc +115 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/grammars/basicdoc.rng +986 -0
- data/grammars/biblio.rng +1142 -0
- data/grammars/isodoc.rng +1028 -0
- data/grammars/reqt.rng +165 -0
- data/grammars/un.rng +242 -0
- data/lib/relaton_un.rb +21 -0
- data/lib/relaton_un/hash_converter.rb +5 -0
- data/lib/relaton_un/hit.rb +58 -0
- data/lib/relaton_un/hit_collection.rb +106 -0
- data/lib/relaton_un/processor.rb +41 -0
- data/lib/relaton_un/un_bibliographic_item.rb +8 -0
- data/lib/relaton_un/un_bibliography.rb +43 -0
- data/lib/relaton_un/version.rb +3 -0
- data/lib/relaton_un/xml_parser.rb +16 -0
- data/relaton_un.gemspec +46 -0
- data/resp.html +163 -0
- metadata +229 -0
data/grammars/reqt.rng
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Presupposes isodoc.rnc, is included in it
|
5
|
+
include "isodoc.rnc" { }
|
6
|
+
-->
|
7
|
+
<define name="requirement">
|
8
|
+
<element name="requirement">
|
9
|
+
<ref name="RequirementType"/>
|
10
|
+
</element>
|
11
|
+
</define>
|
12
|
+
<define name="recommendation">
|
13
|
+
<element name="recommendation">
|
14
|
+
<ref name="RequirementType"/>
|
15
|
+
</element>
|
16
|
+
</define>
|
17
|
+
<define name="permission">
|
18
|
+
<element name="permission">
|
19
|
+
<ref name="RequirementType"/>
|
20
|
+
</element>
|
21
|
+
</define>
|
22
|
+
<define name="RequirementType">
|
23
|
+
<optional>
|
24
|
+
<attribute name="obligation">
|
25
|
+
<ref name="ObligationType"/>
|
26
|
+
</attribute>
|
27
|
+
</optional>
|
28
|
+
<optional>
|
29
|
+
<attribute name="unnumbered">
|
30
|
+
<data type="boolean"/>
|
31
|
+
</attribute>
|
32
|
+
</optional>
|
33
|
+
<optional>
|
34
|
+
<attribute name="subsequence"/>
|
35
|
+
</optional>
|
36
|
+
<attribute name="id">
|
37
|
+
<data type="ID"/>
|
38
|
+
</attribute>
|
39
|
+
<optional>
|
40
|
+
<attribute name="filename"/>
|
41
|
+
</optional>
|
42
|
+
<optional>
|
43
|
+
<ref name="reqtitle"/>
|
44
|
+
</optional>
|
45
|
+
<optional>
|
46
|
+
<ref name="label"/>
|
47
|
+
</optional>
|
48
|
+
<optional>
|
49
|
+
<ref name="subject"/>
|
50
|
+
</optional>
|
51
|
+
<optional>
|
52
|
+
<ref name="reqinherit"/>
|
53
|
+
</optional>
|
54
|
+
<zeroOrMore>
|
55
|
+
<ref name="classification"/>
|
56
|
+
</zeroOrMore>
|
57
|
+
<zeroOrMore>
|
58
|
+
<choice>
|
59
|
+
<ref name="measurementtarget"/>
|
60
|
+
<ref name="specification"/>
|
61
|
+
<ref name="verification"/>
|
62
|
+
<ref name="import"/>
|
63
|
+
<ref name="description"/>
|
64
|
+
</choice>
|
65
|
+
</zeroOrMore>
|
66
|
+
<optional>
|
67
|
+
<ref name="reqt_references"/>
|
68
|
+
</optional>
|
69
|
+
<zeroOrMore>
|
70
|
+
<choice>
|
71
|
+
<ref name="requirement"/>
|
72
|
+
<ref name="recommendation"/>
|
73
|
+
<ref name="permission"/>
|
74
|
+
</choice>
|
75
|
+
</zeroOrMore>
|
76
|
+
</define>
|
77
|
+
<define name="reqtitle">
|
78
|
+
<element name="title">
|
79
|
+
<ref name="FormattedString"/>
|
80
|
+
</element>
|
81
|
+
</define>
|
82
|
+
<define name="label">
|
83
|
+
<element name="label">
|
84
|
+
<text/>
|
85
|
+
</element>
|
86
|
+
</define>
|
87
|
+
<define name="subject">
|
88
|
+
<element name="subject">
|
89
|
+
<text/>
|
90
|
+
</element>
|
91
|
+
</define>
|
92
|
+
<define name="reqinherit">
|
93
|
+
<element name="inherit">
|
94
|
+
<text/>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="measurementtarget">
|
98
|
+
<element name="measurement-target">
|
99
|
+
<ref name="RequirementSubpart"/>
|
100
|
+
</element>
|
101
|
+
</define>
|
102
|
+
<define name="specification">
|
103
|
+
<element name="specification">
|
104
|
+
<ref name="RequirementSubpart"/>
|
105
|
+
</element>
|
106
|
+
</define>
|
107
|
+
<define name="verification">
|
108
|
+
<element name="verification">
|
109
|
+
<ref name="RequirementSubpart"/>
|
110
|
+
</element>
|
111
|
+
</define>
|
112
|
+
<define name="import">
|
113
|
+
<element name="import">
|
114
|
+
<ref name="RequirementSubpart"/>
|
115
|
+
</element>
|
116
|
+
</define>
|
117
|
+
<define name="description">
|
118
|
+
<element name="description">
|
119
|
+
<ref name="RequirementSubpart"/>
|
120
|
+
</element>
|
121
|
+
</define>
|
122
|
+
<define name="reqt_references">
|
123
|
+
<element name="references">
|
124
|
+
<oneOrMore>
|
125
|
+
<ref name="bibitem"/>
|
126
|
+
</oneOrMore>
|
127
|
+
</element>
|
128
|
+
</define>
|
129
|
+
<define name="RequirementSubpart">
|
130
|
+
<optional>
|
131
|
+
<attribute name="type"/>
|
132
|
+
</optional>
|
133
|
+
<optional>
|
134
|
+
<attribute name="exclude">
|
135
|
+
<data type="boolean"/>
|
136
|
+
</attribute>
|
137
|
+
</optional>
|
138
|
+
<oneOrMore>
|
139
|
+
<ref name="BasicBlock"/>
|
140
|
+
</oneOrMore>
|
141
|
+
</define>
|
142
|
+
<define name="ObligationType">
|
143
|
+
<choice>
|
144
|
+
<value>requirement</value>
|
145
|
+
<value>recommendation</value>
|
146
|
+
<value>permission</value>
|
147
|
+
</choice>
|
148
|
+
</define>
|
149
|
+
<define name="classification">
|
150
|
+
<element name="classification">
|
151
|
+
<ref name="classification_tag"/>
|
152
|
+
<ref name="classification_value"/>
|
153
|
+
</element>
|
154
|
+
</define>
|
155
|
+
<define name="classification_tag">
|
156
|
+
<element name="tag">
|
157
|
+
<text/>
|
158
|
+
</element>
|
159
|
+
</define>
|
160
|
+
<define name="classification_value">
|
161
|
+
<element name="value">
|
162
|
+
<text/>
|
163
|
+
</element>
|
164
|
+
</define>
|
165
|
+
</grammar>
|
data/grammars/un.rng
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
3
|
+
<!--
|
4
|
+
Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
|
5
|
+
we cannot have a new default namespace: we will end up with a grammar with two different
|
6
|
+
namespaces, one for isostandard and one for csand additions. And we do not want that.
|
7
|
+
-->
|
8
|
+
<include href="isodoc.rng">
|
9
|
+
<start>
|
10
|
+
<ref name="un-standard"/>
|
11
|
+
</start>
|
12
|
+
<define name="TextElement">
|
13
|
+
<choice>
|
14
|
+
<text/>
|
15
|
+
<ref name="em"/>
|
16
|
+
<ref name="eref"/>
|
17
|
+
<ref name="strong"/>
|
18
|
+
<ref name="stem"/>
|
19
|
+
<ref name="sub"/>
|
20
|
+
<ref name="sup"/>
|
21
|
+
<ref name="tt"/>
|
22
|
+
<ref name="strike"/>
|
23
|
+
<ref name="smallcap"/>
|
24
|
+
<ref name="xref"/>
|
25
|
+
<ref name="br"/>
|
26
|
+
<ref name="hyperlink"/>
|
27
|
+
<ref name="hr"/>
|
28
|
+
<ref name="pagebreak"/>
|
29
|
+
<ref name="bookmark"/>
|
30
|
+
</choice>
|
31
|
+
</define>
|
32
|
+
<define name="admonition">
|
33
|
+
<element name="admonition">
|
34
|
+
<attribute name="id">
|
35
|
+
<data type="ID"/>
|
36
|
+
</attribute>
|
37
|
+
<optional>
|
38
|
+
<attribute name="unnumbered">
|
39
|
+
<data type="boolean"/>
|
40
|
+
</attribute>
|
41
|
+
</optional>
|
42
|
+
<attribute name="type">
|
43
|
+
<choice>
|
44
|
+
<value>danger</value>
|
45
|
+
<value>caution</value>
|
46
|
+
<value>warning</value>
|
47
|
+
<value>important</value>
|
48
|
+
<value>safety precautions</value>
|
49
|
+
</choice>
|
50
|
+
</attribute>
|
51
|
+
<optional>
|
52
|
+
<ref name="tname"/>
|
53
|
+
</optional>
|
54
|
+
<oneOrMore>
|
55
|
+
<choice>
|
56
|
+
<ref name="paragraph-with-footnote"/>
|
57
|
+
<ref name="table"/>
|
58
|
+
<ref name="formula"/>
|
59
|
+
<ref name="ol"/>
|
60
|
+
<ref name="ul"/>
|
61
|
+
<ref name="dl"/>
|
62
|
+
<ref name="figure"/>
|
63
|
+
<ref name="quote"/>
|
64
|
+
<ref name="sourcecode"/>
|
65
|
+
<ref name="example"/>
|
66
|
+
<ref name="review"/>
|
67
|
+
</choice>
|
68
|
+
</oneOrMore>
|
69
|
+
<zeroOrMore>
|
70
|
+
<ref name="note"/>
|
71
|
+
</zeroOrMore>
|
72
|
+
</element>
|
73
|
+
</define>
|
74
|
+
<define name="DocumentType">
|
75
|
+
<choice>
|
76
|
+
<value>recommendation</value>
|
77
|
+
<value>plenary</value>
|
78
|
+
<value>addendum</value>
|
79
|
+
<value>communication</value>
|
80
|
+
<value>corrigendum</value>
|
81
|
+
<value>reissue</value>
|
82
|
+
<value>agenda</value>
|
83
|
+
<value>budgetary</value>
|
84
|
+
<value>sec-gen-notes</value>
|
85
|
+
<value>expert-report</value>
|
86
|
+
<value>resolution</value>
|
87
|
+
</choice>
|
88
|
+
</define>
|
89
|
+
<define name="editorialgroup">
|
90
|
+
<element name="editorialgroup">
|
91
|
+
<oneOrMore>
|
92
|
+
<ref name="committee"/>
|
93
|
+
</oneOrMore>
|
94
|
+
</element>
|
95
|
+
</define>
|
96
|
+
<define name="sections">
|
97
|
+
<element name="sections">
|
98
|
+
<oneOrMore>
|
99
|
+
<ref name="clause"/>
|
100
|
+
</oneOrMore>
|
101
|
+
</element>
|
102
|
+
</define>
|
103
|
+
<define name="BibDataExtensionType">
|
104
|
+
<optional>
|
105
|
+
<ref name="doctype"/>
|
106
|
+
</optional>
|
107
|
+
<zeroOrMore>
|
108
|
+
<ref name="submissionlanguage"/>
|
109
|
+
</zeroOrMore>
|
110
|
+
<ref name="editorialgroup"/>
|
111
|
+
<zeroOrMore>
|
112
|
+
<ref name="ics"/>
|
113
|
+
</zeroOrMore>
|
114
|
+
<optional>
|
115
|
+
<ref name="distribution"/>
|
116
|
+
</optional>
|
117
|
+
<optional>
|
118
|
+
<ref name="session"/>
|
119
|
+
</optional>
|
120
|
+
</define>
|
121
|
+
<define name="preface">
|
122
|
+
<element name="preface">
|
123
|
+
<optional>
|
124
|
+
<ref name="abstract"/>
|
125
|
+
</optional>
|
126
|
+
<optional>
|
127
|
+
<ref name="foreword"/>
|
128
|
+
</optional>
|
129
|
+
<optional>
|
130
|
+
<ref name="introduction"/>
|
131
|
+
</optional>
|
132
|
+
</element>
|
133
|
+
</define>
|
134
|
+
<define name="abstract">
|
135
|
+
<element name="abstract">
|
136
|
+
<ref name="Basic-Section"/>
|
137
|
+
</element>
|
138
|
+
</define>
|
139
|
+
</include>
|
140
|
+
<define name="session">
|
141
|
+
<element name="session">
|
142
|
+
<optional>
|
143
|
+
<ref name="session-number"/>
|
144
|
+
</optional>
|
145
|
+
<optional>
|
146
|
+
<ref name="session-date"/>
|
147
|
+
</optional>
|
148
|
+
<zeroOrMore>
|
149
|
+
<ref name="item-number"/>
|
150
|
+
</zeroOrMore>
|
151
|
+
<zeroOrMore>
|
152
|
+
<ref name="item-name"/>
|
153
|
+
</zeroOrMore>
|
154
|
+
<zeroOrMore>
|
155
|
+
<ref name="subitem-name"/>
|
156
|
+
</zeroOrMore>
|
157
|
+
<optional>
|
158
|
+
<ref name="collaborator"/>
|
159
|
+
</optional>
|
160
|
+
<optional>
|
161
|
+
<ref name="agenda-id"/>
|
162
|
+
</optional>
|
163
|
+
<optional>
|
164
|
+
<ref name="item-footnote"/>
|
165
|
+
</optional>
|
166
|
+
</element>
|
167
|
+
</define>
|
168
|
+
<define name="committee">
|
169
|
+
<element name="committee">
|
170
|
+
<text/>
|
171
|
+
</element>
|
172
|
+
</define>
|
173
|
+
<define name="session-number">
|
174
|
+
<element name="number">
|
175
|
+
<text/>
|
176
|
+
</element>
|
177
|
+
</define>
|
178
|
+
<define name="session-date">
|
179
|
+
<element name="session-date">
|
180
|
+
<data type="date"/>
|
181
|
+
</element>
|
182
|
+
</define>
|
183
|
+
<define name="item-number">
|
184
|
+
<element name="item-number">
|
185
|
+
<text/>
|
186
|
+
</element>
|
187
|
+
</define>
|
188
|
+
<define name="collaborator">
|
189
|
+
<element name="collaborator">
|
190
|
+
<text/>
|
191
|
+
</element>
|
192
|
+
</define>
|
193
|
+
<define name="agenda-id">
|
194
|
+
<element name="agenda-id">
|
195
|
+
<text/>
|
196
|
+
</element>
|
197
|
+
</define>
|
198
|
+
<define name="item-name">
|
199
|
+
<element name="item-name">
|
200
|
+
<text/>
|
201
|
+
</element>
|
202
|
+
</define>
|
203
|
+
<define name="subitem-name">
|
204
|
+
<element name="subitem-name">
|
205
|
+
<text/>
|
206
|
+
</element>
|
207
|
+
</define>
|
208
|
+
<define name="item-footnote">
|
209
|
+
<element name="item-footnote">
|
210
|
+
<text/>
|
211
|
+
</element>
|
212
|
+
</define>
|
213
|
+
<define name="submissionlanguage">
|
214
|
+
<element name="submissionlanguage">
|
215
|
+
<text/>
|
216
|
+
</element>
|
217
|
+
</define>
|
218
|
+
<define name="distribution">
|
219
|
+
<element name="distribution">
|
220
|
+
<choice>
|
221
|
+
<value>general</value>
|
222
|
+
<value>limited</value>
|
223
|
+
<value>restricted</value>
|
224
|
+
</choice>
|
225
|
+
</element>
|
226
|
+
</define>
|
227
|
+
<define name="un-standard">
|
228
|
+
<element name="un-standard">
|
229
|
+
<ref name="bibdata"/>
|
230
|
+
<optional>
|
231
|
+
<ref name="boilerplate"/>
|
232
|
+
</optional>
|
233
|
+
<ref name="preface"/>
|
234
|
+
<oneOrMore>
|
235
|
+
<ref name="sections"/>
|
236
|
+
</oneOrMore>
|
237
|
+
<zeroOrMore>
|
238
|
+
<ref name="annex"/>
|
239
|
+
</zeroOrMore>
|
240
|
+
</element>
|
241
|
+
</define>
|
242
|
+
</grammar>
|
data/lib/relaton_un.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "relaton_bib"
|
2
|
+
require "relaton_un/version"
|
3
|
+
require "relaton_un/un_bibliographic_item"
|
4
|
+
require "relaton_un/un_bibliography"
|
5
|
+
require "relaton_un/hit_collection"
|
6
|
+
require "relaton_un/hit"
|
7
|
+
require "relaton_un/hash_converter"
|
8
|
+
require "relaton_un/xml_parser"
|
9
|
+
|
10
|
+
module RelatonUn
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
# Returns hash of XML reammar
|
14
|
+
# @return [String]
|
15
|
+
def self.grammar_hash
|
16
|
+
gem_path = File.expand_path "..", __dir__
|
17
|
+
grammars_path = File.join gem_path, "grammars", "*"
|
18
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
19
|
+
Digest::MD5.hexdigest grammars
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RelatonUn
|
4
|
+
# Hit.
|
5
|
+
class Hit < RelatonBib::Hit
|
6
|
+
# Parse page.
|
7
|
+
# @return [RelatonUn::UnBibliographicItem]
|
8
|
+
def fetch
|
9
|
+
@fetch ||= un_bib_item
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def un_bib_item
|
15
|
+
UnBibliographicItem.new(
|
16
|
+
type: "standard",
|
17
|
+
fetched: Date.today.to_s,
|
18
|
+
docid: docid,
|
19
|
+
docnumber: hit[:ref],
|
20
|
+
language: ["en"],
|
21
|
+
script: ["Latn"],
|
22
|
+
title: title,
|
23
|
+
date: date,
|
24
|
+
link: link,
|
25
|
+
keyword: keyword
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Array<RelatonBib::DocumentIdentifier>]
|
30
|
+
def docid
|
31
|
+
[RelatonBib::DocumentIdentifier.new(id: hit[:ref], type: "UN")]
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Array<RelatonBib::TypedTitleString>]
|
35
|
+
def title
|
36
|
+
fs = RelatonBib::FormattedString.new(content: hit[:title], language: "en", script: "Latn")
|
37
|
+
[RelatonBib::TypedTitleString.new(type: "main", title: fs)]
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Array<RelatonBib::BibliographicDate>]
|
41
|
+
def date
|
42
|
+
d = []
|
43
|
+
d << RelatonBib::BibliographicDate.new(type: "published", on: hit[:date_pub]) if hit[:date_pub]
|
44
|
+
d << RelatonBib::BibliographicDate.new(type: "issued", on: hit[:date_rel]) if hit[:date_rel]
|
45
|
+
d
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Array<RelatonBib::TypedUri>]
|
49
|
+
def link
|
50
|
+
hit[:link].map { |l| RelatonBib::TypedUri.new l }
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Array<String>]
|
54
|
+
def keyword
|
55
|
+
hit[:keyword].split(", ")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|