relaton-iho 1.3.2 → 1.6.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: 7898af6b5b9c984bcb5888c925df80918f797b3ded43f86ad41e749ebd45b50b
4
- data.tar.gz: b1af3d18334b55e941c18c79cf6e3b060b1ac3ecc6c2f0a82757bf4c0e5df05d
3
+ metadata.gz: e8d151683ce6fe8bff93b6cc28a70324c4c69a8352cdfb71288f5ce8e596fed7
4
+ data.tar.gz: e0d3504f2ac5a4b179e704bae5387db2db153f91d9d476739c5cbede50cced8f
5
5
  SHA512:
6
- metadata.gz: 4eb5ce96479f46296bd0c67294d06e1efb646296051ed4e013ba3ce42eddeaa1ba081a0fce26787d02c3fe4157263d29cc0c81adc4150e8214b7d807f6c95de9
7
- data.tar.gz: d840e8461f613ba954bba1719519d7df704ef73e18cfaeb75648a3216893146f67256296b91e8e7046be7968d2d373581be3366d725255ccc584ee586dd737fb
6
+ metadata.gz: 6a240acc120cb59c70bfa6e51191d901055592fefb04ea280160c749ea60d65f0de1449e8a62498ba9eab1784ae26903895f7574968d87f3362d23cad991ad4c
7
+ data.tar.gz: b20879fb27f85a8abdf6448c0334daa70ff3de5b785f5f4d3f678440e04a0a33662500beda3f8246cc6ad9f5d3eb0679a3293943f41e2bc9a5b132c7ed208a0c
@@ -26,6 +26,8 @@ jobs:
26
26
  - name: Update gems
27
27
  run: |
28
28
  sudo gem install bundler --force
29
+ ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
30
+ ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
29
31
  bundle install --jobs 4 --retry 3
30
32
  - name: Run specs
31
33
  run: |
@@ -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
@@ -148,6 +148,13 @@
148
148
  </define>
149
149
  <define name="iho-standard">
150
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>
151
158
  <ref name="bibdata"/>
152
159
  <zeroOrMore>
153
160
  <ref name="termdocsource"/>
@@ -42,7 +42,6 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
45
  <attribute name="target">
47
46
  <data type="string">
48
47
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -64,6 +63,11 @@
64
63
  </choice>
65
64
  </attribute>
66
65
  </optional>
66
+ <optional>
67
+ <attribute name="droploc">
68
+ <data type="boolean"/>
69
+ </attribute>
70
+ </optional>
67
71
  <text/>
68
72
  </element>
69
73
  </define>
@@ -581,6 +585,8 @@
581
585
  <ref name="ol"/>
582
586
  <ref name="dl"/>
583
587
  <ref name="formula"/>
588
+ <ref name="quote"/>
589
+ <ref name="sourcecode"/>
584
590
  </choice>
585
591
  </oneOrMore>
586
592
  </element>
@@ -664,6 +670,16 @@
664
670
  </choice>
665
671
  </attribute>
666
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>
667
683
  <choice>
668
684
  <zeroOrMore>
669
685
  <choice>
@@ -700,6 +716,16 @@
700
716
  </choice>
701
717
  </attribute>
702
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>
703
729
  <choice>
704
730
  <zeroOrMore>
705
731
  <choice>
@@ -837,6 +863,13 @@
837
863
  </define>
838
864
  <define name="standard-document">
839
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>
840
873
  <ref name="bibdata"/>
841
874
  <optional>
842
875
  <ref name="boilerplate"/>
@@ -858,7 +891,7 @@
858
891
  <oneOrMore>
859
892
  <choice>
860
893
  <ref name="content"/>
861
- <ref name="preface_abstract"/>
894
+ <ref name="abstract"/>
862
895
  <ref name="foreword"/>
863
896
  <ref name="introduction"/>
864
897
  <ref name="acknowledgements"/>
@@ -1052,14 +1085,17 @@
1052
1085
  <ref name="section-title"/>
1053
1086
  </optional>
1054
1087
  <group>
1055
- <group>
1056
- <zeroOrMore>
1057
- <ref name="BasicBlock"/>
1058
- </zeroOrMore>
1059
- <zeroOrMore>
1060
- <ref name="note"/>
1061
- </zeroOrMore>
1062
- </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>
1063
1099
  <zeroOrMore>
1064
1100
  <choice>
1065
1101
  <ref name="clause-subsection"/>
@@ -1456,11 +1492,6 @@
1456
1492
  </optional>
1457
1493
  </element>
1458
1494
  </define>
1459
- <define name="preface_abstract">
1460
- <element name="abstract">
1461
- <ref name="Basic-Section"/>
1462
- </element>
1463
- </define>
1464
1495
  <define name="term-clause">
1465
1496
  <element name="clause">
1466
1497
  <optional>
@@ -1510,4 +1541,79 @@
1510
1541
  <ref name="CitationType"/>
1511
1542
  </element>
1512
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>
1513
1619
  </grammar>
@@ -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])
@@ -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, Metrics/PerceivedComplexity
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
@@ -10,7 +10,7 @@ module RelatonIho
10
10
  # @return [RelatonIho::IhoBibliographicItem]
11
11
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
12
  warn "[relaton-iho] (\"#{text}\") fetching..."
13
- ref = text.sub(/^IHO\s/, "").downcase
13
+ ref = text.sub(/^IHO\s/, "").downcase.sub /^([[:alpha:]]+)(\d+)/, '\1-\2'
14
14
  uri = URI("#{ENDPOINT}#{ref}.yaml")
15
15
  resp = Net::HTTP.get_response uri
16
16
  return unless resp.code == "200"
@@ -21,7 +21,7 @@ module RelatonIho
21
21
  item
22
22
  rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
23
23
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
24
- Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
24
+ Net::ProtocolError, Net::ReadTimeout, # OpenSSL::SSL::SSLError,
25
25
  Errno::ETIMEDOUT => e
26
26
  raise RelatonBib::RequestError, "Could not access #{uri}: #{e.message}"
27
27
  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.2".freeze
2
+ VERSION = "1.6.0".freeze
3
3
  end
@@ -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.6.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.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-11-13 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.6.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.6.0
167
167
  description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
168
168
  model'
169
169
  email:
@@ -192,7 +192,6 @@ files:
192
192
  - lib/relaton_iho/editorial_group.rb
193
193
  - lib/relaton_iho/eg.yml
194
194
  - lib/relaton_iho/hash_converter.rb
195
- - lib/relaton_iho/hit_collection.rb
196
195
  - lib/relaton_iho/iho_bibliographic_item.rb
197
196
  - lib/relaton_iho/iho_bibliography.rb
198
197
  - lib/relaton_iho/iho_group.rb
@@ -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