relaton-iho 1.3.0 → 1.3.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: 77ecf973a90c8af2ae4a0f67edc3f313f850afe7a2d99385923bf8e84cd05c6b
4
- data.tar.gz: fd1ad0bd00a7cd28dcc5e1a44cf2dc1a71ffbfce90893f526bb0a80552bb4208
3
+ metadata.gz: a6a255a7706913443c4114b78fb417b67de9955f843cd434959c9ef6eb4009f6
4
+ data.tar.gz: 0d367ff3ad8c25f6873223bbc846c95c92e21c9dfdd5df6034abbb5f59b7cb40
5
5
  SHA512:
6
- metadata.gz: 6ccb427bc61bf0b5550baad8cf0511086bc0c0ae5407ca60062f191edb31630a706f1b59d4d07c7564c550849fa9e83b627c70a76eda6c065003c6301ffa1f35
7
- data.tar.gz: '08a06a4eff69ace8c8437916d8cd916cd7e48fdcd2208a47d0dc6fa2dc75db752d175d0d60b5df7003bb35e1bc65871a97c9e65b30031dfc4f82bf8bead3d52d'
6
+ metadata.gz: 4c1f2e6df7dece59c0efdfd2e1605475045f2d6c9305ad9b0650ff68db17a76513412061ffb6663a0c370f2751e4dcae31a12e9acca34878a99378c546f2f846
7
+ data.tar.gz: 4fe6fad0a66d7b15c898ca52b420926f3232ec0db93e49590870dc9c2dc8062b1d5aa187219b0bd7f837967822fe798b6780ec5a15ae5ee7efafe5ed0e35a9f3
@@ -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
 
@@ -1,7 +1,6 @@
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
 
@@ -18,9 +17,9 @@ 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
- single_element_array collection
22
+ collection.map &:to_hash
24
23
  end
25
24
 
26
25
  # @param prefix [String]
@@ -36,35 +35,28 @@ module RelatonIho
36
35
  end
37
36
 
38
37
  class EditorialGroup
39
- # @return [String]
40
- attr_reader :committee
38
+ include RelatonBib
41
39
 
42
- # @return [String, nil]
43
- attr_reader :workgroup
40
+ # @return [Array<RelatonIho::Committee, RelatonIho::Commission,
41
+ # RelatonIho::Workgroup>]
42
+ attr_accessor :workgroup
44
43
 
45
- # @parma committee [String]
46
- # @param workgroup [String, nil]
47
- def initialize(committee:, workgroup: nil)
48
- unless %[hssc ircc council ihr bureau imo msc dcdb].include? committee.downcase
49
- warn "[relaton-iho] WARNING: invalid committee: #{committee}"
50
- end
51
- @committee = committee
44
+ # @param workgroup [Array<RelatonIho::Committee, RelatonIho::Commission,
45
+ # RelatonIho::Workgroup>]
46
+ def initialize(workgroup)
52
47
  @workgroup = workgroup
53
48
  end
54
49
 
55
50
  # @param builder [Nokogiro::XML::Builder]
56
51
  def to_xml(builder)
57
52
  builder.editorialgroup do
58
- builder.committee committee
59
- builder.workgroup workgroup if workgroup
53
+ workgroup.each { |wg| wg.to_xml builder }
60
54
  end
61
55
  end
62
56
 
63
- # @return [Hash]
57
+ # @return [Hash, Array<Hash>]
64
58
  def to_hash
65
- hash = { "committee" => committee }
66
- hash["workgroup"] = workgroup if workgroup
67
- hash
59
+ single_element_array workgroup
68
60
  end
69
61
 
70
62
  # @param prefix [String]
@@ -74,8 +66,7 @@ module RelatonIho
74
66
  pref = prefix.empty? ? prefix : prefix + "."
75
67
  pref += "editorialgroup"
76
68
  out = count > 1 ? "#{pref}::\n" : ""
77
- out += "#{pref}.committee:: #{committee}\n"
78
- out += "#{pref}.workgroup:: #{workgroup}\n" if workgroup
69
+ workgroup.each { |wg| out += wg.to_asciibib pref, workgroup.size }
79
70
  out
80
71
  end
81
72
  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 { |g| EditorialGroup.new g }
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) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
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? ||
@@ -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,7 +8,7 @@ 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")
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RelatonIho
2
- VERSION = "1.3.0".freeze
2
+ VERSION = "1.3.1".freeze
3
3
  end
@@ -27,12 +27,25 @@ module RelatonIho
27
27
  return unless ext
28
28
 
29
29
  egs = ext.xpath("editorialgroup").map do |eg|
30
- EditorialGroup.new(committee: eg.at("committee")&.text,
31
- workgroup: eg.at("workgroup")&.text)
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)
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.3.0
4
+ version: 1.3.1
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-08-21 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -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'