relaton-iho 1.2.3 → 1.5.pre

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: 8a71904841f99ee9eab8d284e9834870734dbaa46c2dac616f3fd37a64c1dcfd
4
- data.tar.gz: 42ce621872f8df62d1af6faa4eb02237b11f37494b733609b72b80f04e4df54a
3
+ metadata.gz: 91019ca7dda0ba25033d364e181586a7a116e8fbac770270cba721c96a2541da
4
+ data.tar.gz: 364f59c8de9c03dea313fab24aca6535b68d05bc4e15803bff27ea59a3306e41
5
5
  SHA512:
6
- metadata.gz: d3fca909e02416984e999fc122916c143f7a9bcc6fc9d191541983e62b91ddb4212cf28563136b1ba82d53341c8c1465681fe16fd335567fe1ebcd85288c6cc1
7
- data.tar.gz: ef010c3146afc90870fe301e641848b0e37fd959b9dcda4c09ff16e556668f4174add4b0412122c450d1d7f553d05efb9a6926bfb5a3cb0e2bdd2d0cf7e0f97b
6
+ metadata.gz: 55157bfc84864465c81ba4287801512f759fe87814e65a84e70d654dfaffc975823e0a1ba9704784d0ae2230d73b613a141df3312b4d90385841de2ef1fff49c
7
+ data.tar.gz: f2e11fd9f647ded0607c003c19d7b3aa586f33292715d6dc9f88d3bd7f44d379c9f7877c2d87bf8e111822275dcaba15de88c328faeb252c597e88d73d9f279b
@@ -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
@@ -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)
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
@@ -36,5 +38,13 @@ module RelatonIho
36
38
  hash["commentperiod"] = commentperiod.to_hash if commentperiod
37
39
  hash
38
40
  end
41
+
42
+ # @param prefix [String]
43
+ # @return [String]
44
+ def to_asciibib(prefix = "")
45
+ out = super
46
+ out += commentperiod.to_asciibib prefix if commentperiod
47
+ out
48
+ end
39
49
  end
40
50
  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,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.2.3".freeze
2
+ VERSION = "1.5.pre".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.5.pre"
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.3
4
+ version: 1.5.pre
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-08 00:00:00.000000000 Z
11
+ date: 2020-10-07 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.5.pre
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.5.pre
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
@@ -213,12 +214,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
214
  version: 2.4.0
214
215
  required_rubygems_version: !ruby/object:Gem::Requirement
215
216
  requirements:
216
- - - ">="
217
+ - - ">"
217
218
  - !ruby/object:Gem::Version
218
- version: '0'
219
+ version: 1.3.1
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