relaton-iho 1.4.0 → 1.5.pre
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91019ca7dda0ba25033d364e181586a7a116e8fbac770270cba721c96a2541da
|
4
|
+
data.tar.gz: 364f59c8de9c03dea313fab24aca6535b68d05bc4e15803bff27ea59a3306e41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55157bfc84864465c81ba4287801512f759fe87814e65a84e70d654dfaffc975823e0a1ba9704784d0ae2230d73b613a141df3312b4d90385841de2ef1fff49c
|
7
|
+
data.tar.gz: f2e11fd9f647ded0607c003c19d7b3aa586f33292715d6dc9f88d3bd7f44d379c9f7877c2d87bf8e111822275dcaba15de88c328faeb252c597e88d73d9f279b
|
@@ -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.5.pre
|
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-10-07 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.5.pre
|
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.5.pre
|
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
|
@@ -215,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
214
|
version: 2.4.0
|
216
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
216
|
requirements:
|
218
|
-
- - "
|
217
|
+
- - ">"
|
219
218
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
219
|
+
version: 1.3.1
|
221
220
|
requirements: []
|
222
221
|
rubygems_version: 3.0.6
|
223
222
|
signing_key:
|
@@ -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
|