redis_object 1.3.0 → 1.3.1b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/redis_object.rb +1 -0
- data/lib/redis_object/base.rb +29 -8
- data/lib/redis_object/indices.rb +2 -1
- data/lib/redis_object/version.rb +1 -1
- data/spec/base_spec.rb +17 -0
- data/spec/indices_spec.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTk4ZjkxYzdmYzFjNTk0MTkzZjk1MWVjMDk4M2MzZjY0Nzg4NzRmNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTE4M2E2YjFhOGU4MDY0MDQ5N2UyNzgzYjNkZTViMWNkNWUwOTczMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmI4N2EwODRhMWYyMmFiNGY3NmIxMmFkNjcyOWY3YWYyYmNkYTc1NzViZTE5
|
10
|
+
ZGIxYjI3MjkxOTkzMDRiMTViMTIxNGE2MzJiYzBkZGNlZmJiZTUzNjZmYzVk
|
11
|
+
ZGU2MjRiODk0YTM2ZmExYjI2ODVhMzgwMzk1OTFjN2NmMmZkMzU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDAxM2I2MmViMWFiMTA0ZmY2M2U1ZDRhMmQ5NTc2NGFiMGMzODdiNTJjNmU0
|
14
|
+
NTI0YTZlMjQ5ZWM3MmM0MGU2YTMyOTg3NmIzODg2Y2U4ZjgzMGMyMTUwZmY0
|
15
|
+
NzU4ZjQ0MDdhNGZiMDFhZTUxYjc0Y2E3NDNhZjgxNDI3ZGUyMGM=
|
data/lib/redis_object.rb
CHANGED
data/lib/redis_object/base.rb
CHANGED
@@ -93,7 +93,7 @@ module Seabright
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def mset(dat)
|
96
|
-
store.hmset(hkey, *(dat.inject([]){|acc,(k,v)| acc
|
96
|
+
store.hmset(hkey, *(dat.inject([]){|acc,(k,v)| acc << [k,v] }.flatten))
|
97
97
|
cached_hash_values.merge!(dat)
|
98
98
|
dat.each do |k,v|
|
99
99
|
define_setter_getter(k)
|
@@ -185,8 +185,8 @@ module Seabright
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
|
188
|
-
def id_sym(cls=
|
189
|
-
|
188
|
+
def id_sym(cls=nil)
|
189
|
+
self.class.id_sym(cls)
|
190
190
|
end
|
191
191
|
|
192
192
|
# Not used yet...
|
@@ -236,7 +236,7 @@ module Seabright
|
|
236
236
|
end
|
237
237
|
|
238
238
|
def cname
|
239
|
-
|
239
|
+
name
|
240
240
|
end
|
241
241
|
|
242
242
|
def plname
|
@@ -244,8 +244,9 @@ module Seabright
|
|
244
244
|
end
|
245
245
|
|
246
246
|
def all
|
247
|
+
kys = store.smembers(plname)
|
247
248
|
Enumerator.new do |y|
|
248
|
-
|
249
|
+
kys.each do |member|
|
249
250
|
if a = find_by_key(hkey(member))
|
250
251
|
y << a
|
251
252
|
else
|
@@ -341,8 +342,9 @@ module Seabright
|
|
341
342
|
return out".gsub(/\t/,'').freeze
|
342
343
|
|
343
344
|
def match(pkt)
|
345
|
+
kys = run_script(pkt.keys.count > 1 ? :MultiMatcher : :Matcher,[plname],pkt.flatten.map{|i| i.is_a?(Regexp) ? convert_regex_to_lua(i) : i.to_s })
|
344
346
|
Enumerator.new do |y|
|
345
|
-
|
347
|
+
kys.each do |k|
|
346
348
|
y << find(k)
|
347
349
|
end
|
348
350
|
end
|
@@ -416,8 +418,27 @@ module Seabright
|
|
416
418
|
true
|
417
419
|
end
|
418
420
|
|
419
|
-
def id_sym(cls=
|
420
|
-
|
421
|
+
def id_sym(cls=nil)
|
422
|
+
_old_id_sym(cls)
|
423
|
+
end
|
424
|
+
|
425
|
+
def _new_id_sym(cls=self.name)
|
426
|
+
(cls || self.name).foreign_key.to_sym
|
427
|
+
end
|
428
|
+
|
429
|
+
def convert_old_id_syms!
|
430
|
+
ol = _old_id_sym
|
431
|
+
nw = id_sym
|
432
|
+
each do |obj|
|
433
|
+
if obj.is_set?(ol)
|
434
|
+
obj.set(nw,get(ol))
|
435
|
+
obj.unset(ol)
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
def _old_id_sym(cls=self.name)
|
441
|
+
"#{(cls || self.name).split('::').last.downcase}_id".to_sym
|
421
442
|
end
|
422
443
|
|
423
444
|
def describe
|
data/lib/redis_object/indices.rb
CHANGED
@@ -45,8 +45,9 @@ module Seabright
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def indexed(idx,num=-1,reverse=false)
|
48
|
+
kys = store.send(reverse ? :zrevrange : :zrange, index_key(idx), 0, num-1)
|
48
49
|
out = Enumerator.new do |yielder|
|
49
|
-
|
50
|
+
kys.each do |member|
|
50
51
|
if a = self.find_by_key(member)
|
51
52
|
yielder << a
|
52
53
|
end
|
data/lib/redis_object/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -10,6 +10,11 @@ module ObjectTests
|
|
10
10
|
class Doodad < RedisObject
|
11
11
|
|
12
12
|
end
|
13
|
+
class Collidor < RedisObject
|
14
|
+
def new_id
|
15
|
+
"totsunique"
|
16
|
+
end
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
describe RedisObject do
|
@@ -38,6 +43,13 @@ describe RedisObject do
|
|
38
43
|
obj.should_not be_nil
|
39
44
|
end
|
40
45
|
|
46
|
+
it "should be found by complex matchers" do
|
47
|
+
obj = ObjectTests::User.find(user_id: "test")
|
48
|
+
obj.should_not be_nil
|
49
|
+
obj = ObjectTests::User.find(user_id: /test/)
|
50
|
+
obj.should_not be_nil
|
51
|
+
end
|
52
|
+
|
41
53
|
it "can recollect objects" do
|
42
54
|
ObjectTests::User.recollect!
|
43
55
|
end
|
@@ -99,4 +111,9 @@ describe RedisObject do
|
|
99
111
|
end
|
100
112
|
end
|
101
113
|
|
114
|
+
it "detects id collisions" do
|
115
|
+
ObjectTests::Collidor.create
|
116
|
+
ObjectTests::Collidor.create
|
117
|
+
end
|
118
|
+
|
102
119
|
end
|
data/spec/indices_spec.rb
CHANGED
@@ -23,6 +23,7 @@ module IndexSpec
|
|
23
23
|
end
|
24
24
|
|
25
25
|
sort_by :a_number
|
26
|
+
sort_by :a_bool
|
26
27
|
|
27
28
|
end
|
28
29
|
|
@@ -34,7 +35,7 @@ module IndexSpec
|
|
34
35
|
it "indexes on integer field" do
|
35
36
|
|
36
37
|
5.times do
|
37
|
-
obj = IndexedObject.create(a_number: Random.rand(100))
|
38
|
+
obj = IndexedObject.create(a_number: Random.rand(100), a_bool: true)
|
38
39
|
end
|
39
40
|
|
40
41
|
IndexedObject.indexed(:a_number,3,true).count.should eq(3)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1b
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bragg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utf8_utils
|
@@ -163,9 +163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: 1.9.2
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
|
-
- - ! '
|
166
|
+
- - ! '>'
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version:
|
168
|
+
version: 1.3.1
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project: redis_object
|
171
171
|
rubygems_version: 2.0.3
|