better_record 0.25.1 → 0.25.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializers/redis_store.rb +2 -2
- data/lib/better_record/version.rb +1 -1
- metadata +39 -20
- data/lib/better_record/fake_redis.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925a6e392a7e09a6a37ac206c21b744ff4302e2230f19fc103cf4dc2034f605b
|
4
|
+
data.tar.gz: 23d59e5cb90a4bd57941cb6098acc0f242b176bb7703418f3484ce6a80699d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08ce52bf923b009a567f52bb4188fb010df8dde927bd88f03b4986d6546c4c3cff2810d6e80f85acc6ef7a8b3e6dfe5795c490ba8f90fa0f71c49a17191f088b'
|
7
|
+
data.tar.gz: 7999a2285c92638ca80f4dcc57529d812ab83855fa364cea859ebb593b3047173db84a7db3677573888c2c07a6a0a05bead706443181b92309d5f01f6e651138
|
@@ -8,9 +8,9 @@ if defined?(Redis) && defined?(Redis::Namespace)
|
|
8
8
|
tmp_rds.get('test')
|
9
9
|
rescue
|
10
10
|
if (!Rails.env.production? && !Boolean.parse(ENV.fetch('FORCE_REDIS') { false })) || Boolean.parse(ENV.fetch('ALLOW_FAKE_REDIS') { false })
|
11
|
-
|
11
|
+
raise unless defined?(TinyFakeRedis)
|
12
12
|
puts "WARNING!!! Redis Server not found"
|
13
|
-
tmp_rds =
|
13
|
+
tmp_rds = TinyFakeRedis.new
|
14
14
|
else
|
15
15
|
raise
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampson Crowley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,22 +114,22 @@ dependencies:
|
|
114
114
|
name: jwt
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- - ">="
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: 2.1.0
|
120
117
|
- - "~>"
|
121
118
|
- !ruby/object:Gem::Version
|
122
119
|
version: '2.1'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.1.0
|
123
123
|
type: :runtime
|
124
124
|
prerelease: false
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- - ">="
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: 2.1.0
|
130
127
|
- - "~>"
|
131
128
|
- !ruby/object:Gem::Version
|
132
129
|
version: '2.1'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.1.0
|
133
133
|
- !ruby/object:Gem::Dependency
|
134
134
|
name: jwe
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,42 +174,62 @@ dependencies:
|
|
174
174
|
name: rspec-rails
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
|
-
- - ">="
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
version: 3.9.0
|
180
177
|
- - "~>"
|
181
178
|
- !ruby/object:Gem::Version
|
182
179
|
version: '3.9'
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: 3.9.0
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
186
186
|
requirements:
|
187
|
+
- - "~>"
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '3.9'
|
187
190
|
- - ">="
|
188
191
|
- !ruby/object:Gem::Version
|
189
192
|
version: 3.9.0
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: tiny_fake_redis
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
190
197
|
- - "~>"
|
191
198
|
- !ruby/object:Gem::Version
|
192
|
-
version: '
|
199
|
+
version: '0.1'
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 0.1.0
|
203
|
+
type: :development
|
204
|
+
prerelease: false
|
205
|
+
version_requirements: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0.1'
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: 0.1.0
|
193
213
|
- !ruby/object:Gem::Dependency
|
194
214
|
name: factory_bot_rails
|
195
215
|
requirement: !ruby/object:Gem::Requirement
|
196
216
|
requirements:
|
197
|
-
- - ">="
|
198
|
-
- !ruby/object:Gem::Version
|
199
|
-
version: 4.10.0
|
200
217
|
- - "~>"
|
201
218
|
- !ruby/object:Gem::Version
|
202
219
|
version: '4.10'
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 4.10.0
|
203
223
|
type: :development
|
204
224
|
prerelease: false
|
205
225
|
version_requirements: !ruby/object:Gem::Requirement
|
206
226
|
requirements:
|
207
|
-
- - ">="
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: 4.10.0
|
210
227
|
- - "~>"
|
211
228
|
- !ruby/object:Gem::Version
|
212
229
|
version: '4.10'
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: 4.10.0
|
213
233
|
description: |2
|
214
234
|
This app extends active record to allow you to change the polymorphic type value in relationships.
|
215
235
|
It also extends active record batching functions to be able to order records while batching.
|
@@ -302,7 +322,6 @@ files:
|
|
302
322
|
- lib/better_record/encoder.rb
|
303
323
|
- lib/better_record/engine.rb
|
304
324
|
- lib/better_record/exchange_rate_integer.rb
|
305
|
-
- lib/better_record/fake_redis.rb
|
306
325
|
- lib/better_record/gender.rb
|
307
326
|
- lib/better_record/inject_methods.rb
|
308
327
|
- lib/better_record/jwt.rb
|
@@ -361,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
361
380
|
- !ruby/object:Gem::Version
|
362
381
|
version: '0'
|
363
382
|
requirements: []
|
364
|
-
rubygems_version: 3.
|
383
|
+
rubygems_version: 3.1.3
|
365
384
|
signing_key:
|
366
385
|
specification_version: 4
|
367
386
|
summary: Fix functions that are lacking in Active record to be compatible with multi-app
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module BetterRecord
|
5
|
-
class FakeRedis
|
6
|
-
def data
|
7
|
-
@data ||= {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def incr(key)
|
11
|
-
data[key] ||= 0
|
12
|
-
data[key] += 1
|
13
|
-
end
|
14
|
-
|
15
|
-
def decr(key)
|
16
|
-
data[key] ||= 0
|
17
|
-
data[key] -= 1
|
18
|
-
end
|
19
|
-
|
20
|
-
def set(key, val)
|
21
|
-
data[key] = val
|
22
|
-
end
|
23
|
-
|
24
|
-
def get(key)
|
25
|
-
data[key].dup
|
26
|
-
end
|
27
|
-
|
28
|
-
def lpush(key, val)
|
29
|
-
require_array
|
30
|
-
data[key].unshift val
|
31
|
-
data[key].size
|
32
|
-
end
|
33
|
-
|
34
|
-
def lrem(key, count, val)
|
35
|
-
require_array
|
36
|
-
start_idx = 0
|
37
|
-
arr = data[key]
|
38
|
-
removed = 0
|
39
|
-
|
40
|
-
if count == 0
|
41
|
-
removed = (arr.select {|v| v != val}).size
|
42
|
-
arr.select! {|v| v != val}
|
43
|
-
else
|
44
|
-
arr.reverse! if count < 0
|
45
|
-
|
46
|
-
count.abs.times do
|
47
|
-
removed += 1 unless arr.delete_at(arr.index(val) || arr.size).nil?
|
48
|
-
end
|
49
|
-
|
50
|
-
arr.reverse! if count < 0
|
51
|
-
end
|
52
|
-
|
53
|
-
data[key] = arr
|
54
|
-
removed
|
55
|
-
end
|
56
|
-
|
57
|
-
def lrange(key, start_idx, end_idx = -1)
|
58
|
-
data[key][start_idx..end_idx] || []
|
59
|
-
end
|
60
|
-
|
61
|
-
def rpush(key, val)
|
62
|
-
require_array
|
63
|
-
data[key] << val
|
64
|
-
data[key].size
|
65
|
-
end
|
66
|
-
|
67
|
-
def rpushx(key, val)
|
68
|
-
return 0 unless data[key]
|
69
|
-
rpush key, val
|
70
|
-
end
|
71
|
-
|
72
|
-
def rpop(key)
|
73
|
-
require_array
|
74
|
-
data[key].pop
|
75
|
-
end
|
76
|
-
|
77
|
-
def rpoplpush(one, two)
|
78
|
-
val = rpop(one)
|
79
|
-
lpush two, val
|
80
|
-
val
|
81
|
-
end
|
82
|
-
|
83
|
-
def keys(pattern = ".*")
|
84
|
-
data.keys.filter {|k| k.to_s =~ /^#{pattern}$/}
|
85
|
-
end
|
86
|
-
|
87
|
-
def del(*keys)
|
88
|
-
keys.flatten!
|
89
|
-
i = 0
|
90
|
-
keys.map {|k| data.delete(k) && (i += 1) }
|
91
|
-
i
|
92
|
-
end
|
93
|
-
|
94
|
-
def method_missing
|
95
|
-
return nil
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
def require_array(key)
|
100
|
-
data[key] ||= []
|
101
|
-
raise_wrong_type unless data[key].is_a?(Array)
|
102
|
-
end
|
103
|
-
|
104
|
-
def raise_wrong_type
|
105
|
-
raise CommandError.new("WRONGTYPE Operation against a key holding the wrong kind of value")
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|