relaton-iho 1.7.1 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/reqt.rng CHANGED
@@ -30,9 +30,22 @@
30
30
  <data type="boolean"/>
31
31
  </attribute>
32
32
  </optional>
33
+ <optional>
34
+ <attribute name="number"/>
35
+ </optional>
33
36
  <optional>
34
37
  <attribute name="subsequence"/>
35
38
  </optional>
39
+ <optional>
40
+ <attribute name="keep-with-next">
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ <optional>
45
+ <attribute name="keep-lines-together">
46
+ <data type="boolean"/>
47
+ </attribute>
48
+ </optional>
36
49
  <attribute name="id">
37
50
  <data type="ID"/>
38
51
  </attribute>
@@ -40,17 +53,23 @@
40
53
  <attribute name="filename"/>
41
54
  </optional>
42
55
  <optional>
43
- <ref name="reqtitle"/>
56
+ <attribute name="model"/>
44
57
  </optional>
45
58
  <optional>
46
- <ref name="label"/>
59
+ <attribute name="type"/>
47
60
  </optional>
48
61
  <optional>
49
- <ref name="subject"/>
62
+ <ref name="reqtitle"/>
50
63
  </optional>
51
64
  <optional>
52
- <ref name="reqinherit"/>
65
+ <ref name="label"/>
53
66
  </optional>
67
+ <zeroOrMore>
68
+ <ref name="subject"/>
69
+ </zeroOrMore>
70
+ <zeroOrMore>
71
+ <ref name="reqinherit"/>
72
+ </zeroOrMore>
54
73
  <zeroOrMore>
55
74
  <ref name="classification"/>
56
75
  </zeroOrMore>
@@ -61,6 +80,7 @@
61
80
  <ref name="verification"/>
62
81
  <ref name="import"/>
63
82
  <ref name="description"/>
83
+ <ref name="component"/>
64
84
  </choice>
65
85
  </zeroOrMore>
66
86
  <optional>
@@ -86,12 +106,16 @@
86
106
  </define>
87
107
  <define name="subject">
88
108
  <element name="subject">
89
- <text/>
109
+ <oneOrMore>
110
+ <ref name="TextElement"/>
111
+ </oneOrMore>
90
112
  </element>
91
113
  </define>
92
114
  <define name="reqinherit">
93
115
  <element name="inherit">
94
- <text/>
116
+ <oneOrMore>
117
+ <ref name="TextElement"/>
118
+ </oneOrMore>
95
119
  </element>
96
120
  </define>
97
121
  <define name="measurementtarget">
@@ -119,6 +143,12 @@
119
143
  <ref name="RequirementSubpart"/>
120
144
  </element>
121
145
  </define>
146
+ <define name="component">
147
+ <element name="component">
148
+ <attribute name="class"/>
149
+ <ref name="RequirementSubpart"/>
150
+ </element>
151
+ </define>
122
152
  <define name="reqt_references">
123
153
  <element name="references">
124
154
  <oneOrMore>
@@ -135,6 +165,16 @@
135
165
  <data type="boolean"/>
136
166
  </attribute>
137
167
  </optional>
168
+ <optional>
169
+ <attribute name="keep-with-next">
170
+ <data type="boolean"/>
171
+ </attribute>
172
+ </optional>
173
+ <optional>
174
+ <attribute name="keep-lines-together">
175
+ <data type="boolean"/>
176
+ </attribute>
177
+ </optional>
138
178
  <oneOrMore>
139
179
  <ref name="BasicBlock"/>
140
180
  </oneOrMore>
@@ -13,6 +13,13 @@ module RelatonIho
13
13
  super
14
14
  end
15
15
 
16
+ # @param hash [Hash]
17
+ # @return [RelatonIho::IhoBibliographicItem]
18
+ def self.from_hash(hash)
19
+ item_hash = ::RelatonIho::HashConverter.hash_to_bib(hash)
20
+ new **item_hash
21
+ end
22
+
16
23
  # @param opts [Hash]
17
24
  # @option opts [Nokogiri::XML::Builder] :builder XML builder
18
25
  # @option opts [Boolean] :bibdata
