elasticgraph-support 0.18.0.0 → 0.18.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/elasticgraph-support.gemspec +8 -1
- data/lib/elastic_graph/support/hash_util.rb +37 -0
- data/lib/elastic_graph/version.rb +1 -1
- metadata +40 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c2c34936320b3d9973d7222606560fb4cc550d30e0dcee224158ddeee2fcd90
|
4
|
+
data.tar.gz: 61a36d430507c160ef6044c4e7b11856aa48e6a3f2b883e6da3b1ff4eb129f50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49964720179d4bcea673ab62eb317d69750fba06574091dcd8ad85ca8788b357ed5520fbf8ccab13e66f364f76774aab6c7f167e2df590865397372d6dd4a05b
|
7
|
+
data.tar.gz: e3ef4adc73cd9db165d8f69c703fbf4051a7c92ccd0826e2e7110420975ba6f9dc52d04c14d70eb90938b2265abc6007c8637f76a09d55874c3a80d6b6cf4c23
|
data/README.md
CHANGED
@@ -3,4 +3,5 @@
|
|
3
3
|
This gem provides support utilities for the rest of the ElasticGraph gems. As
|
4
4
|
such, it is not intended to provide any public APIs for ElasticGraph users.
|
5
5
|
|
6
|
-
Importantly, it is intended to have
|
6
|
+
Importantly, it is intended to have as few dependencies as possible: it currently
|
7
|
+
only depends on `logger` (which originated in the Ruby standard library).
|
@@ -11,6 +11,13 @@ require_relative "../gemspec_helper"
|
|
11
11
|
ElasticGraphGemspecHelper.define_elasticgraph_gem(gemspec_file: __FILE__, category: :core) do |spec, eg_version|
|
12
12
|
spec.summary = "ElasticGraph gem providing support utilities to the other ElasticGraph gems."
|
13
13
|
|
14
|
-
|
14
|
+
# Ruby 3.4 warns about using `logger` being moved out of the standard library, and in Ruby 3.5
|
15
|
+
# it'll no longer be available without declaring a dependency.
|
16
|
+
#
|
17
|
+
# Note: Logger 1.6.0 has an issue that impacts our ElasticGraph lambdas, but 1.6.1 avoids the issue:
|
18
|
+
# https://github.com/aws/aws-lambda-ruby-runtime-interface-client/issues/33
|
19
|
+
spec.add_dependency "logger", "~> 1.6", ">= 1.6.1"
|
20
|
+
|
21
|
+
spec.add_development_dependency "faraday", "~> 2.11"
|
15
22
|
spec.add_development_dependency "rake", "~> 13.2"
|
16
23
|
end
|
@@ -9,6 +9,43 @@
|
|
9
9
|
module ElasticGraph
|
10
10
|
module Support
|
11
11
|
class HashUtil
|
12
|
+
# Fetches a key from a hash (just like `Hash#fetch`) but with a more verbose error message when the key is not found.
|
13
|
+
# The error message indicates the available keys unlike `Hash#fetch`.
|
14
|
+
def self.verbose_fetch(hash, key)
|
15
|
+
hash.fetch(key) do
|
16
|
+
raise ::KeyError, "key not found: #{key.inspect}. Available keys: #{hash.keys.inspect}."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Like `Hash#to_h`, but strict. When the given input has conflicting keys, `Hash#to_h` will happily let
|
21
|
+
# the last pair when. This method instead raises an exception.
|
22
|
+
def self.strict_to_h(pairs)
|
23
|
+
hash = pairs.to_h
|
24
|
+
|
25
|
+
if hash.size < pairs.size
|
26
|
+
conflicting_keys = pairs.map(&:first).tally.filter_map { |key, count| key if count > 1 }
|
27
|
+
raise ::KeyError, "Cannot build a strict hash, since input has conflicting keys: #{conflicting_keys.inspect}."
|
28
|
+
end
|
29
|
+
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
|
33
|
+
# Like `Hash#merge`, but verifies that the hashes were strictly disjoint (e.g. had no keys in common).
|
34
|
+
# An error is raised if they do have any keys in common.
|
35
|
+
def self.disjoint_merge(hash1, hash2)
|
36
|
+
conflicting_keys = [] # : ::Array[untyped]
|
37
|
+
merged = hash1.merge(hash2) do |key, v1, _v2|
|
38
|
+
conflicting_keys << key
|
39
|
+
v1
|
40
|
+
end
|
41
|
+
|
42
|
+
unless conflicting_keys.empty?
|
43
|
+
raise ::KeyError, "Hashes were not disjoint. Conflicting keys: #{conflicting_keys.inspect}."
|
44
|
+
end
|
45
|
+
|
46
|
+
merged
|
47
|
+
end
|
48
|
+
|
12
49
|
# Recursively transforms any hash keys in the given object to string keys, without
|
13
50
|
# mutating the provided argument.
|
14
51
|
def self.stringify_keys(object)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticgraph-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.0.
|
4
|
+
version: 0.18.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop-factory_bot
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.40.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.40.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: steep
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,22 +98,22 @@ dependencies:
|
|
98
98
|
name: flatware-rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.3
|
104
|
-
- - "
|
103
|
+
version: '2.3'
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 2.3.3
|
107
107
|
type: :development
|
108
108
|
prerelease: false
|
109
109
|
version_requirements: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- - "
|
111
|
+
- - "~>"
|
112
112
|
- !ruby/object:Gem::Version
|
113
|
-
version: 2.3
|
114
|
-
- - "
|
113
|
+
version: '2.3'
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
116
|
+
version: 2.3.3
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: rspec
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,16 +132,16 @@ dependencies:
|
|
132
132
|
name: super_diff
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
|
-
- - "
|
135
|
+
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.12
|
137
|
+
version: '0.12'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- - "
|
142
|
+
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.12
|
144
|
+
version: '0.12'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: simplecov
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,36 +160,50 @@ dependencies:
|
|
160
160
|
name: simplecov-console
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - "
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 0.9.1
|
166
|
-
- - "<"
|
163
|
+
- - "~>"
|
167
164
|
- !ruby/object:Gem::Version
|
168
|
-
version: '
|
165
|
+
version: '0.9'
|
169
166
|
type: :development
|
170
167
|
prerelease: false
|
171
168
|
version_requirements: !ruby/object:Gem::Requirement
|
172
169
|
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.9'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: logger
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '1.6'
|
173
180
|
- - ">="
|
174
181
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
176
|
-
|
182
|
+
version: 1.6.1
|
183
|
+
type: :runtime
|
184
|
+
prerelease: false
|
185
|
+
version_requirements: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '1.6'
|
190
|
+
- - ">="
|
177
191
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
192
|
+
version: 1.6.1
|
179
193
|
- !ruby/object:Gem::Dependency
|
180
194
|
name: faraday
|
181
195
|
requirement: !ruby/object:Gem::Requirement
|
182
196
|
requirements:
|
183
197
|
- - "~>"
|
184
198
|
- !ruby/object:Gem::Version
|
185
|
-
version: '2.
|
199
|
+
version: '2.11'
|
186
200
|
type: :development
|
187
201
|
prerelease: false
|
188
202
|
version_requirements: !ruby/object:Gem::Requirement
|
189
203
|
requirements:
|
190
204
|
- - "~>"
|
191
205
|
- !ruby/object:Gem::Version
|
192
|
-
version: '2.
|
206
|
+
version: '2.11'
|
193
207
|
- !ruby/object:Gem::Dependency
|
194
208
|
name: rake
|
195
209
|
requirement: !ruby/object:Gem::Requirement
|