relaton-iho 1.13.0 → 1.14.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,11 +13,20 @@ module RelatonIho
13
13
  super
14
14
  end
15
15
 
16
+ #
17
+ # Fetch flavor schema version
18
+ #
19
+ # @return [String] flavor schema version
20
+ #
21
+ def ext_schema
22
+ @ext_schema ||= schema_versions["relaton-model-iho"]
23
+ end
24
+
16
25
  # @param hash [Hash]
17
26
  # @return [RelatonIho::IhoBibliographicItem]
18
27
  def self.from_hash(hash)
19
28
  item_hash = ::RelatonIho::HashConverter.hash_to_bib(hash)
20
- new **item_hash
29
+ new(**item_hash)
21
30
  end
22
31
 
23
32
  # @param opts [Hash]
@@ -29,12 +38,13 @@ module RelatonIho
29
38
  super ext: !commentperiod.nil?, **opts do |b|
30
39
  if opts[:bibdata] && (doctype || editorialgroup&.presence? ||
31
40
  ics.any? || commentperiod)
32
- b.ext do
41
+ ext = b.ext do
33
42
  b.doctype doctype if doctype
34
43
  editorialgroup&.to_xml b
35
44
  ics.each { |i| i.to_xml b }
36
45
  commentperiod&.to_xml b
37
46
  end
47
+ ext["schema-version"] = ext_schema unless opts[:embedded]
38
48
  end
39
49
  end
40
50
  end
@@ -2,25 +2,31 @@ require "net/http"
2
2
 
3
3
  module RelatonIho
4
4
  class IhoBibliography
5
- ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iho/"\
6
- "master/data/".freeze
5
+ ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iho/" \
6
+ "master/".freeze
7
7
 
8
8
  class << self
9
- # @param text [String]
10
- # @return [RelatonIho::IhoBibliographicItem]
9
+ #
10
+ # Search for IHO standard by IHO standard Code
11
+ #
12
+ # @param text [String] the IHO standard Code to look up (e..g "IHO B-11")
13
+ #
14
+ # @return [RelatonIho::IhoBibliographicItem, nil] the IHO standard or nil if not found
15
+ #
11
16
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
17
  warn "[relaton-iho] (\"#{text}\") fetching..."
13
- ref = text.sub(/^IHO\s/, "").downcase.sub(/^([[:alpha:]]+)(\d+)/, '\1-\2')
14
- uri = URI("#{ENDPOINT}#{ref}.yaml")
18
+ ref = text.sub(/^IHO\s/, "").sub(/^([[:alpha:]]+)(\d+)/, '\1-\2')
19
+ index = Relaton::Index.find_or_create :IHO, url: "#{ENDPOINT}index.zip"
20
+ row = index.search(ref).first
21
+ return unless row
22
+
23
+ uri = URI("#{ENDPOINT}#{row[:file]}")
15
24
  resp = Net::HTTP.get_response uri
16
25
  return unless resp.code == "200"
17
26
 
18
- yaml = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("3.1.0.pre1")
19
- YAML.safe_load(resp.body, permitted_classes: [Date])
20
- else
21
- YAML.safe_load(resp.body, [Date])
22
- end
27
+ yaml = RelatonBib.parse_yaml resp.body, [Date]
23
28
  hash = HashConverter.hash_to_bib yaml
29
+ hash[:fetched] = Date.today.to_s
24
30
  item = IhoBibliographicItem.new(**hash)
25
31
  warn "[relaton-iho] (\"#{text}\") found #{item.docidentifier.first.id}"
26
32
  item
@@ -1,3 +1,3 @@
1
1
  module RelatonIho
2
- VERSION = "1.13.0".freeze
2
+ VERSION = "1.14.1".freeze
3
3
  end
data/lib/relaton_iho.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "digest/md5"
2
2
  require "yaml"
3
3
  require "relaton_bib"
4
+ require "relaton/index"
4
5
  require "relaton_iho/version"
5
6
  require "relaton_iho/iho_bibliography"
6
7
  require "relaton_iho/hash_converter"
data/relaton_iho.gemspec CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
9
9
  s.email = ["open.source@ribose.com"]
10
10
  s.homepage = "https://github.com/relaton/relaton-iho"
11
11
  s.licenses = "BSD-2-Clause"
12
- s.summary = "RelatonIho: retrieve IHO Standards for bibliographic "\
12
+ s.summary = "RelatonIho: retrieve IHO Standards for bibliographic " \
13
13
  "using the BibliographicItem model"
