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: 9c2889e6d995ae69c8aaf59df34b2a4c8ca5c7700be4e7f31f5ae27411469afd
4
- data.tar.gz: 9c27f57bd7cd0824fcbfbd4acc6cd6921f7c7cf0bd2594a4032406ccd037d406
3
+ metadata.gz: 91019ca7dda0ba25033d364e181586a7a116e8fbac770270cba721c96a2541da
4
+ data.tar.gz: 364f59c8de9c03dea313fab24aca6535b68d05bc4e15803bff27ea59a3306e41
5
5
  SHA512:
6
- metadata.gz: b73ac143dab2eff7e69440608d2373b0f62cfe059cebcf0a1fab47a2d395dd8fd6b3fd22ba5f3124293cd14f8d4e7382795e65a0c3135e0ea7fe407636af7503
7
- data.tar.gz: e25a2f287db40dfc99a305358134b3dfd87afe2aa3a500c103f2de8f97e6ae4093b8aa3b1843a1cf253c073cb5bc8ca9d6b1f5002b11b711eb313ac15c4b43b4
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 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.5.pre".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.5.pre"
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.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-09-18 00:00:00.000000000 Z
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.4.0
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.4.0
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: '0'
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