relaton-iho 1.2.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/grammars/iho.rng +30 -6
- data/grammars/isodoc.rng +16 -7
- data/lib/relaton_iho.rb +1 -0
- data/lib/relaton_iho/comment_periond.rb +10 -0
- data/lib/relaton_iho/editorial_group.rb +31 -17
- data/lib/relaton_iho/eg.yml +191 -0
- data/lib/relaton_iho/hash_converter.rb +17 -1
- data/lib/relaton_iho/iho_bibliographic_item.rb +9 -1
- data/lib/relaton_iho/iho_bibliography.rb +4 -2
- data/lib/relaton_iho/iho_group.rb +146 -0
- data/lib/relaton_iho/version.rb +1 -1
- data/lib/relaton_iho/xml_parser.rb +15 -2
- data/relaton_iho.gemspec +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7898af6b5b9c984bcb5888c925df80918f797b3ded43f86ad41e749ebd45b50b
|
4
|
+
data.tar.gz: b1af3d18334b55e941c18c79cf6e3b060b1ac3ecc6c2f0a82757bf4c0e5df05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eb5ce96479f46296bd0c67294d06e1efb646296051ed4e013ba3ce42eddeaa1ba081a0fce26787d02c3fe4157263d29cc0c81adc4150e8214b7d807f6c95de9
|
7
|
+
data.tar.gz: d840e8461f613ba954bba1719519d7df704ef73e18cfaeb75648a3216893146f67256296b91e8e7046be7968d2d373581be3366d725255ccc584ee586dd737fb
|
data/.rubocop.yml
CHANGED
data/grammars/iho.rng
CHANGED
@@ -23,8 +23,13 @@
|
|
23
23
|
</define>
|
24
24
|
<define name="editorialgroup">
|
25
25
|
<element name="editorialgroup">
|
26
|
-
<
|
27
|
-
|
26
|
+
<oneOrMore>
|
27
|
+
<choice>
|
28
|
+
<ref name="committee"/>
|
29
|
+
<ref name="workgroup"/>
|
30
|
+
<ref name="commission"/>
|
31
|
+
</choice>
|
32
|
+
</oneOrMore>
|
28
33
|
</element>
|
29
34
|
</define>
|
30
35
|
<define name="BibDataExtensionType">
|
@@ -94,16 +99,35 @@
|
|
94
99
|
</include>
|
95
100
|
<define name="committee">
|
96
101
|
<element name="committee">
|
97
|
-
<
|
98
|
-
<value>hssc</value>
|
99
|
-
<value>ircc</value>
|
100
|
-
</choice>
|
102
|
+
<ref name="IHO_Group"/>
|
101
103
|
</element>
|
102
104
|
</define>
|
103
105
|
<define name="workgroup">
|
104
106
|
<element name="workgroup">
|
107
|
+
<ref name="IHO_Group"/>
|
108
|
+
</element>
|
109
|
+
</define>
|
110
|
+
<define name="commission">
|
111
|
+
<element name="commission">
|
112
|
+
<ref name="IHO_Group"/>
|
113
|
+
</element>
|
114
|
+
</define>
|
115
|
+
<define name="IHO_Group">
|
116
|
+
<optional>
|
117
|
+
<element name="name">
|
118
|
+
<text/>
|
119
|
+
</element>
|
120
|
+
</optional>
|
121
|
+
<element name="abbreviation">
|
105
122
|
<text/>
|
106
123
|
</element>
|
124
|
+
<optional>
|
125
|
+
<choice>
|
126
|
+
<ref name="committee"/>
|
127
|
+
<ref name="workgroup"/>
|
128
|
+
<ref name="commission"/>
|
129
|
+
</choice>
|
130
|
+
</optional>
|
107
131
|
</define>
|
108
132
|
<define name="annex-appendix">
|
109
133
|
<element name="appendix">
|
data/grammars/isodoc.rng
CHANGED
@@ -42,8 +42,11 @@
|
|
42
42
|
</define>
|
43
43
|
<define name="xref">
|
44
44
|
<element name="xref">
|
45
|
+
<!-- attribute target { xsd:IDREF }, -->
|
45
46
|
<attribute name="target">
|
46
|
-
<data type="
|
47
|
+
<data type="string">
|
48
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
49
|
+
</data>
|
47
50
|
</attribute>
|
48
51
|
<optional>
|
49
52
|
<attribute name="type">
|
@@ -922,6 +925,9 @@
|
|
922
925
|
<optional>
|
923
926
|
<attribute name="script"/>
|
924
927
|
</optional>
|
928
|
+
<optional>
|
929
|
+
<attribute name="type"/>
|
930
|
+
</optional>
|
925
931
|
<optional>
|
926
932
|
<attribute name="obligation">
|
927
933
|
<choice>
|
@@ -961,9 +967,6 @@
|
|
961
967
|
</define>
|
962
968
|
<define name="content-subsection">
|
963
969
|
<element name="clause">
|
964
|
-
<optional>
|
965
|
-
<attribute name="type"/>
|
966
|
-
</optional>
|
967
970
|
<ref name="Content-Section"/>
|
968
971
|
</element>
|
969
972
|
</define>
|
@@ -992,6 +995,9 @@
|
|
992
995
|
</choice>
|
993
996
|
</attribute>
|
994
997
|
</optional>
|
998
|
+
<optional>
|
999
|
+
<attribute name="type"/>
|
1000
|
+
</optional>
|
995
1001
|
<optional>
|
996
1002
|
<ref name="section-title"/>
|
997
1003
|
</optional>
|
@@ -1011,9 +1017,6 @@
|
|
1011
1017
|
</define>
|
1012
1018
|
<define name="clause">
|
1013
1019
|
<element name="clause">
|
1014
|
-
<optional>
|
1015
|
-
<attribute name="type"/>
|
1016
|
-
</optional>
|
1017
1020
|
<ref name="Clause-Section"/>
|
1018
1021
|
</element>
|
1019
1022
|
</define>
|
@@ -1042,6 +1045,9 @@
|
|
1042
1045
|
</choice>
|
1043
1046
|
</attribute>
|
1044
1047
|
</optional>
|
1048
|
+
<optional>
|
1049
|
+
<attribute name="type"/>
|
1050
|
+
</optional>
|
1045
1051
|
<optional>
|
1046
1052
|
<ref name="section-title"/>
|
1047
1053
|
</optional>
|
@@ -1180,6 +1186,9 @@
|
|
1180
1186
|
<optional>
|
1181
1187
|
<attribute name="script"/>
|
1182
1188
|
</optional>
|
1189
|
+
<optional>
|
1190
|
+
<attribute name="type"/>
|
1191
|
+
</optional>
|
1183
1192
|
<optional>
|
1184
1193
|
<attribute name="obligation">
|
1185
1194
|
<choice>
|
data/lib/relaton_iho.rb
CHANGED
@@ -5,6 +5,7 @@ require "relaton_iho/iho_bibliography"
|
|
5
5
|
require "relaton_iho/hash_converter"
|
6
6
|
require "relaton_iho/xml_parser"
|
7
7
|
require "relaton_iho/editorial_group"
|
8
|
+
require "relaton_iho/iho_group"
|
8
9
|
require "relaton_iho/comment_periond"
|
9
10
|
require "relaton_iho/iho_bibliographic_item"
|
10
11
|
|
@@ -27,5 +27,15 @@ module RelatonIho
|
|
27
27
|
hash["to"] = to.to_s if to
|
28
28
|
hash
|
29
29
|
end
|
30
|
+
|
31
|
+
# @param prefix [String]
|
32
|
+
# @return [String]
|
33
|
+
def to_asciibib(prefix)
|
34
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
35
|
+
pref += "commentperiod"
|
36
|
+
out = "#{pref}.from:: #{from}\n"
|
37
|
+
out += "#{pref}.to:: #{to}\n" if to
|
38
|
+
out
|
39
|
+
end
|
30
40
|
end
|
31
41
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module RelatonIho
|
2
2
|
class EditorialGroupCollection
|
3
3
|
extend Forwardable
|
4
|
-
include RelatonBib
|
5
4
|
|
6
5
|
def_delegators :@collection, :first, :any?
|
7
6
|
|
8
|
-
# @return [Array<RelatonIho::
|
7
|
+
# @return [Array<RelatonIho::EditorialGroup]
|
9
8
|
attr_reader :collection
|
10
9
|
|
11
10
|
# @param collection [Array<RelatonIho::EditorialGroup>]
|
@@ -18,9 +17,15 @@ module RelatonIho
|
|
18
17
|
collection.each { |eg| eg.to_xml builder }
|
19
18
|
end
|
20
19
|
|
21
|
-
# @return [Hash]
|
20
|
+
# @return [Hash, Array<Hash>]
|
22
21
|
def to_hash
|
23
|
-
|
22
|
+
collection.map &:to_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param prefix [String]
|
26
|
+
# @return [String]
|
27
|
+
def to_asciibib(prefix)
|
28
|
+
collection.map { |ed| ed.to_asciibib prefix, collection.size }.join
|
24
29
|
end
|
25
30
|
|
26
31
|
# @return [Boolean]
|
@@ -30,30 +35,39 @@ module RelatonIho
|
|
30
35
|
end
|
31
36
|
|
32
37
|
class EditorialGroup
|
33
|
-
|
34
|
-
attr_reader :committee, :workgroup
|
38
|
+
include RelatonBib
|
35
39
|
|
36
|
-
# @
|
37
|
-
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
# @return [Array<RelatonIho::Committee, RelatonIho::Commission,
|
41
|
+
# RelatonIho::Workgroup>]
|
42
|
+
attr_accessor :workgroup
|
43
|
+
|
44
|
+
# @param workgroup [Array<RelatonIho::Committee, RelatonIho::Commission,
|
45
|
+
# RelatonIho::Workgroup>]
|
46
|
+
def initialize(workgroup)
|
43
47
|
@workgroup = workgroup
|
44
48
|
end
|
45
49
|
|
46
50
|
# @param builder [Nokogiro::XML::Builder]
|
47
51
|
def to_xml(builder)
|
48
52
|
builder.editorialgroup do
|
49
|
-
|
50
|
-
builder.workgroup workgroup
|
53
|
+
workgroup.each { |wg| wg.to_xml builder }
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
|
-
# @return [Hash]
|
57
|
+
# @return [Hash, Array<Hash>]
|
55
58
|
def to_hash
|
56
|
-
|
59
|
+
single_element_array workgroup
|
60
|
+
end
|
61
|
+
|
62
|
+
# @param prefix [String]
|
63
|
+
# @param count [Integer]
|
64
|
+
# @return [Strin]
|
65
|
+
def to_asciibib(prefix, count)
|
66
|
+
pref = prefix.empty? ? prefix : prefix + "."
|
67
|
+
pref += "editorialgroup"
|
68
|
+
out = count > 1 ? "#{pref}::\n" : ""
|
69
|
+
workgroup.each { |wg| out += wg.to_asciibib pref, workgroup.size }
|
70
|
+
out
|
57
71
|
end
|
58
72
|
end
|
59
73
|
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
HSSC:
|
2
|
+
previously: CHRIS
|
3
|
+
name: Hydrographic Services and Standards Committee
|
4
|
+
class: Committee
|
5
|
+
subgroup:
|
6
|
+
S-100WG:
|
7
|
+
name: S-100 Working Group
|
8
|
+
class: Workgroup
|
9
|
+
ENCWG:
|
10
|
+
name: ENC STANDARDS MAINTENANCE WORKING GROUP
|
11
|
+
class: Workgroup
|
12
|
+
NCWG:
|
13
|
+
previously: CSPCWG
|
14
|
+
name: NAUTICAL CARTOGRAPHY WORKING GROUP
|
15
|
+
class: Workgroup
|
16
|
+
NIPWG:
|
17
|
+
name: NAUTICAL INFORMATION PROVISION WORKING GROUP
|
18
|
+
class: Workgroup
|
19
|
+
DQWG:
|
20
|
+
name: DATA QUALITY WORKING GROUP
|
21
|
+
class: Workgroup
|
22
|
+
TWCWG:
|
23
|
+
name: Tides, Water Level and Currents Working Group
|
24
|
+
class: Workgroup
|
25
|
+
HDWG:
|
26
|
+
name: Hydrographic Dictionary Working Group
|
27
|
+
class: Workgroup
|
28
|
+
ABLOS:
|
29
|
+
name: Advisory Board on Law of the Sea
|
30
|
+
class: Workgroup
|
31
|
+
HSPT:
|
32
|
+
name: Project Team on Standards for Hydrographic Surveys
|
33
|
+
class: Workgroup
|
34
|
+
CPRNW:
|
35
|
+
name: Commission for the Promulgation of Radio Navigation Warnings
|
36
|
+
class: Commission
|
37
|
+
TSMAD:
|
38
|
+
name: Transfer Standard Maintenance and Application Development Working Group
|
39
|
+
class: Workgroup
|
40
|
+
IRCC:
|
41
|
+
name: Inter-Regional Coordination Committee
|
42
|
+
class: Committee
|
43
|
+
subgroup:
|
44
|
+
RHCs:
|
45
|
+
name: Regional Hydrographic Commissions
|
46
|
+
class: Commission
|
47
|
+
subgroup:
|
48
|
+
NHC:
|
49
|
+
name: Nordic HC
|
50
|
+
class: Commission
|
51
|
+
NSHC:
|
52
|
+
name: North Sea HC
|
53
|
+
class: Commission
|
54
|
+
MBSHC:
|
55
|
+
name: Mediterranean and Black Seas HC
|
56
|
+
class: Commission
|
57
|
+
subgroup:
|
58
|
+
BASWG:
|
59
|
+
name: Black and Azov Seas Working Group
|
60
|
+
class: Workgroup
|
61
|
+
ARHC:
|
62
|
+
name: Arctic RHC
|
63
|
+
class: Commission
|
64
|
+
BHSC:
|
65
|
+
name: Baltic Sea HC
|
66
|
+
class: Commission
|
67
|
+
USCHC:
|
68
|
+
name: US / Canada HC
|
69
|
+
class: Commission
|
70
|
+
EAHS:
|
71
|
+
name: East Asia HC
|
72
|
+
class: Commission
|
73
|
+
EAtHC:
|
74
|
+
name: Eastern Atlantic HC
|
75
|
+
class: Commission
|
76
|
+
SEPRHC:
|
77
|
+
name: South-East Pacific RHC
|
78
|
+
class: Commission
|
79
|
+
SWPHC:
|
80
|
+
name: South-West Pacific HC
|
81
|
+
class: Commission
|
82
|
+
subgroup:
|
83
|
+
ICCWG:
|
84
|
+
name: International Charting Coordination Working Group
|
85
|
+
class: Workgroup
|
86
|
+
MACHC:
|
87
|
+
name: Meso American & Caribbean Sea HC
|
88
|
+
class: Commission
|
89
|
+
SAIHC:
|
90
|
+
name: Southern African and Islands HC
|
91
|
+
class: Commission
|
92
|
+
NIOHC:
|
93
|
+
name: North Indian Ocean HC
|
94
|
+
class: Commission
|
95
|
+
RSAHC:
|
96
|
+
name: ROPME Sea Area HC
|
97
|
+
class: Commission
|
98
|
+
subgroup:
|
99
|
+
ICCWG:
|
100
|
+
name: International Charting Coordination Working Group
|
101
|
+
class: Workgroup
|
102
|
+
SWAtHC:
|
103
|
+
name: South West Atlantic HC
|
104
|
+
class: Commission
|
105
|
+
HCA:
|
106
|
+
name: Hydrographic Commission on Antarctica
|
107
|
+
class: Commission
|
108
|
+
subgroup:
|
109
|
+
HPWG:
|
110
|
+
name: HCA Hydrography Priorities Working Group
|
111
|
+
class: Workgroup
|
112
|
+
WWNWS:
|
113
|
+
name: World-Wide Navigational Warning Service
|
114
|
+
class: Committee
|
115
|
+
subgroup:
|
116
|
+
S-124PT:
|
117
|
+
name: S-124 Project Team
|
118
|
+
class: Workgroup
|
119
|
+
CBSC:
|
120
|
+
name: CAPACITY BUILDING SUB-COMMITTEE
|
121
|
+
class: Committee
|
122
|
+
WENDWG:
|
123
|
+
name: WORLDWIDE ENC DATABASE WORKING GROUP
|
124
|
+
class: Workgroup
|
125
|
+
MSDIWG:
|
126
|
+
name: MARINE SPATIAL DATA INFRASTRUCTURES WORKING GROUP
|
127
|
+
class: Workgroup
|
128
|
+
EC-IHO:
|
129
|
+
name: IENWG & EC - IHO Cooperation WG
|
130
|
+
class: Workgroup
|
131
|
+
subgroup:
|
132
|
+
IENWG:
|
133
|
+
name: COOPERATION BETWEEN THE EUROPEAN COMMISSION (EC) AND THE IHO
|
134
|
+
class: Workgroup
|
135
|
+
CSBWG:
|
136
|
+
name: CROWDSOURCED BATHYMETRY WORKING GROUP
|
137
|
+
class: Workgroup
|
138
|
+
IBSC:
|
139
|
+
name: FIG/IHO/ICA INTERNATIONAL BOARD ON STANDARDS OF COMPETENCE FOR HYDROGRAPHIC SURVEYORS AND NAUTICAL CARTOGRAPHERS
|
140
|
+
class: Committee
|
141
|
+
DCDB:
|
142
|
+
name: IHO Data Centre for Digital Bathymetry
|
143
|
+
class: Committee
|
144
|
+
GEBCO:
|
145
|
+
name: JOINT IHO-IOC GUIDING COMMITTEE FOR THE GENERAL BATHYMETRIC CHART OF THE OCEANS
|
146
|
+
class: Committee
|
147
|
+
subgroup:
|
148
|
+
GGC:
|
149
|
+
name: GEBCO Guiding Committee
|
150
|
+
class: Committee
|
151
|
+
SCUFN:
|
152
|
+
name: GEBCO SUB-COMMITTEE ON UNDERSEA FEATURE NAMES
|
153
|
+
class: Committee
|
154
|
+
TSCOM:
|
155
|
+
name: GEBCO TECHNICAL SUB-COMMITTEE ON OCEAN MAPPING
|
156
|
+
class: Committee
|
157
|
+
SCRUM:
|
158
|
+
name: SUB-COMMITTEE ON REGIONAL UNDERSEA MAPPING
|
159
|
+
class: Committee
|
160
|
+
SCOPE:
|
161
|
+
name: SUB-COMMITTEE ON COMMUNICATIONS, OUTREACH AND PUBLIC ENGAGEMENT
|
162
|
+
class: Committee
|
163
|
+
Council:
|
164
|
+
class: Committee
|
165
|
+
subgroup:
|
166
|
+
SPRWG:
|
167
|
+
name: Strategic Plan Review Working Group
|
168
|
+
class: Workgroup
|
169
|
+
IHR:
|
170
|
+
name: International Hydrography Review
|
171
|
+
class: Committee
|
172
|
+
subgroup:
|
173
|
+
IHR:
|
174
|
+
name: International Hydrography Review
|
175
|
+
class: Committee
|
176
|
+
IHREB:
|
177
|
+
name: International Hydrography Review Editorial Board
|
178
|
+
class: Committee
|
179
|
+
BUREAU:
|
180
|
+
name: International Hydrography Bureau
|
181
|
+
class: Committee
|
182
|
+
IMO MSC:
|
183
|
+
name: Maritime Safety Committee
|
184
|
+
class: Committee
|
185
|
+
subgroup:
|
186
|
+
NCSR:
|
187
|
+
name: Sub-Committee on Navigation, Communications and Search and Rescue
|
188
|
+
class: Committee
|
189
|
+
DCDB:
|
190
|
+
name: IHO Data Centre for Digital Bathymetry
|
191
|
+
class: Committee
|
@@ -25,9 +25,25 @@ module RelatonIho
|
|
25
25
|
eg = ret[:editorialgroup]
|
26
26
|
return unless eg.is_a?(Hash) || eg&.any?
|
27
27
|
|
28
|
-
collection = array(eg).map
|
28
|
+
collection = array(eg).map do |g|
|
29
|
+
EditorialGroup.new(array(g).map { |wg| iho_workgroup wg })
|
30
|
+
end
|
29
31
|
ret[:editorialgroup] = EditorialGroupCollection.new collection
|
30
32
|
end
|
33
|
+
|
34
|
+
# @param ihowg [Hash]
|
35
|
+
# @return [RelatonIho::Committee, RelatonIho::Workgroup,
|
36
|
+
# RelatonIho::Commission]
|
37
|
+
def iho_workgroup(ihowg)
|
38
|
+
key, value = ihowg&.first
|
39
|
+
return unless key && value.is_a?(Hash)
|
40
|
+
|
41
|
+
klass = Object.const_get "RelatonIho::#{key.capitalize}"
|
42
|
+
subwg = value.select do |k, _|
|
43
|
+
%i[committee workgroup commission].include? k
|
44
|
+
end
|
45
|
+
klass.new value[:abbreviation], value[:name], iho_workgroup(subwg)
|
46
|
+
end
|
31
47
|
end
|
32
48
|
end
|
33
49
|
end
|
@@ -15,7 +15,7 @@ module RelatonIho
|
|
15
15
|
|
16
16
|
# @param builder [Nokogiri::XML::Builder]
|
17
17
|
# @param bibdata [TrueClasss, FalseClass, NilClass]
|
18
|
-
def to_xml(builer = nil, **opts)
|
18
|
+
def to_xml(builer = nil, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
19
19
|
opts[:ext] = !commentperiod.nil?
|
20
20
|
super do |b|
|
21
21
|
if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
|
@@ -36,5 +36,13 @@ module RelatonIho
|
|
36
36
|
hash["commentperiod"] = commentperiod.to_hash if commentperiod
|
37
37
|
hash
|
38
38
|
end
|
39
|
+
|
40
|
+
# @param prefix [String]
|
41
|
+
# @return [String]
|
42
|
+
def to_asciibib(prefix = "")
|
43
|
+
out = super
|
44
|
+
out += commentperiod.to_asciibib prefix if commentperiod
|
45
|
+
out
|
46
|
+
end
|
39
47
|
end
|
40
48
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
1
3
|
module RelatonIho
|
2
4
|
class IhoBibliography
|
3
5
|
ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iho/"\
|
@@ -6,12 +8,12 @@ module RelatonIho
|
|
6
8
|
class << self
|
7
9
|
# @param text [String]
|
8
10
|
# @return [RelatonIho::IhoBibliographicItem]
|
9
|
-
def search(text, _year = nil, _opts = {})
|
11
|
+
def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
10
12
|
warn "[relaton-iho] (\"#{text}\") fetching..."
|
11
13
|
ref = text.sub(/^IHO\s/, "").downcase
|
12
14
|
uri = URI("#{ENDPOINT}#{ref}.yaml")
|
13
15
|
resp = Net::HTTP.get_response uri
|
14
|
-
|
16
|
+
return unless resp.code == "200"
|
15
17
|
|
16
18
|
hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
|
17
19
|
item = IhoBibliographicItem.new hash
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module RelatonIho
|
2
|
+
class IHOGroup
|
3
|
+
# @return [String]
|
4
|
+
attr_reader :abbreviation
|
5
|
+
|
6
|
+
# @return [String, nil]
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
# @return [RelatonIho::Committee, RelatonIho::Workgroup,
|
10
|
+
# RelatonIho::Commission, nil]
|
11
|
+
attr_reader :subgroup
|
12
|
+
|
13
|
+
# @param abbreviation [String]
|
14
|
+
# @param name [String, nil]
|
15
|
+
# @param subgroup [RelatonIho::Committee, RelatonIho::Workgroup,
|
16
|
+
# RelatonIho::Commission, nil]
|
17
|
+
def initialize(abbreviation, name = nil, subgroup = nil)
|
18
|
+
@abbreviation = abbreviation
|
19
|
+
@name = name
|
20
|
+
@subgroup = subgroup
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# @param abbr [String]
|
25
|
+
# @return [RelatonIho::EditorialGroup]
|
26
|
+
def expand(abbr)
|
27
|
+
struct = YAML.load_file File.expand_path("eg.yml", __dir__)
|
28
|
+
from_abbr abbr.upcase, struct
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @param abbr [String]
|
34
|
+
# @param struct [Hash]
|
35
|
+
# @return [RelatonIho::Committee, RelatonIho::Commission,
|
36
|
+
# RelatonIho::Workgroup]
|
37
|
+
def from_abbr(abbr, struct)
|
38
|
+
return unless struct
|
39
|
+
|
40
|
+
gr = struct.detect { |k, v| k == abbr || v["previously"] == abbr }
|
41
|
+
return klass(gr[1]["class"]).new abbr, gr[1]["name"] if gr
|
42
|
+
|
43
|
+
expand_from_abbr abbr, struct
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param abbr [String]
|
47
|
+
# @param struct [Hash]
|
48
|
+
# @return [RelatonIho::Committee, RelatonIho::Commission,
|
49
|
+
# RelatonIho::Workgroup]
|
50
|
+
def expand_from_abbr(abbr, struct)
|
51
|
+
struct.each do |k, g|
|
52
|
+
wg = from_abbr abbr, g["subgroup"]
|
53
|
+
return klass(g["class"]).new k, g["name"], wg if wg
|
54
|
+
end
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
def klass(name)
|
59
|
+
Object.const_get "RelatonIho::" + name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param builder [Nokogiri::XML::Builder]
|
64
|
+
def to_xml(builder)
|
65
|
+
builder.name name if name
|
66
|
+
builder.abbreviation abbreviation
|
67
|
+
subgroup&.to_xml builder
|
68
|
+
end
|
69
|
+
|
70
|
+
# @return [Hash]
|
71
|
+
def to_hash
|
72
|
+
hash = { "abbreviation" => abbreviation }
|
73
|
+
hash["name"] = name if name
|
74
|
+
hash.merge! subgroup.to_hash if subgroup
|
75
|
+
hash
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param prefix [String]
|
79
|
+
# @param count [Integer]
|
80
|
+
# @return [Strin]
|
81
|
+
def to_asciibib(prefix, count = 1)
|
82
|
+
out = count > 1 ? "#{prefix}::\n" : ""
|
83
|
+
out += "#{prefix}.abbreviation:: #{abbreviation}\n"
|
84
|
+
out += "#{prefix}.name:: #{name}\n" if name
|
85
|
+
out += subgroup.to_asciibib prefix if subgroup
|
86
|
+
out
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Committee < IHOGroup
|
91
|
+
# @param builder [Nokogiri::XML::Builder]
|
92
|
+
def to_xml(builder)
|
93
|
+
builder.committee { |b| super b }
|
94
|
+
end
|
95
|
+
|
96
|
+
# @return [Hash]
|
97
|
+
def to_hash
|
98
|
+
{ "committee" => super }
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param prefix [String]
|
102
|
+
# @param count [Integer]
|
103
|
+
# @return [Strin]
|
104
|
+
def to_asciibib(prefix, count = 1)
|
105
|
+
super prefix + ".committee", count
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class Workgroup < IHOGroup
|
110
|
+
# @param builder [Nokogiri::XML::Builder]
|
111
|
+
def to_xml(builder)
|
112
|
+
builder.workgroup { |b| super b }
|
113
|
+
end
|
114
|
+
|
115
|
+
# @return [Hash]
|
116
|
+
def to_hash
|
117
|
+
{ "workgroup" => super }
|
118
|
+
end
|
119
|
+
|
120
|
+
# @param prefix [String]
|
121
|
+
# @param count [Integer]
|
122
|
+
# @return [Strin]
|
123
|
+
def to_asciibib(prefix, count = 1)
|
124
|
+
super prefix + ".workgroup", count
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Commission < IHOGroup
|
129
|
+
# @param builder [Nokogiri::XML::Builder]
|
130
|
+
def to_xml(builder)
|
131
|
+
builder.commisstion { |b| super b }
|
132
|
+
end
|
133
|
+
|
134
|
+
# @return [Hash]
|
135
|
+
def to_hash
|
136
|
+
{ "commission" => super }
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param prefix [String]
|
140
|
+
# @param count [Integer]
|
141
|
+
# @return [Strin]
|
142
|
+
def to_asciibib(prefix, count = 1)
|
143
|
+
super prefix + ".commission", count
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
data/lib/relaton_iho/version.rb
CHANGED
@@ -27,12 +27,25 @@ module RelatonIho
|
|
27
27
|
return unless ext
|
28
28
|
|
29
29
|
egs = ext.xpath("editorialgroup").map do |eg|
|
30
|
-
|
31
|
-
|
30
|
+
grps = eg.xpath("committee|workgroup|commission").map do |ig|
|
31
|
+
iho_group ig
|
32
|
+
end
|
33
|
+
EditorialGroup.new grps
|
32
34
|
end
|
33
35
|
EditorialGroupCollection.new egs if egs.any?
|
34
36
|
end
|
35
37
|
|
38
|
+
# @param ext [Nokogiri::XML::Element. nil]
|
39
|
+
# @return [RelatonIho::Committee, RelatonIho::Commission,
|
40
|
+
# RelatonIho::Workgroup, nil]
|
41
|
+
def iho_group(ihgrp)
|
42
|
+
return unless ihgrp
|
43
|
+
|
44
|
+
klass = Object.const_get "RelatonIho::" + ihgrp.name.capitalize
|
45
|
+
subg = iho_group ihgrp.at("./committee|./workgroup|./commission")
|
46
|
+
klass.new ihgrp.at("abbreviation").text, ihgrp.at("name")&.text, subg
|
47
|
+
end
|
48
|
+
|
36
49
|
# @param ext [Nokogiri::XML::Element]
|
37
50
|
# @return [RelatonIho::CommentPeriod, nil]
|
38
51
|
def fetch_commentperiond(ext)
|
data/relaton_iho.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.
|
159
|
+
version: 1.3.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.
|
166
|
+
version: 1.3.0
|
167
167
|
description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
|
168
168
|
model'
|
169
169
|
email:
|
@@ -190,10 +190,12 @@ files:
|
|
190
190
|
- lib/relaton_iho.rb
|
191
191
|
- lib/relaton_iho/comment_periond.rb
|
192
192
|
- lib/relaton_iho/editorial_group.rb
|
193
|
+
- lib/relaton_iho/eg.yml
|
193
194
|
- lib/relaton_iho/hash_converter.rb
|
194
195
|
- lib/relaton_iho/hit_collection.rb
|
195
196
|
- lib/relaton_iho/iho_bibliographic_item.rb
|
196
197
|
- lib/relaton_iho/iho_bibliography.rb
|
198
|
+
- lib/relaton_iho/iho_group.rb
|
197
199
|
- lib/relaton_iho/processor.rb
|
198
200
|
- lib/relaton_iho/version.rb
|
199
201
|
- lib/relaton_iho/xml_parser.rb
|
@@ -202,7 +204,7 @@ homepage: https://github.com/relaton/relaton-iho
|
|
202
204
|
licenses:
|
203
205
|
- BSD-2-Clause
|
204
206
|
metadata: {}
|
205
|
-
post_install_message:
|
207
|
+
post_install_message:
|
206
208
|
rdoc_options: []
|
207
209
|
require_paths:
|
208
210
|
- lib
|
@@ -218,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
220
|
version: '0'
|
219
221
|
requirements: []
|
220
222
|
rubygems_version: 3.0.6
|
221
|
-
signing_key:
|
223
|
+
signing_key:
|
222
224
|
specification_version: 4
|
223
225
|
summary: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
|
224
226
|
model'
|