relaton-iho 1.2.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9de8a40ba30cb75e63c79bd94336fb3a912966d96e5c9effa06de4449b2d1b42
4
- data.tar.gz: 30a0fa02802686ffd10cb798ba1024c2ee30a5d0cf8a3de1839162042375adc1
3
+ metadata.gz: 9c2889e6d995ae69c8aaf59df34b2a4c8ca5c7700be4e7f31f5ae27411469afd
4
+ data.tar.gz: 9c27f57bd7cd0824fcbfbd4acc6cd6921f7c7cf0bd2594a4032406ccd037d406
5
5
  SHA512:
6
- metadata.gz: 493afaeb6f957ddff07dc00136b7ded51bca12d404ef82d9089bee4009dbb04e8ee9da620bf429fc2a969e60b5d89917adc496c379544d21d42bf20df8ba0cb9
7
- data.tar.gz: dfebf7a00a38d031b1556223cf88136783cccde0a37b1ecee93bb17c3bb0ca6de48c69a66c39c983c692b3734aa6f40aa57bf7bb42c73a01342bb86b7eba8f3c
6
+ metadata.gz: b73ac143dab2eff7e69440608d2373b0f62cfe059cebcf0a1fab47a2d395dd8fd6b3fd22ba5f3124293cd14f8d4e7382795e65a0c3135e0ea7fe407636af7503
7
+ data.tar.gz: e25a2f287db40dfc99a305358134b3dfd87afe2aa3a500c103f2de8f97e6ae4093b8aa3b1843a1cf253c073cb5bc8ca9d6b1f5002b11b711eb313ac15c4b43b4
@@ -5,6 +5,6 @@
5
5
  inherit_from:
6
6
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
7
  AllCops:
8
- TargetRubyVersion: 2.3
8
+ TargetRubyVersion: 2.4
9
9
  Rails:
10
- Enabled: true
10
+ Enabled: false
@@ -32,7 +32,7 @@ Or install it yourself as:
32
32
 
33
33
  [source,sh]
34
34
  ----
35
- $ gem install relaton_iho
35
+ $ gem install relaton-iho
36
36
  ----
37
37
 
38
38
  == Usage
@@ -41,11 +41,13 @@ $ gem install relaton_iho
41
41
 
42
42
  [source,ruby]
43
43
  ----
44
- hits = RelatonIho::IhoBibliography.search("OGC 19-025r1")
45
- => [<RelatonIho::Hit:0x007fcab6b9aab8 @text="OGC 19-025r1" @fetched="false" @fullIdentifier="" @title="">]
44
+ pry(main)> require 'relaton_iho'
45
+ => true
46
46
 
47
- tem = hits[0].fetch
48
- => #<RelatonIho::IhoBibliographicItem:0x007fcab3cb4758
47
+ item = RelatonIho::IhoBibliography.search("B-11")
48
+ [relaton-iho] ("B-11") fetching...
49
+ [relaton-iho] ("B-11") found B-11
50
+ => #<RelatonIho::IhoBibliographicItem:0x007fe74fc80800
49
51
  ...
50
52
  ----
51
53
 
@@ -53,14 +55,12 @@ tem = hits[0].fetch
53
55
  [source,ruby]
54
56
  ----
55
57
  item.to_xml
56
- => "<bibitem id="19-025r1" type="standard">
57
- <title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
58
- <title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
59
- <uri type="obp">https://portal.opengeospatial.org/files/?artifact_id=88037</uri>
60
- <docidentifier type="OGC">19-025r1</docidentifier>
61
- <date type="published">
62
- <on>2019</on>
63
- </date>
58
+ => "<bibitem id="B-11" type="standard">
59
+ <fetched>2020-03-29</fetched>
60
+ <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
61
+ <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
62
+ <uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
63
+ <docidentifier type="IHO">B-11</docidentifier>
64
64
  ...
65
65
  </bibitem>"
66
66
  ----
@@ -69,33 +69,45 @@ With argument `bibdata: true` it ouputs XML wrapped by `bibdata` element and add
69
69
  ----
70
70
  item.to_xml bibdata: true
71
71
  => "<bibdata type="standard">
