relaton-iho 1.3.0 → 1.5.0

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: 5287c92a9460b9824298f86fe7a8a921c6e95ec905af81c3972ccd89b39c435e
4
+ data.tar.gz: 89f4d59af4346061c1a7c964471f1c3989a850767e96a3b2f1b2949e88557a1a
5
5
  SHA512:
6
- metadata.gz: 6ccb427bc61bf0b5550baad8cf0511086bc0c0ae5407ca60062f191edb31630a706f1b59d4d07c7564c550849fa9e83b627c70a76eda6c065003c6301ffa1f35
7
- data.tar.gz: '08a06a4eff69ace8c8437916d8cd916cd7e48fdcd2208a47d0dc6fa2dc75db752d175d0d60b5df7003bb35e1bc65871a97c9e65b30031dfc4f82bf8bead3d52d'
6
+ metadata.gz: a7f9474e438600fc90653129f6bc7cd3fdf49f07fac96ca63771b8d1eeeda06635771e2dafeb0f1d4462efa09caaa197548cca3079f112334a58e87d29783468
7
+ data.tar.gz: 2999394cad48607762ffdc67456c0c14731315d9138b3b26e4d1f260bd464918d7b836f81d228c7881c100bb582fd5a2a3d2fde716f64d296b9fb7ec8e66bce4
@@ -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">
@@ -124,6 +148,13 @@
124
148
  </define>
125
149
  <define name="iho-standard">
126
150
  <element name="iho-standard">
151
+ <attribute name="version"/>
152
+ <attribute name="type">
153
+ <choice>
154
+ <value>semantic</value>
155
+ <value>presentation</value>
156
+ </choice>
157
+ </attribute>
127
158
  <ref name="bibdata"/>
128
159
  <zeroOrMore>
129
160
  <ref name="termdocsource"/>
@@ -43,7 +43,9 @@
43
43
  <define name="xref">
44
44
  <element name="xref">
45
45
  <attribute name="target">
46
- <data type="IDREF"/>
46
+ <data type="string">
47
+ <param name="pattern">\i\c*|\c+#\c+</param>
48
+ </data>
47
49
  </attribute>
48
50
  <optional>
49
51
  <attribute name="type">
@@ -61,6 +63,11 @@
61
63
  </choice>
62
64
  </attribute>
63
65
  </optional>
66
+ <optional>
67
+ <attribute name="droploc">
68
+ <data type="boolean"/>
69
+ </attribute>
70
+ </optional>
64
71
  <text/>
65
72
  </element>
66
73
  </define>
@@ -578,6 +585,8 @@
578
585
  <ref name="ol"/>
579
586
  <ref name="dl"/>
580
587
  <ref name="formula"/>
588
+ <ref name="quote"/>
589
+ <ref name="sourcecode"/>
581
590
  </choice>
582
591
  </oneOrMore>
583
592
  </element>
@@ -661,6 +670,16 @@
661
670
  </choice>
662
671
  </attribute>
663
672
  </optional>
673
+ <optional>
674
+ <attribute name="valign">
675
+ <choice>
676
+ <value>top</value>
677
+ <value>middle</value>
678
+ <value>bottom</value>
679
+ <value>baseline</value>
680
+ </choice>
681
+ </attribute>
682
+ </optional>
664
683
  <choice>
665
684
  <zeroOrMore>
666
685
  <choice>
@@ -697,6 +716,16 @@
697
716
  </choice>
698
717
  </attribute>
699
718
  </optional>
719
+ <optional>
720
+ <attribute name="valign">
721
+ <choice>
722
+ <value>top</value>
723
+ <value>middle</value>
724
+ <value>bottom</value>
725
+ <value>baseline</value>
726
+ </choice>
727
+ </attribute>
728
+ </optional>
700
729
  <choice>
701
730
  <zeroOrMore>
702
731
  <choice>
@@ -834,6 +863,13 @@
834
863
  </define>
835
864
  <define name="standard-document">
836
865
  <element name="standard-document">
866
+ <attribute name="version"/>
867
+ <attribute name="type">
868
+ <choice>
869
+ <value>semantic</value>
870
+ <value>presentation</value>
871
+ </choice>
872
+ </attribute>
837
873
  <ref name="bibdata"/>
