relaton-index 0.2.17 → 0.2.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 788bf4331c7923b1671faeb8b9655aab2caaa856dcf5f6fb6b9a95a930c9376c
4
- data.tar.gz: 6d6e14df3e79b577e04e654579cdb4fb1c2dfdbe458763de1aabc28ca1d3af84
3
+ metadata.gz: 4a0b0524d3ff48cefa5a45836a1a66752936d4c2f314c7b9a57ce57e66bf1188
4
+ data.tar.gz: a44c2069cead390088f0100ebcd79931fda7acf2c588e725f405af8338ee8d53
5
5
  SHA512:
6
- metadata.gz: f1b8d3dfe3686f754cf65a592daaa6ac475f6370aa0473da8eb77d48f9d53fc6694d0a71cad06a0fe3657829e2fd29d5928ecbaf5bd333547148b8066cb8bbfa
7
- data.tar.gz: d6b868fa97d70774e5fcc865c390dabb64c8321be488c47127278cc33767f5725763e1da67848975a73c9ae539a432d8aa55d29e609c6d95a02e9aec0986bfd2
6
+ metadata.gz: 2259a5c99d9be722cdde9970a9e8f9991ba9b54196e1309116d8cbdacecd02bf61f1cd46d5ec84b49248f7dc3c1b4c1a97d76060176e0da7fee707838a2b5027
7
+ data.tar.gz: 77a0daf08f996acba87a6c177bc04596dc552a1607b14b14edc4964b32280afa89d6bbec6aef501796aae0a5de37cd72d12bff891427f56ea2f96fbf43b4a242
data/.rubocop.yml CHANGED
@@ -7,6 +7,6 @@ require: rubocop-rails
7
7
  inherit_from:
8
8
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
9
  AllCops:
10
- TargetRubyVersion: 2.7
10
+ TargetRubyVersion: 3.1
11
11
  Rails:
12
12
  Enabled: false
@@ -8,6 +8,9 @@ module Relaton
8
8
  class FileIO
9
9
  attr_reader :url, :pubid_class
10
10
 
11
+ @@file_locks = {}
12
+ @@file_locks_mutex = Mutex.new
13
+
11
14
  #
12
15
  # Initialize FileIO
13
16
  #
@@ -39,7 +42,9 @@ module Relaton
39
42
  def read
40
43
  case url
41
44
  when String
42
- check_file || fetch_and_save
45
+ with_file_lock do
46
+ check_file || fetch_and_save
47
+ end
43
48
  else
44
49
  read_file || []
45
50
  end
@@ -146,6 +151,7 @@ module Relaton
146
151
  warn_local_index_error "YAML parsing error when reading"
147
152
  end
148
153
  end
154
+
149
155
  #
150
156
  # Fetch index from external repository and save it to storage
151
157
  #
@@ -159,7 +165,7 @@ module Relaton
159
165
  yaml = entry.get_input_stream.read
160
166
  end
161
167
  Util.info "Downloaded index from `#{url}`", progname
162
- load_index(yaml, save = true)
168
+ load_index(yaml, _save = true)
163
169
  end
164
170
 
165
171
  def warn_remote_index_error(reason)
@@ -176,8 +182,10 @@ module Relaton
176
182
  # @return [void]
177
183
  #
178
184
  def save(index)
179
- Index.config.storage.write file,
180
- index.map { |item| item.transform_values { |value| value.is_a?(Pubid::Core::Identifier::Base) ? value.to_h : value } }.to_yaml
185
+ yaml = index.map do |item|
186
+ item.transform_values { |value| value.is_a?(Pubid::Core::Identifier::Base) ? value.to_h : value }
187
+ end.to_yaml
188
+ Index.config.storage.write file, yaml
181
189
  end
182
190
 
183
191
  #
@@ -189,6 +197,16 @@ module Relaton
189
197
  Index.config.storage.remove file
190
198
  []
191
199
  end
200
+
201
+ private
202
+
203
+ def with_file_lock(&)
204
+ @@file_locks_mutex.synchronize do
205
+ @@file_locks[file] ||= Mutex.new
206
+ end
207
+
208
+ @@file_locks[file].synchronize(&)
209
+ end
192
210
  end
193
211
  end
194
212
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Index
5
- VERSION = "0.2.17"
5
+ VERSION = "0.2.18"
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = "Relaton Index is a library for indexing Relaton files."
12
12
  spec.homepage = "https://github.com/relaton/relaton-index"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.7.0"
14
+ spec.required_ruby_version = ">= 3.1.0"
15
15
 
16
16
  # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
17
 
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
+ spec.add_dependency "openssl", "~> 3.3.2"
33
34
  spec.add_dependency "pubid-core", "~> 1.15.0"
34
35
  spec.add_dependency "relaton-logger", "~> 0.2.0"
35
36
  spec.add_dependency "rubyzip", "~> 2.3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.17
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -9,6 +9,20 @@ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: openssl
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 3.3.2
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 3.3.2
12
26
  - !ruby/object:Gem::Dependency
13
27
  name: pubid-core
14
28
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: 2.7.0
103
+ version: 3.1.0
90
104
  required_rubygems_version: !ruby/object:Gem::Requirement
91
105
  requirements:
92
106
  - - ">="