72
- <title type="title-main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
73
- <title type="main" format="text/plain" language="en" script="Latn">Development of Spatial Data Infrastructures for Marine Data Management</title>
74
- <uri type="obp">https://portal.opengeospatial.org/files/?artifact_id=88037</uri>
75
- <docidentifier type="OGC">19-025r1</docidentifier>
76
- <date type="published\">
77
- <on>2019</on>
78
- </date>
72
+ <fetched>2020-03-29</fetched>
73
+ <title type="main" format="text/plain" language="en">IHO-IOC GEBCO Cook Book</title>
74
+ <title type="main" format="text/plain" language="fr">Livre de recettes GEBCO OHI-COI</title>
75
+ <uri type="pdf">https://www.star.nesdis.noaa.gov/socd/lsa/GEBCO_Cookbook/documents/CookBook_20191031.pdf</uri>
76
+ <docidentifier type="IHO">B-11</docidentifier>
79
77
  ...
80
78
  <ext>
81
- <doctype>public-engineering-report</doctype>
79
+ <editorialgroup>
80
+ <committee>
81
+ <name>Hydrographic Services and Standards Committee</name>
82
+ <abbreviation>HSSC</abbreviation>
83
+ </committee>
84
+ <committee>
85
+ <name>Inter-Regional Coordination Committee</name>
86
+ <abbreviation>IRCC</abbreviation>
87
+ <committee>
88
+ <name>JOINT IHO-IOC GUIDING COMMITTEE FOR THE GENERAL BATHYMETRIC CHART OF THE OCEANS</name>
89
+ <abbreviation>GEBCO</abbreviation>
90
+ </committee>
91
+ </committee>
92
+ </editorialgroup>
82
93
  </ext>
83
94
  </bibdata>"
84
95
  ----
85
96
 
86
- === Get code, and year
97
+ === Get code
87
98
  [source,ruby]
88
99
  ----
89
- RelatonIho::IhoBibliography.get "OGC 19-025r1", "2019", {}
90
- fetching OGC 19-025r1...
91
- => #<RelatonIho::IhoBibliographicItem:0x007fc322e9aba0
100
+ RelatonIho::IhoBibliography.get "IHO B-11"
101
+ [relaton-iho] ("IHO B-11") fetching...
102
+ [relaton-iho] ("IHO B-11") found B-11
103
+ => #<RelatonIho::IhoBibliographicItem:0x007fe78dbb7c78
92
104
  ...
93
105
  ----
94
106
 
95
107
  === Create bibliographic item from XML
96
108
  [source,ruby]
97
109
  ----
98
- RelatonIho::XMLParser.from_xml File.read('spec/fixtures/ogc_bib_item.xml')
110
+ RelatonIho::XMLParser.from_xml File.read('spec/fixtures/iho.xml')
99
111
  => #<RelatonIho::IhoBibliographicItem:0x007fc322ea82c8
100
112
  ...
101
113
  ----
@@ -103,12 +115,12 @@ RelatonIho::XMLParser.from_xml File.read('spec/fixtures/ogc_bib_item.xml')
103
115
  === Create bibliographic item from YAML
104
116
  [source,ruby]
105
117
  ----