838
874
  <optional>
839
875
  <ref name="boilerplate"/>
@@ -855,7 +891,7 @@
855
891
  <oneOrMore>
856
892
  <choice>
857
893
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
894
+ <ref name="abstract"/>
859
895
  <ref name="foreword"/>
860
896
  <ref name="introduction"/>
861
897
  <ref name="acknowledgements"/>
@@ -922,6 +958,9 @@
922
958
  <optional>
923
959
  <attribute name="script"/>
924
960
  </optional>
961
+ <optional>
962
+ <attribute name="type"/>
963
+ </optional>
925
964
  <optional>
926
965
  <attribute name="obligation">
927
966
  <choice>
@@ -961,9 +1000,6 @@
961
1000
  </define>
962
1001
  <define name="content-subsection">
963
1002
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
1003
  <ref name="Content-Section"/>
968
1004
  </element>
969
1005
  </define>
@@ -992,6 +1028,9 @@
992
1028
  </choice>
993
1029
  </attribute>
994
1030
  </optional>
1031
+ <optional>
1032
+ <attribute name="type"/>
1033
+ </optional>
995
1034
  <optional>
996
1035
  <ref name="section-title"/>
997
1036
  </optional>
@@ -1011,9 +1050,6 @@
1011
1050
  </define>
1012
1051
  <define name="clause">
1013
1052
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1053
  <ref name="Clause-Section"/>
1018
1054
  </element>
1019
1055
  </define>
@@ -1042,18 +1078,24 @@
1042
1078
  </choice>
1043
1079
  </attribute>
1044
1080
  </optional>
1081
+ <optional>
1082
+ <attribute name="type"/>
1083
+ </optional>
1045
1084
  <optional>
1046
1085
  <ref name="section-title"/>
1047
1086
  </optional>
1048
1087
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1088
+ <choice>
1089
+ <group>
1090
+ <zeroOrMore>
1091
+ <ref name="BasicBlock"/>
1092
+ </zeroOrMore>
1093
+ <zeroOrMore>
1094
+ <ref name="note"/>
1095
+ </zeroOrMore>
1096
+ </group>
1097
+ <ref name="amend"/>
1098
+ </choice>
1057
1099
  <zeroOrMore>
1058
1100
  <choice>
1059
1101
  <ref name="clause-subsection"/>
@@ -1180,6 +1222,9 @@
1180
1222
  <optional>
1181
1223
  <attribute name="script"/>
1182
1224
  </optional>
1225
+ <optional>
1226
+ <attribute name="type"/>
1227
+ </optional>
1183
1228
  <optional>
1184
1229
  <attribute name="obligation">
1185
1230
  <choice>
@@ -1447,11 +1492,6 @@
1447
1492
  </optional>
1448
1493
  </element>
1449
1494
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1495
  <define name="term-clause">
1456
1496
  <element name="clause">
1457
1497
  <optional>
@@ -1501,4 +1541,79 @@
1501
1541
  <ref name="CitationType"/>
1502
1542
  </element>
1503
1543
  </define>