@@ -10,18 +10,23 @@ 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.sub /^([[:alpha:]]+)(\d+)/, '\1-\2'
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"
17
17
 
18
- hash = HashConverter.hash_to_bib YAML.safe_load(resp.body, [Date])
19
- item = IhoBibliographicItem.new **hash
18
+ yaml = if RUBY_VERSION.match?(/^2\.5/)
19
+ YAML.safe_load(resp.body, [Date])
20
+ else
21
+ YAML.safe_load(resp.body, permitted_classes: [Date])
22
+ end
23
+ hash = HashConverter.hash_to_bib yaml
24
+ item = IhoBibliographicItem.new(**hash)
20
25
  warn "[relaton-iho] (\"#{text}\") found #{item.docidentifier.first.id}"
21
26
  item
22
27
  rescue SocketError, Errno::EINVAL, Errno::ECONNRESET, EOFError,
23
28
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
24
- Net::ProtocolError, Net::ReadTimeout, # OpenSSL::SSL::SSLError,
29
+ Net::ProtocolError, Net::ReadTimeout, OpenSSL::SSL::SSLError,
25
30
  Errno::ETIMEDOUT => e
26
31
  raise RelatonBib::RequestError, "Could not access #{uri}: #{e.message}"
27
32
  end
@@ -28,8 +28,7 @@ module RelatonIho
28
28
  # @param hash [Hash]
29
29
  # @return [RelatonIho::IhoBibliographicItem]
30
30
  def hash_to_bib(hash)
31
- item_hash = ::RelatonIho::HashConverter.hash_to_bib(hash)
32
- ::RelatonIho::IhoBibliographicItem.new item_hash
31
+ ::RelatonIho::IhoBibliographicItem.new hash
33
32
  end
34
33
 
35
34
  # Returns hash of XML grammar
@@ -1,3 +1,3 @@
1
1
  module RelatonIho
2
- VERSION = "1.7.1".freeze
2
+ VERSION = "1.10.0".freeze
3
3
  end
@@ -18,7 +18,7 @@ module RelatonIho
18
18
  # @param item_hash [Hash]
19
19
  # @return [RelatonIho::IhoBibliographicItem]
20
20
  def bib_item(item_hash)
21
- IhoBibliographicItem.new **item_hash
21
+ IhoBibliographicItem.new(**item_hash)
22
22
  end
23
23
 
24
24
  # @param ext [Nokogiri::XML::Element, nil]
data/lib/relaton_iho.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "digest/md5"
2
+ require "yaml"
2
3
  require "relaton_bib"
3
4
  require "relaton_iho/version"
4
5
  require "relaton_iho/iho_bibliography"
data/relaton_iho.gemspec CHANGED
@@ -19,18 +19,16 @@ Gem::Specification.new do |s|
19
19
  end
20
20
  s.platform = Gem::Platform::RUBY
21
21
  s.require_paths = ["lib"]
22
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
22
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
23
23
 
24
24
  s.add_development_dependency "byebug"
25
- # s.add_development_dependency "debase"
26
25
  s.add_development_dependency "equivalent-xml", "~> 0.6"
27
- s.add_development_dependency "rake", "~> 10.0"
26
+ s.add_development_dependency "rake", "~> 13.0"
28
27
  s.add_development_dependency "rspec", "~> 3.0"
29
- # s.add_development_dependency "ruby-debug-ide"
30
28
  s.add_development_dependency "ruby-jing"
31
29
  s.add_development_dependency "simplecov"
32
30
  s.add_development_dependency "vcr"
33
31
  s.add_development_dependency "webmock"
34
32
 
35
- s.add_dependency "relaton-bib", "~> 1.7.0"
33
+ s.add_dependency "relaton-bib", "~> 1.10.0"
36
34
  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.7.1
4
+ version: 1.10.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: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.7.0
131
+ version: 1.10.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.7.0
138
+ version: 1.10.0
139
139
  description: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem
140
140
  model'
141
141
  email:
@@ -181,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  requirements:
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.4.0
184
+ version: 2.5.0
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements:
187
187
  - - ">="
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.0.6
191
+ rubygems_version: 3.2.3
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: 'RelatonIho: retrieve IHO Standards for bibliographic using the BibliographicItem