14
- s.description = "RelatonIho: retrieve IHO Standards for bibliographic "\
14
+ s.description = "RelatonIho: retrieve IHO Standards for bibliographic " \
15
15
  "using the BibliographicItem model"
16
16
 
17
17
  s.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -21,14 +21,10 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = ["lib"]
22
22
  s.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
23
23
 
24
- s.add_development_dependency "byebug"
25
24
  s.add_development_dependency "equivalent-xml", "~> 0.6"
26
25
  s.add_development_dependency "rake", "~> 13.0"
27
26
  s.add_development_dependency "rspec", "~> 3.0"
28
- s.add_development_dependency "ruby-jing"
29
- s.add_development_dependency "simplecov"
30
- s.add_development_dependency "vcr"
31
- s.add_development_dependency "webmock"
32
27
 
33
- s.add_dependency "relaton-bib", "~> 1.13.0"
28
+ s.add_dependency "relaton-bib", "~> 1.14.0"
29
+ s.add_dependency "relaton-index", "~> 0.1.0"
34
30
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-21 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: byebug
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: equivalent-xml
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -67,75 +53,33 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '3.0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: ruby-jing
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: simplecov
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: vcr
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: webmock
56
+ name: relaton-bib
113
57
  requirement: !ruby/object:Gem::Requirement
114
58
  requirements:
115
- - - ">="
59
+ - - "~>"
116
60
  - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
61
+ version: 1.14.0
62
+ type: :runtime
119
63
  prerelease: false
120
64
  version_requirements: !ruby/object:Gem::Requirement
121
65
  requirements:
122
- - - ">="
66
+ - - "~>"
123
67
  - !ruby/object:Gem::Version
124
- version: '0'
68
+ version: 1.14.0
125
69
  - !ruby/object:Gem::Dependency
126
- name: relaton-bib
70
+ name: relaton-index
127
71
  requirement: !ruby/object:Gem::Requirement
128
72
  requirements:
129
73
  - - "~>"
130
74
  - !ruby/object:Gem::Version
131
- version: 1.13.0
75
+ version: 0.1.0
132
76
  type: :runtime
133
77
  prerelease: false
134
78
  version_requirements: !ruby/object:Gem::Requirement
135
79
  requirements:
136
80
  - - "~>"
137
81
  - !ruby/object:Gem::Version
138
- version: 1.13.0
82
+ version: 0.1.0
139
83
  description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
140
84
  model'
141
85
  email:
@@ -145,6 +89,7 @@ extensions: []
145
89
  extra_rdoc_files: []
146
90
  files:
147
91
  - ".github/workflows/rake.yml"
92
+ - ".github/workflows/release.yml"
148
93
  - ".gitignore"
149
94
  - ".rspec"
150
95
  - ".rubocop.yml"
@@ -153,10 +98,10 @@ files:
153
98
  - Rakefile
154
99
  - bin/rspec
155
100
  - grammars/basicdoc.rng
101
+ - grammars/biblio-standoc.rng
156
102
  - grammars/biblio.rng
157
- - grammars/iho.rng
158
- - grammars/isodoc.rng
159
- - grammars/reqt.rng
103
+ - grammars/relaton-iho-compile.rng
104
+ - grammars/relaton-iho.rng
160
105
  - lib/relaton_iho.rb
161
106
  - lib/relaton_iho/comment_periond.rb
162
107
  - lib/relaton_iho/editorial_group.rb
@@ -173,7 +118,7 @@ homepage: https://github.com/relaton/relaton-iho
173
118
  licenses:
174
119
  - BSD-2-Clause
175
120
  metadata: {}
176
- post_install_message:
121
+ post_install_message:
177
122
  rdoc_options: []
178
123
  require_paths:
179
124
  - lib
@@ -188,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
133
  - !ruby/object:Gem::Version
189
134
  version: '0'
190
135
  requirements: []
191
- rubygems_version: 3.2.3
192
- signing_key:
136
+ rubygems_version: 3.1.6
137
+ signing_key:
193
138
  specification_version: 4
194
139
  summary: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
195
140
  model'