1544
+ <define name="amend">
1545
+ <element name="amend">
1546
+ <optional>
1547
+ <attribute name="id">
1548
+ <data type="ID"/>
1549
+ </attribute>
1550
+ </optional>
1551
+ <attribute name="change">
1552
+ <choice>
1553
+ <value>add</value>
1554
+ <value>modify</value>
1555
+ <value>delete</value>
1556
+ </choice>
1557
+ </attribute>
1558
+ <optional>
1559
+ <attribute name="path"/>
1560
+ </optional>
1561
+ <optional>
1562
+ <attribute name="path_end"/>
1563
+ </optional>
1564
+ <optional>
1565
+ <attribute name="title"/>
1566
+ </optional>
1567
+ <optional>
1568
+ <element name="location">
1569
+ <zeroOrMore>
1570
+ <ref name="locality"/>
1571
+ </zeroOrMore>
1572
+ </element>
1573
+ </optional>
1574
+ <zeroOrMore>
1575
+ <ref name="autonumber"/>
1576
+ </zeroOrMore>
1577
+ <optional>
1578
+ <element name="description">
1579
+ <zeroOrMore>
1580
+ <ref name="BasicBlock"/>
1581
+ </zeroOrMore>
1582
+ </element>
1583
+ </optional>
1584
+ <optional>
1585
+ <element name="newcontent">
1586
+ <zeroOrMore>
1587
+ <ref name="BasicBlock"/>
1588
+ </zeroOrMore>
1589
+ </element>
1590
+ </optional>
1591
+ <optional>
1592
+ <element name="description">
1593
+ <zeroOrMore>
1594
+ <ref name="BasicBlock"/>
1595
+ </zeroOrMore>
1596
+ </element>
1597
+ </optional>
1598
+ </element>
1599
+ </define>
1600
+ <define name="autonumber">
1601
+ <element name="autonumber">
1602
+ <attribute name="type">
1603
+ <choice>
1604
+ <value>requirement</value>
1605
+ <value>recommendation</value>
1606
+ <value>permission</value>
1607
+ <value>table</value>
1608
+ <value>figure</value>
1609
+ <value>admonition</value>
1610
+ <value>formula</value>
1611
+ <value>sourcecode</value>
1612
+ <value>example</value>
1613
+ <value>note</value>
1614
+ </choice>
1615
+ </attribute>
1616
+ <text/>
1617
+ </element>
1618
+ </define>
1504
1619
  </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
 
@@ -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
@@ -15,6 +15,12 @@ module RelatonIho
15
15
 
16
16
  private
17
17
 
18
+ # @param item_hash [Hash]
19
+ # @return [RelatonBib::BibliographicItem]
20
+ def bib_item(item_hash)
21
+ IhoBibliographicItem.new item_hash
22
+ end
23
+
18
24
  # @param ret [Hash]
19
25
  def commentperiod_hash_to_bib(ret)
20
26
  ret[:commentperiod] &&= CommentPeriond.new(ret[:commentperiod])
@@ -25,9 +31,25 @@ module RelatonIho
25
31
  eg = ret[:editorialgroup]
26
32
  return unless eg.is_a?(Hash) || eg&.any?
27
33
 
28
- collection = array(eg).map { |g| EditorialGroup.new g }
34
+ collection = array(eg).map do |g|
35
+ EditorialGroup.new(array(g).map { |wg| iho_workgroup wg })
36
+ end
29
37
  ret[:editorialgroup] = EditorialGroupCollection.new collection
30
38
  end
39
+
40
+ # @param ihowg [Hash]
41
+ # @return [RelatonIho::Committee, RelatonIho::Workgroup,
42
+ # RelatonIho::Commission]
43
+ def iho_workgroup(ihowg)
44
+ key, value = ihowg&.first
45
+ return unless key && value.is_a?(Hash)
46
+
47
+ klass = Object.const_get "RelatonIho::#{key.capitalize}"
48
+ subwg = value.select do |k, _|
49
+ %i[committee workgroup commission].include? k
50
+ end
51
+ klass.new value[:abbreviation], value[:name], iho_workgroup(subwg)
52
+ end
31
53
  end
32
54
  end
33
55
  end
@@ -13,11 +13,13 @@ module RelatonIho
13
13
  super
14
14
  end
15
15
 
16
- # @param builder [Nokogiri::XML::Builder]
17
- # @param bibdata [TrueClasss, FalseClass, NilClass]
18
- def to_xml(builer = nil, **opts) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
19
- opts[:ext] = !commentperiod.nil?
20
- super do |b|
16
+ # @param opts [Hash]
17
+ # @option opts [Nokogiri::XML::Builder] :builder XML builder
18
+ # @option opts [Boolean] :bibdata
19
+ # @option opts [String] :lang language
20
+ # @return [String] XML
21
+ def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
22
+ super ext: !commentperiod.nil?, **opts do |b|
21
23
  if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
22
24
  ics.any? || commentperiod)
23
25
  b.ext do
@@ -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,9 +8,9 @@ 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
16
  return unless resp.code == "200"
@@ -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
@@ -35,7 +35,7 @@ module RelatonIho
35
35
  # Returns hash of XML grammar
