relaton-iho 1.4.0 → 1.7.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: 9c2889e6d995ae69c8aaf59df34b2a4c8ca5c7700be4e7f31f5ae27411469afd
4
- data.tar.gz: 9c27f57bd7cd0824fcbfbd4acc6cd6921f7c7cf0bd2594a4032406ccd037d406
3
+ metadata.gz: b5a912d46e4d8722af0143176f796d9ee60169b9e7c02c9e8323cb4b578ea719
4
+ data.tar.gz: f0868b0fd1b521f2850fd635457bca2270b5c964cea068516e29801bb30ca33f
5
5
  SHA512:
6
- metadata.gz: b73ac143dab2eff7e69440608d2373b0f62cfe059cebcf0a1fab47a2d395dd8fd6b3fd22ba5f3124293cd14f8d4e7382795e65a0c3135e0ea7fe407636af7503
7
- data.tar.gz: e25a2f287db40dfc99a305358134b3dfd87afe2aa3a500c103f2de8f97e6ae4093b8aa3b1843a1cf253c073cb5bc8ca9d6b1f5002b11b711eb313ac15c4b43b4
6
+ metadata.gz: 85ae6ce05130d766e3674aa146ebf0ac21d46c3f80c53b73b3ebf6dd9b2b7a6da958853bb3ec505e376a91ec2e651f6e9933fc5d974e44e45e4aa6175f715ee4
7
+ data.tar.gz: 71eda4d452890bcc9168a0f1af9f874f32c1f536fd6cebbb85a1580ae6953de78ff067737964c09c90ff41bcdc544771de4c1e6687912d7be38381bba6e777cd
@@ -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: |
@@ -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"/>
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,7 +50,6 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -142,6 +149,11 @@
142
149
  <data type="boolean"/>
143
150
  </attribute>
144
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
145
157
  <oneOrMore>
146
158
  <ref name="dt"/>
147
159
  <ref name="dd"/>
@@ -864,6 +876,13 @@
864
876
  </define>
865
877
  <define name="standard-document">
866
878
  <element name="standard-document">
879
+ <attribute name="version"/>
880
+ <attribute name="type">
881
+ <choice>
882
+ <value>semantic</value>
883
+ <value>presentation</value>
884
+ </choice>
885
+ </attribute>
867
886
  <ref name="bibdata"/>
868
887
  <optional>
869
888
  <ref name="boilerplate"/>
@@ -1158,49 +1177,7 @@
1158
1177
  </define>
1159
1178
  <define name="annex">
1160
1179
  <element name="annex">
1161
- <optional>
1162
- <attribute name="id">
1163
- <data type="ID"/>
1164
- </attribute>
1165
- </optional>
1166
- <optional>
1167
- <attribute name="language"/>
1168
- </optional>
1169
- <optional>
1170
- <attribute name="script"/>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="inline-header">
1174
- <data type="boolean"/>
1175
- </attribute>
1176
- </optional>
1177
- <attribute name="obligation">
1178
- <choice>
1179
- <value>normative</value>
1180
- <value>informative</value>
1181
- </choice>
1182
- </attribute>
1183
- <optional>
1184
- <ref name="section-title"/>
1185
- </optional>
1186
- <group>
1187
- <group>
1188
- <zeroOrMore>
1189
- <ref name="BasicBlock"/>
1190
- </zeroOrMore>
1191
- <zeroOrMore>
1192
- <ref name="note"/>
1193
- </zeroOrMore>
1194
- </group>
1195
- <zeroOrMore>
1196
- <choice>
1197
- <ref name="annex-subsection"/>
1198
- <ref name="terms"/>
1199
- <ref name="definitions"/>
1200
- <ref name="references"/>
1201
- </choice>
1202
- </zeroOrMore>
1203
- </group>
1180
+ <ref name="Annex-Section"/>
1204
1181
  </element>
1205
1182
  </define>
1206
1183
  <define name="terms">
@@ -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
@@ -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.4.0".freeze
2
+ VERSION = "1.7.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.4.0"
35
+ s.add_dependency "relaton-bib", "~> 1.7.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.4.0
4
+ version: 1.7.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-18 00:00:00.000000000 Z
11
+ date: 2020-11-27 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.4.0
159
+ version: 1.7.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.4.0
166
+ version: 1.7.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