106
- hash = YAML.load_file 'spec/fixtures/ogc_bib_item.yml'
107
- => {"id"=>"19-025r1",
118
+ hash = YAML.load_file 'spec/fixtures/iho.yaml'
119
+ => {"id"=>"B-11",
108
120
  ...
109
121
 
110
122
  bib_hash = RelatonIho::HashConverter.hash_to_bib hash
111
- => {:id=>"19-025r1",
123
+ => {:id=>"B-11",
112
124
  ...
113
125
 
114
126
  RelatonIho::IhoBibliographicItem.new bib_hash
@@ -23,8 +23,13 @@
23
23
  </define>
24
24
  <define name="editorialgroup">
25
25
  <element name="editorialgroup">
26
- <ref name="committee"/>
27
- <ref name="workgroup"/>
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
- <choice>
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">
@@ -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="IDREF"/>
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">
@@ -61,6 +64,11 @@
61
64
  </choice>
62
65
  </attribute>
63
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
64
72
  <text/>
65
73
  </element>
66
74
  </define>
@@ -578,6 +586,8 @@
578
586
  <ref name="ol"/>
579
587
  <ref name="dl"/>
580
588
  <ref name="formula"/>
589
+ <ref name="quote"/>
590
+ <ref name="sourcecode"/>
581
591
  </choice>
582
592
  </oneOrMore>
583
593
  </element>
@@ -661,6 +671,16 @@
661
671
  </choice>
662
672
  </attribute>
663
673
  </optional>
674
+ <optional>
675
+ <attribute name="valign">
676
+ <choice>
677
+ <value>top</value>
678
+ <value>middle</value>
679
+ <value>bottom</value>
680
+ <value>baseline</value>
681
+ </choice>
682
+ </attribute>
683
+ </optional>
664
684
  <choice>
665
685
  <zeroOrMore>
666
686
  <choice>
@@ -697,6 +717,16 @@
697
717
  </choice>
698
718
  </attribute>
699
719
  </optional>
720
+ <optional>
721
+ <attribute name="valign">
722
+ <choice>
723
+ <value>top</value>
724
+ <value>middle</value>
725
+ <value>bottom</value>
726
+ <value>baseline</value>
727
+ </choice>
728
+ </attribute>
729
+ </optional>
700
730
  <choice>
701
731
  <zeroOrMore>
702
732
  <choice>
@@ -855,7 +885,7 @@
855
885
  <oneOrMore>
856
886
  <choice>
857
887
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
888
+ <ref name="abstract"/>
859
889
  <ref name="foreword"/>
860
890
  <ref name="introduction"/>
861
891
  <ref name="acknowledgements"/>
@@ -922,6 +952,9 @@
922
952
  <optional>
923
953
  <attribute name="script"/>
924
954
  </optional>
955
+ <optional>
956
+ <attribute name="type"/>
957
+ </optional>
925
958
  <optional>
926
959
  <attribute name="obligation">
927
960
  <choice>
@@ -961,9 +994,6 @@
961
994
  </define>
962
995
  <define name="content-subsection">
963
996
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
997
  <ref name="Content-Section"/>
968
998
  </element>
969
999
  </define>
@@ -992,6 +1022,9 @@
992
1022
  </choice>
993
1023
  </attribute>
994
1024
  </optional>
1025
+ <optional>
1026
+ <attribute name="type"/>
1027
+ </optional>
995
1028
  <optional>
996
1029
  <ref name="section-title"/>
997
1030
  </optional>
@@ -1011,9 +1044,6 @@
1011
1044
  </define>
1012
1045
  <define name="clause">
1013
1046
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1047
  <ref name="Clause-Section"/>
1018
1048
  </element>
1019
1049
  </define>
@@ -1042,18 +1072,24 @@
1042
1072
  </choice>
1043
1073
  </attribute>
1044
1074
  </optional>
1075
+ <optional>
1076
+ <attribute name="type"/>
1077
+ </optional>
1045
1078
  <optional>
1046
1079
  <ref name="section-title"/>
1047
1080
  </optional>
1048
1081
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1082
+ <choice>
1083
+ <group>
1084
+ <zeroOrMore>
1085
+ <ref name="BasicBlock"/>
1086
+ </zeroOrMore>
1087
+ <zeroOrMore>
1088
+ <ref name="note"/>
1089
+ </zeroOrMore>
1090
+ </group>
1091
+ <ref name="amend"/>
1092
+ </choice>
1057
1093
  <zeroOrMore>
1058
1094
  <choice>
1059
1095
  <ref name="clause-subsection"/>
@@ -1180,6 +1216,9 @@
1180
1216
  <optional>
1181
1217
  <attribute name="script"/>
1182
1218
  </optional>
1219
+ <optional>
1220
+ <attribute name="type"/>
1221
+ </optional>
1183
1222
  <optional>
1184
1223
  <attribute name="obligation">
1185
1224
  <choice>
@@ -1447,11 +1486,6 @@
1447
1486
  </optional>
1448
1487
  </element>
1449
1488
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1489
  <define name="term-clause">
1456
1490
  <element name="clause">
1457
1491
  <optional>
@@ -1501,4 +1535,79 @@
1501
1535
  <ref name="CitationType"/>
1502
1536
  </element>
1503
1537
  </define>
1538
+ <define name="amend">
1539
+ <element name="amend">
1540
+ <optional>
1541
+ <attribute name="id">
1542
+ <data type="ID"/>
1543
+ </attribute>
1544
+ </optional>
1545
+ <attribute name="change">
1546
+ <choice>
1547
+ <value>add</value>
1548
+ <value>modify</value>
1549
+ <value>delete</value>
1550
+ </choice>
1551
+ </attribute>
1552
+ <optional>
1553
+ <attribute name="path"/>
1554
+ </optional>
1555
+ <optional>
1556
+ <attribute name="path_end"/>
1557
+ </optional>
1558
+ <optional>
1559
+ <attribute name="title"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <element name="location">
1563
+ <zeroOrMore>
1564
+ <ref name="locality"/>
1565
+ </zeroOrMore>
1566
+ </element>
1567
+ </optional>
1568
+ <zeroOrMore>
1569
+ <ref name="autonumber"/>
1570
+ </zeroOrMore>
1571
+ <optional>
1572
+ <element name="description">
1573
+ <zeroOrMore>
1574
+ <ref name="BasicBlock"/>
1575
+ </zeroOrMore>
1576
+ </element>
1577
+ </optional>
1578
+ <optional>
1579
+ <element name="newcontent">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="description">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ </element>
1593
+ </define>
1594
+ <define name="autonumber">
1595
+ <element name="autonumber">
1596
+ <attribute name="type">
1597
+ <choice>
1598
+ <value>requirement</value>
1599
+ <value>recommendation</value>
1600
+ <value>permission</value>
1601
+ <value>table</value>
1602
+ <value>figure</value>
1603
+ <value>admonition</value>
1604
+ <value>formula</value>
1605
+ <value>sourcecode</value>
1606
+ <value>example</value>
1607
+ <value>note</value>
1608
+ </choice>
1609
+ </attribute>
1610
+ <text/>
1611
+ </element>
1612
+ </define>
1504
1613
  </grammar>
@@ -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::editorialgroup]
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
- single_element_array collection
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,35 +35,39 @@ module RelatonIho
30
35
  end
31
36
 
32
37
  class EditorialGroup
33
- # @return [String]
34
- attr_reader :committee
38
+ include RelatonBib
35
39
 
36
- # @return [String, nil]
37
- attr_reader :workgroup
40
+ # @return [Array<RelatonIho::Committee, RelatonIho::Commission,
41
+ # RelatonIho::Workgroup>]
42
+ attr_accessor :workgroup
38
43
 
39
- # @parma committee [String]
40
- # @param workgroup [String, nil]
41
- def initialize(committee:, workgroup: nil)
42
- unless %[hssc ircc council ihr bureau imo msc dcdb].include? committee.downcase
43
- warn "[relaton-iho] WARNING: invalid committee: #{committee}"
44
- end
45
- @committee = committee
44
+ # @param workgroup [Array<RelatonIho::Committee, RelatonIho::Commission,
45
+ # RelatonIho::Workgroup>]
46
+ def initialize(workgroup)
46
47
  @workgroup = workgroup
47
48
  end
48
49
 
49
50
  # @param builder [Nokogiro::XML::Builder]
50
51
  def to_xml(builder)
51
52
  builder.editorialgroup do
52
- builder.committee committee
53
- builder.workgroup workgroup if workgroup
53
+ workgroup.each { |wg| wg.to_xml builder }
54
54
  end
55
55
  end
56
56
 
57
- # @return [Hash]
57
+ # @return [Hash, Array<Hash>]
58
58
  def to_hash
59
- hash = { "committee" => committee }
60
- hash["workgroup"] = workgroup if workgroup
61
- hash
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
62
71
  end
63
72
  end
64
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 { |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)
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
- ref = text.sub(/^IHO\s/, "").downcase
13
+ ref = text.sub(/^IHO\s/, "").downcase.sub /^([[:alpha:]]+)(\d+)/, '\1-\2'
12
14
  uri = URI("#{ENDPOINT}#{ref}.yaml")
13
15
  resp = Net::HTTP.get_response uri
14
- returm unless resp.code == "200"
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
@@ -19,7 +21,7 @@ module RelatonIho
19
21
  item
20
22
  rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
21
23
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
22
- Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
24
+ Net::ProtocolError, Net::ReadTimeout, # OpenSSL::SSL::SSLError,
23
25
  Errno::ETIMEDOUT => e
24
26
  raise RelatonBib::RequestError, "Could not access #{uri}: #{e.message}"
25
27
  end
@@ -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.2.2".freeze
2
+ VERSION = "1.4.0".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)
@@ -32,5 +32,5 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency "vcr"
33
33
  s.add_development_dependency "webmock"
34
34
 
35
- s.add_dependency "relaton-bib", "~> 1.2.0"
35
+ s.add_dependency "relaton-bib", "~> 1.4.0"
36
36
  end
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.2
4
+ version: 1.4.0
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-07-03 00:00:00.000000000 Z
11
+ date: 2020-09-18 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.2.0
159
+ version: 1.4.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.2.0
166
+ version: 1.4.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'