36
36
  # @return [String]
37
37
  def grammar_hash
38
- @grammar_hash ||= ::RelatonIeee.grammar_hash
38
+ @grammar_hash ||= ::RelatonIho.grammar_hash
39
39
  end
40
40
  end
41
41
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIho
2
- VERSION = "1.3.0".freeze
2
+ VERSION = "1.5.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.3.0"
35
+ s.add_dependency "relaton-bib", "~> 1.5.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.3.0
4
+ version: 1.5.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-08-21 00:00:00.000000000 Z
11
+ date: 2020-10-09 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.3.0
159
+ version: 1.5.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.3.0
166
+ version: 1.5.0
167
167
  description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
168
168
  model'
169
169
  email:
@@ -190,10 +190,11 @@ 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
- - lib/relaton_iho/hit_collection.rb
195
195
  - lib/relaton_iho/iho_bibliographic_item.rb
196
196
  - lib/relaton_iho/iho_bibliography.rb
197
+ - lib/relaton_iho/iho_group.rb
197
198
  - lib/relaton_iho/processor.rb
198
199
  - lib/relaton_iho/version.rb
199
200
  - lib/relaton_iho/xml_parser.rb
@@ -202,7 +203,7 @@ homepage: https://github.com/relaton/relaton-iho
202
203
  licenses:
203
204
  - BSD-2-Clause
204
205
  metadata: {}
205
- post_install_message:
206
+ post_install_message:
206
207
  rdoc_options: []
207
208
  require_paths:
208
209
  - lib
@@ -218,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
219
  version: '0'
219
220
  requirements: []
220
221
  rubygems_version: 3.0.6
221
- signing_key:
222
+ signing_key:
222
223
  specification_version: 4
223
224
  summary: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
224
225
  model'
@@ -1,73 +0,0 @@
1
- require "faraday"
2
- require "yaml"
3
- require "fileutils"
4
-
5
- module RelatonIho
6
- class HitCollection < RelatonBib::HitCollection
7
- ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iho/master/data/".freeze
8
-
9
- # @param ref [Strig]
10
- # @param year [String]
11
- # @param opts [Hash]
12
- def initialize(ref, year = nil)
13
- super
14
- @array = from_yaml(ref).sort_by do |hit|
15
- hit.hit["revdate"] ? Date.parse(hit.hit["revdate"]) : Date.new
16
- end.reverse
17
- end
18
-
19
- private
20
-
21
- #
22
- # Fetch data form yaml
23
- #
24
- # @param docid [String]
25
- def from_yaml(docid, **_opts)
26
- data["root"]["items"].select do |doc|
27
- doc["docid"] && doc["docid"]["id"].include?(docid)
28
- end.map { |h| Hit.new(h, self) }
29
- end
30
-
31
- #
32
- # Fetches YAML data
33
- #
34
- # @return [Hash]
35
- def data
36
- FileUtils.mkdir_p DATADIR
37
- ctime = File.ctime DATAFILE if File.exist? DATAFILE
38
- fetch_data if !ctime || ctime.to_date < Date.today
39
- @data ||= YAML.safe_load File.read(DATAFILE, encoding: "UTF-8")
40
- end
41
-
42
- #
43
- # fetch data form server and save it to file.
44
- #
45
- def fetch_data
46
- resp = Faraday.new(ENDPOINT, headers: { "If-None-Match" => etag }).get
47
- # return if there aren't any changes since last fetching
48
- return unless resp.status == 200
49
-
50
- self.etag = resp[:etag]
51
- @data = YAML.safe_load resp.body
52
- File.write DATAFILE, @data.to_yaml, encoding: "UTF-8"
53
- end
54
-
55
- #
56
- # Read ETag form file
57
- #
58
- # @return [String, NilClass]
59
- def etag
60
- @etag ||= if File.exist? ETAGFILE
61
- File.read ETAGFILE, encoding: "UTF-8"
62
- end
63
- end
64
-
65
- #
66
- # Save ETag to file
67
- #
68
- # @param tag [String]
69
- def etag=(e_tag)
70
- File.write ETAGFILE, e_tag, encoding: "UTF-8"
71
- end
72
- end
73
- end