relaton-iho 1.4.0 → 1.7.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 +4 -4
- data/.github/workflows/macos.yml +2 -0
- data/grammars/iho.rng +7 -0
- data/grammars/isodoc.rng +21 -44
- data/lib/relaton_iho/hash_converter.rb +6 -0
- data/lib/relaton_iho/iho_bibliographic_item.rb +7 -5
- data/lib/relaton_iho/processor.rb +1 -1
- data/lib/relaton_iho/version.rb +1 -1
- data/relaton_iho.gemspec +1 -1
- metadata +4 -5
- data/lib/relaton_iho/hit_collection.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a912d46e4d8722af0143176f796d9ee60169b9e7c02c9e8323cb4b578ea719
|
4
|
+
data.tar.gz: f0868b0fd1b521f2850fd635457bca2270b5c964cea068516e29801bb30ca33f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85ae6ce05130d766e3674aa146ebf0ac21d46c3f80c53b73b3ebf6dd9b2b7a6da958853bb3ec505e376a91ec2e651f6e9933fc5d974e44e45e4aa6175f715ee4
|
7
|
+
data.tar.gz: 71eda4d452890bcc9168a0f1af9f874f32c1f536fd6cebbb85a1580ae6953de78ff067737964c09c90ff41bcdc544771de4c1e6687912d7be38381bba6e777cd
|
data/.github/workflows/macos.yml
CHANGED
@@ -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: |
|
data/grammars/iho.rng
CHANGED
@@ -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"/>
|
data/grammars/isodoc.rng
CHANGED
@@ -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
|
-
<
|
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
|
17
|
-
# @
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
data/lib/relaton_iho/version.rb
CHANGED
data/relaton_iho.gemspec
CHANGED
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
|
+
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-
|
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.
|
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.
|
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
|