data/grammars/iho.rng DELETED
@@ -1,179 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!--
4
- Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
5
- we cannot have a new default namespace: we will end up with a grammar with two different
6
- namespaces, one for isostandard and one for csand additions. And we do not want that.
7
- -->
8
- <include href="isodoc.rng">
9
- <start>
10
- <ref name="iho-standard"/>
11
- </start>
12
- <define name="DocumentType">
13
- <choice>
14
- <value>policy-and-procedures</value>
15
- <value>best-practices</value>
16
- <value>supporting-document</value>
17
- <value>report</value>
18
- <value>legal</value>
19
- <value>directives</value>
20
- <value>proposal</value>
21
- <value>standard</value>
22
- </choice>
23
- </define>
24
- <define name="editorialgroup">
25
- <element name="editorialgroup">
26
- <oneOrMore>
27
- <choice>
28
- <ref name="committee"/>
29
- <ref name="workgroup"/>
30
- <ref name="commission"/>
31
- </choice>
32
- </oneOrMore>
33
- </element>
34
- </define>
35
- <define name="BibDataExtensionType">
36
- <optional>
37
- <ref name="doctype"/>
38
- </optional>
39
- <optional>
40
- <ref name="docsubtype"/>
41
- </optional>
42
- <zeroOrMore>
43
- <ref name="editorialgroup"/>
44
- </zeroOrMore>
45
- <zeroOrMore>
46
- <ref name="ics"/>
47
- </zeroOrMore>
48
- <optional>
49
- <ref name="commentperiod"/>
50
- </optional>
51
- </define>
52
- <define name="annex">
53
- <element name="annex">
54
- <optional>
55
- <attribute name="id">
56
- <data type="ID"/>
57
- </attribute>
58
- </optional>
59
- <optional>
60
- <attribute name="language"/>
61
- </optional>
62
- <optional>
63
- <attribute name="script"/>
64
- </optional>
65
- <optional>
66
- <attribute name="inline-header">
67
- <data type="boolean"/>
68
- </attribute>
69
- </optional>
70
- <attribute name="obligation">
71
- <choice>
72
- <value>normative</value>
73
- <value>informative</value>
74
- </choice>
75
- </attribute>
76
- <optional>
77
- <ref name="section-title"/>
78
- </optional>
79
- <group>
80
- <zeroOrMore>
81
- <ref name="BasicBlock"/>
82
- </zeroOrMore>
83
- <zeroOrMore>
84
- <choice>
85
- <ref name="annex-subsection"/>
86
- <ref name="terms"/>
87
- <ref name="definitions"/>
88
- <ref name="references"/>
89
- </choice>
90
- </zeroOrMore>
91
- </group>
92
- <zeroOrMore>
93
- <ref name="annex-appendix"/>
94
- </zeroOrMore>
95
- </element>
96
- </define>
97
- </include>
98
- <define name="committee">
99
- <element name="committee">
100
- <ref name="IHO_Group"/>
101
- </element>
102
- </define>
103
- <define name="workgroup">
104
- <element name="workgroup">
105
- <ref name="IHO_Group"/>
106
- </element>
107
- </define>
108
- <define name="commission">
109
- <element name="commission">
110
- <ref name="IHO_Group"/>
111
- </element>
112
- </define>
113
- <define name="IHO_Group">
114
- <optional>
115
- <element name="name">
116
- <text/>
117
- </element>
118
- </optional>
119
- <element name="abbreviation">
120
- <text/>
121
- </element>
122
- <optional>
123
- <choice>
124
- <ref name="committee"/>
125
- <ref name="workgroup"/>
126
- <ref name="commission"/>
127
- </choice>
128
- </optional>
129
- </define>
130
- <define name="annex-appendix">
131
- <element name="appendix">
132
- <ref name="Clause-Section"/>
133
- </element>
134
- </define>
135
- <define name="commentperiod">
136
- <element name="commentperiod">
137
- <element name="from">
138
- <ref name="ISO8601Date"/>
139
- </element>
140
- <optional>
141
- <element name="to">
142
- <ref name="ISO8601Date"/>
143
- </element>
144
- </optional>
145
- </element>
146
- </define>
147
- <define name="iho-standard">
148
- <element name="iho-standard">
149
- <attribute name="version"/>
150
- <attribute name="type">
151
- <choice>
152
- <value>semantic</value>
153
- <value>presentation</value>
154
- </choice>
155
- </attribute>
156
- <ref name="bibdata"/>
157
- <zeroOrMore>
158
- <ref name="termdocsource"/>
159
- </zeroOrMore>
160
- <optional>
161
- <ref name="misccontainer"/>
162
- </optional>
163
- <optional>
164
- <ref name="boilerplate"/>
165
- </optional>
166
- <ref name="preface"/>
167
- <oneOrMore>
168
- <ref name="sections"/>
169
- </oneOrMore>
170
- <zeroOrMore>
171
- <ref name="annex"/>
172
- </zeroOrMore>
173
- <ref name="bibliography"/>
174
- <zeroOrMore>
175
- <ref name="indexsect"/>
176
- </zeroOrMore>
177
- </element>
178
- </define>
179
- </grammar>