redis_object 1.5.1 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_object.rb +2 -2
- data/lib/redis_object/base.rb +44 -1
- data/lib/redis_object/collection.rb +61 -41
- data/lib/redis_object/defaults.rb +5 -5
- data/lib/redis_object/ext/filters.rb +27 -23
- data/lib/redis_object/indices.rb +15 -26
- data/lib/redis_object/inheritance_tracking.rb +7 -0
- data/lib/redis_object/timestamps.rb +3 -1
- data/lib/redis_object/types.rb +12 -23
- data/lib/redis_object/types/array.rb +2 -0
- data/lib/redis_object/types/boolean.rb +2 -2
- data/lib/redis_object/types/json.rb +2 -0
- data/lib/redis_object/version.rb +1 -1
- data/spec/adapter_spec.rb +1 -1
- data/spec/benchmark_spec.rb +1 -1
- data/spec/collections_spec.rb +2 -2
- data/spec/defaults_spec.rb +1 -1
- data/spec/dumping_spec.rb +4 -4
- data/spec/field_ref_spec.rb +1 -1
- data/spec/filters_spec.rb +1 -1
- data/spec/indices_spec.rb +1 -1
- data/spec/rename_class_spec.rb +1 -1
- data/spec/sanitization_spec.rb +14 -11
- data/spec/script_cache_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -0
- data/spec/timestamp_spec.rb +1 -1
- data/spec/trigger_spec.rb +1 -1
- data/spec/types_spec.rb +1 -1
- data/spec/view_caching_spec_disabled.rb +1 -1
- data/spec/views_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e29fac9ff513bd3d3f7aa116e630fe7c73f5cec7
|
4
|
+
data.tar.gz: 14d062362d8cad4c0ee0ea30de05fcf7ae21f4a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ea0b819bb2181d844fbbf493d3e5cbd66a2b9511282ed200a8cc2ed2032df0fd67b1c9cbb1f43867a2d3bd349be8a369355d380ad39661855ebc734fad50786
|
7
|
+
data.tar.gz: cc1dbf34cddda5e4fadad91871d443ba038c0657f8b9566f70b3526d6bbf01e45dd94b460a7b86aa380edd08b4a03c7081104c7636080d19bb656560e46cbdff
|
data/lib/redis_object.rb
CHANGED
@@ -34,11 +34,11 @@ module Seabright
|
|
34
34
|
include Seabright::CachedScripts
|
35
35
|
include Seabright::Storage
|
36
36
|
include Seabright::Keys
|
37
|
-
include Seabright::Types
|
38
37
|
include Seabright::DefaultValues
|
38
|
+
include Seabright::Indices
|
39
39
|
include Seabright::Collections
|
40
|
+
include Seabright::Types
|
40
41
|
include Seabright::Triggers
|
41
|
-
include Seabright::Indices
|
42
42
|
include Seabright::Views
|
43
43
|
include Seabright::ViewCaching
|
44
44
|
include Seabright::Timestamps
|
data/lib/redis_object/base.rb
CHANGED
@@ -71,7 +71,13 @@ module Seabright
|
|
71
71
|
alias_method :actual, :raw
|
72
72
|
|
73
73
|
def get(k)
|
74
|
-
cached_hash_values[k.to_s]
|
74
|
+
filter_gotten_value(k, (cached_hash_values[k.to_s] || _get(k)))
|
75
|
+
end
|
76
|
+
|
77
|
+
def filter_gotten_value(k,v)
|
78
|
+
self.class.get_filters.inject(v) do |acc, filter|
|
79
|
+
filter.call(self, k, acc)
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
def _get(k)
|
@@ -92,6 +98,9 @@ module Seabright
|
|
92
98
|
end
|
93
99
|
|
94
100
|
def mset(dat)
|
101
|
+
dat = self.class.mset_filters.inject(dat) do |acc,filter|
|
102
|
+
filter.call(self, acc)
|
103
|
+
end
|
95
104
|
store.hmset(hkey, *(dat.inject([]){|acc,(k,v)| acc << [k,v] }.flatten))
|
96
105
|
cached_hash_values.merge!(dat)
|
97
106
|
dat.each do |k,v|
|
@@ -115,6 +124,9 @@ module Seabright
|
|
115
124
|
end
|
116
125
|
|
117
126
|
def set(k,v)
|
127
|
+
(k,v) = self.class.set_filters.inject([k,v]) do |acc,filter|
|
128
|
+
filter.call(self,*acc) unless acc.nil? or acc[0].nil?
|
129
|
+
end
|
118
130
|
return nil if k.nil?
|
119
131
|
return set_ref(k,v) if v.is_a?(RedisObject)
|
120
132
|
store.hset(hkey, k.to_s, v.to_s)
|
@@ -151,6 +163,9 @@ module Seabright
|
|
151
163
|
end
|
152
164
|
|
153
165
|
def setnx(k,v)
|
166
|
+
(k,v) = self.class.set_filters.inject([k,v]) do |acc,filter|
|
167
|
+
filter.call(self,*acc)
|
168
|
+
end
|
154
169
|
if success = store.hsetnx(hkey, k.to_s, v.to_s)
|
155
170
|
cached_hash_values[k.to_s] = v
|
156
171
|
define_setter_getter(k)
|
@@ -216,6 +231,34 @@ module Seabright
|
|
216
231
|
|
217
232
|
module ClassMethods
|
218
233
|
|
234
|
+
def action_filters
|
235
|
+
@@action_filters ||= {}
|
236
|
+
end
|
237
|
+
|
238
|
+
def set_filters
|
239
|
+
action_filters[:set] ||= []
|
240
|
+
end
|
241
|
+
|
242
|
+
def filter_sets(&block)
|
243
|
+
set_filters << block
|
244
|
+
end
|
245
|
+
|
246
|
+
def mset_filters
|
247
|
+
action_filters[:mset] ||= []
|
248
|
+
end
|
249
|
+
|
250
|
+
def filter_msets(&block)
|
251
|
+
mset_filters << block
|
252
|
+
end
|
253
|
+
|
254
|
+
def get_filters
|
255
|
+
action_filters[:get] ||= []
|
256
|
+
end
|
257
|
+
|
258
|
+
def filter_gets(&block)
|
259
|
+
get_filters << block
|
260
|
+
end
|
261
|
+
|
219
262
|
def clean_id(i)
|
220
263
|
i.to_s.gsub(/.*:/,'').gsub(/_h$/,'')
|
221
264
|
end
|
@@ -6,20 +6,6 @@ module Seabright
|
|
6
6
|
"#{hkey}:collections"
|
7
7
|
end
|
8
8
|
|
9
|
-
def load(o_id)
|
10
|
-
super(o_id)
|
11
|
-
store.smembers(hkey_col).each do |name|
|
12
|
-
collections[name] = Seabright::Collection.load(name,self)
|
13
|
-
define_access(name) do
|
14
|
-
get_collection(name)
|
15
|
-
end
|
16
|
-
define_access(name.to_s.singularize) do
|
17
|
-
get_collection(name).latest
|
18
|
-
end
|
19
|
-
end
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
9
|
def delete_child(obj)
|
24
10
|
if col = get_collection(obj.collection_name)
|
25
11
|
col.delete obj
|
@@ -78,14 +64,18 @@ module Seabright
|
|
78
64
|
end
|
79
65
|
end
|
80
66
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
67
|
+
def load(o_id)
|
68
|
+
super(o_id)
|
69
|
+
store.smembers(hkey_col).each do |name|
|
70
|
+
collections[name] = Seabright::Collection.load(name,self)
|
71
|
+
define_access(name) do
|
72
|
+
get_collection(name)
|
73
|
+
end
|
74
|
+
define_access(name.to_s.singularize) do
|
75
|
+
get_collection(name).latest
|
76
|
+
end
|
88
77
|
end
|
78
|
+
true
|
89
79
|
end
|
90
80
|
|
91
81
|
def has_collection?(name)
|
@@ -97,13 +87,13 @@ module Seabright
|
|
97
87
|
collections[name.to_s] ||= Collection.load(name,self)
|
98
88
|
else
|
99
89
|
store.sadd hkey_col, name
|
100
|
-
|
90
|
+
collection_names << name.to_s
|
101
91
|
collections[name.to_s] ||= Collection.load(name,self)
|
102
92
|
define_access(name.to_s.pluralize) do
|
103
93
|
get_collection(name)
|
104
94
|
end
|
105
95
|
define_access(name.to_s.singularize) do
|
106
|
-
get_collection(name).
|
96
|
+
get_collection(name).first
|
107
97
|
end
|
108
98
|
end
|
109
99
|
collections[name.to_s]
|
@@ -117,16 +107,6 @@ module Seabright
|
|
117
107
|
@collection_names ||= store.smembers(hkey_col)
|
118
108
|
end
|
119
109
|
|
120
|
-
def mset(dat)
|
121
|
-
dat.select! {|k,v| !collections[k.to_s] }
|
122
|
-
super(dat)
|
123
|
-
end
|
124
|
-
|
125
|
-
def set(k,v)
|
126
|
-
@data ? super(k,v) : has_collection?(k) ? get_collection(k.to_s).replace(v) : super(k,v)
|
127
|
-
v
|
128
|
-
end
|
129
|
-
|
130
110
|
def collect_type_by_key(col,*keys)
|
131
111
|
collect = get_collection(col)
|
132
112
|
keys.each do |k|
|
@@ -136,6 +116,37 @@ module Seabright
|
|
136
116
|
|
137
117
|
module ClassMethods
|
138
118
|
|
119
|
+
def intercept_sets_for_collecting!
|
120
|
+
return if @intercepted_sets_for_collecting
|
121
|
+
self.class_eval do
|
122
|
+
|
123
|
+
filter_gets do |obj, k, v|
|
124
|
+
if obj.has_collection?(k)
|
125
|
+
obj.get_collection(k)
|
126
|
+
elsif obj.has_collection?(pk = k.to_s.pluralize)
|
127
|
+
obj.get_collection(pk).first
|
128
|
+
else
|
129
|
+
v
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
filter_sets do |obj, k, v|
|
134
|
+
if obj.has_collection?(k)
|
135
|
+
obj.get_collection(k.to_s).replace(v)
|
136
|
+
return [nil,nil]
|
137
|
+
else
|
138
|
+
[k,v]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
filter_msets do |obj, dat|
|
143
|
+
dat.select {|k,v| !obj.collections[k.to_s] }
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
@intercepted_sets_for_collecting = true
|
148
|
+
end
|
149
|
+
|
139
150
|
def hkey_col(ident = nil)
|
140
151
|
"#{hkey(ident)}:collections"
|
141
152
|
end
|
@@ -170,12 +181,11 @@ module Seabright
|
|
170
181
|
|
171
182
|
def get(k)
|
172
183
|
if has_collection?(k)
|
173
|
-
get_collection(k)
|
184
|
+
return get_collection(k)
|
174
185
|
elsif has_collection?(pk = k.to_s.pluralize)
|
175
|
-
get_collection(pk).first
|
176
|
-
else
|
177
|
-
super(k)
|
186
|
+
return get_collection(pk).first
|
178
187
|
end
|
188
|
+
nil
|
179
189
|
end
|
180
190
|
|
181
191
|
def has_collection?(name)
|
@@ -195,6 +205,7 @@ module Seabright
|
|
195
205
|
|
196
206
|
def self.included(base)
|
197
207
|
base.extend(ClassMethods)
|
208
|
+
base.intercept_sets_for_collecting!
|
198
209
|
end
|
199
210
|
|
200
211
|
end
|
@@ -238,12 +249,18 @@ module Seabright
|
|
238
249
|
"#{key}::zintersect_temp::#{RedisObject.new_id(4)}"
|
239
250
|
end
|
240
251
|
|
241
|
-
RedisObject::ScriptSources::FwdScript = "redis.call('ZINTERSTORE', KEYS[1], 2, KEYS[2], KEYS[3], 'WEIGHTS', 1, 0)
|
242
|
-
|
252
|
+
RedisObject::ScriptSources::FwdScript = "redis.call('ZINTERSTORE', KEYS[1], 2, KEYS[2], KEYS[3], 'WEIGHTS', 1, 0)
|
253
|
+
local keys = redis.call('ZRANGE', KEYS[1], 0, KEYS[4])
|
254
|
+
redis.call('DEL', KEYS[1])
|
255
|
+
return keys".freeze
|
256
|
+
RedisObject::ScriptSources::RevScript = "redis.call('ZINTERSTORE', KEYS[1], 2, KEYS[2], KEYS[3], 'WEIGHTS', 1, 0)
|
257
|
+
local keys = redis.call('ZREVRANGE', KEYS[1], 0, KEYS[4])
|
258
|
+
redis.call('DEL', KEYS[1])
|
259
|
+
return keys".freeze
|
243
260
|
|
244
261
|
def keys_by_index(idx,num=-1,reverse=false)
|
245
|
-
keys = run_script(reverse ? :RevScript : :FwdScript, [temp_key, sort_index_key(idx), key, num])
|
246
|
-
ListEnumerator.new(keys) do |y|
|
262
|
+
keys = run_script(reverse ? :RevScript : :FwdScript, [temp_key, sort_index_key(idx), key, num>0 ? num - 1 : -1])
|
263
|
+
ListEnumerator.new(keys.uniq) do |y|
|
247
264
|
keys.each do |member|
|
248
265
|
y << member
|
249
266
|
end
|
@@ -584,6 +601,9 @@ module Seabright
|
|
584
601
|
end
|
585
602
|
|
586
603
|
def class_const_for(name)
|
604
|
+
if cls = RedisObject.constant_lookups[name.to_s.classify.to_sym]
|
605
|
+
return cls
|
606
|
+
end
|
587
607
|
Object.const_get(name.to_s.classify.to_sym) rescue RedisObject
|
588
608
|
end
|
589
609
|
|
@@ -11,12 +11,12 @@ module Seabright
|
|
11
11
|
return if @intercepted_for_defaults
|
12
12
|
self.class_eval do
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
filter_gets do |obj, k, v|
|
15
|
+
if !obj.is_set?(k) && (d = obj.class.default_vals[k.to_sym]) && !d.nil?
|
16
|
+
d
|
17
|
+
else
|
18
|
+
v
|
18
19
|
end
|
19
|
-
undefaulted_get(k)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -7,41 +7,45 @@ module Seabright
|
|
7
7
|
return if @intercept_for_filters
|
8
8
|
self.class_eval do
|
9
9
|
|
10
|
-
|
11
|
-
if filters =
|
12
|
-
filters.
|
13
|
-
|
14
|
-
args = send(f,*args)
|
10
|
+
filter_gets do |obj, k, v|
|
11
|
+
if filters = obj.class.filters_for(:get)
|
12
|
+
return filters.inject(v) do |acc,f|
|
13
|
+
obj.send(f,acc)
|
15
14
|
end
|
15
|
+
else
|
16
|
+
v
|
16
17
|
end
|
17
|
-
unless args.is_a?(Array)
|
18
|
-
args = [nil,nil]
|
19
|
-
end
|
20
|
-
send("unfiltered_#{method.to_s}".to_sym,*args)
|
21
|
-
end
|
22
|
-
|
23
|
-
alias_method :unfiltered_get, :get unless method_defined?(:unfiltered_get)
|
24
|
-
def get(k)
|
25
|
-
filtered_method_call(:get,k)
|
26
18
|
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
20
|
+
filter_sets do |obj, k, v|
|
21
|
+
if filters = obj.class.filters_for(:set)
|
22
|
+
filters.inject([k,v]) do |acc,f|
|
23
|
+
obj.send(f,*acc)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
[k,v]
|
27
|
+
end
|
36
28
|
end
|
37
29
|
|
30
|
+
# filter_msets do |dat|
|
31
|
+
# if filters = self.class.filters_for(method)
|
32
|
+
# filters.each do |f|
|
33
|
+
# next unless args.is_a?(Array) and !args[0].nil?
|
34
|
+
# args = send(f,*args)
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
# unless args.is_a?(Array)
|
38
|
+
# args = [nil,nil]
|
39
|
+
# end
|
40
|
+
# args
|
41
|
+
# end
|
42
|
+
#
|
38
43
|
end
|
39
44
|
@intercept_for_filters = true
|
40
45
|
end
|
41
46
|
|
42
47
|
def set_filter(filter)
|
43
48
|
filter_method(:set,filter)
|
44
|
-
filter_method(:setnx,filter)
|
45
49
|
end
|
46
50
|
|
47
51
|
def get_filter(filter)
|
data/lib/redis_object/indices.rb
CHANGED
@@ -22,17 +22,6 @@ module Seabright
|
|
22
22
|
return if @intercepted_sets_for_indices
|
23
23
|
self.class_eval do
|
24
24
|
|
25
|
-
def indexed_set_method(meth,k,v)
|
26
|
-
ret = send("unindexed_#{meth}".to_sym,k,v)
|
27
|
-
if self.class.has_index?(k)
|
28
|
-
set_index k, v, hkey
|
29
|
-
end
|
30
|
-
if self.class.has_sort_index?(k)
|
31
|
-
set_sort_index k, v, hkey
|
32
|
-
end
|
33
|
-
ret
|
34
|
-
end
|
35
|
-
|
36
25
|
def set_index(k,v,hkey)
|
37
26
|
if cur = get(k)
|
38
27
|
store.srem(self.class.index_key(k,cur), hkey)
|
@@ -45,25 +34,24 @@ module Seabright
|
|
45
34
|
store.zadd(self.class.sort_index_key(k), score_format(k,v), hkey)
|
46
35
|
end
|
47
36
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
filter_sets do |obj, k, v|
|
38
|
+
if obj.class.has_index?(k)
|
39
|
+
obj.set_index k, v, obj.hkey
|
40
|
+
end
|
41
|
+
if obj.class.has_sort_index?(k)
|
42
|
+
obj.set_sort_index k, v, obj.hkey
|
43
|
+
end
|
44
|
+
[k, v]
|
56
45
|
end
|
57
46
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
set_index k, v, hkey
|
47
|
+
filter_msets do |obj, dat|
|
48
|
+
dat.each do |k,v|
|
49
|
+
obj.set_index(k, v, obj.hkey) if obj.class.has_index?(k)
|
62
50
|
end
|
63
|
-
dat.
|
64
|
-
set_sort_index
|
51
|
+
dat.each do |k,v|
|
52
|
+
obj.set_sort_index(k, v, obj.hkey) if obj.class.has_sort_index?(k)
|
65
53
|
end
|
66
|
-
|
54
|
+
dat
|
67
55
|
end
|
68
56
|
|
69
57
|
end
|
@@ -147,6 +135,7 @@ module Seabright
|
|
147
135
|
|
148
136
|
def self.included(base)
|
149
137
|
base.extend(ClassMethods)
|
138
|
+
base.intercept_sets_for_indices!
|
150
139
|
end
|
151
140
|
|
152
141
|
end
|
@@ -1,8 +1,15 @@
|
|
1
1
|
module Seabright
|
2
|
+
|
3
|
+
def RedisObject.constant_lookups
|
4
|
+
@constant_lookups ||= {}
|
5
|
+
end
|
6
|
+
|
2
7
|
module InheritanceTracking
|
3
8
|
|
4
9
|
module ClassMethods
|
10
|
+
|
5
11
|
def inherited(child_class)
|
12
|
+
RedisObject.constant_lookups[child_class.name.to_s.split("::").last.to_sym] ||= child_class
|
6
13
|
child_classes_set.add(child_class)
|
7
14
|
end
|
8
15
|
|
data/lib/redis_object/types.rb
CHANGED
@@ -136,30 +136,19 @@ module Seabright
|
|
136
136
|
|
137
137
|
def intercept_for_typing!
|
138
138
|
return if @intercepted_for_typing
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
alias_method :untyped_set, :set unless method_defined?(:untyped_set)
|
153
|
-
def set(k,v)
|
154
|
-
untyped_set(k,save_format(k,v))
|
155
|
-
end
|
156
|
-
|
157
|
-
alias_method :untyped_setnx, :setnx unless method_defined?(:untyped_setnx)
|
158
|
-
def setnx(k,v)
|
159
|
-
untyped_setnx(k,save_format(k,v))
|
160
|
-
end
|
161
|
-
|
139
|
+
|
140
|
+
filter_gets do |obj, k, v|
|
141
|
+
obj.enforce_format(k, v)
|
142
|
+
end
|
143
|
+
|
144
|
+
filter_sets do |obj, k, v|
|
145
|
+
[k, obj.save_format(k,v)]
|
146
|
+
end
|
147
|
+
|
148
|
+
filter_msets do |obj, dat|
|
149
|
+
dat.merge!(dat) {|k,v1,v2| obj.save_format(k, v1) }
|
162
150
|
end
|
151
|
+
|
163
152
|
@intercepted_for_typing = true
|
164
153
|
end
|
165
154
|
|
@@ -3,10 +3,12 @@ module Seabright
|
|
3
3
|
module ArrayType
|
4
4
|
|
5
5
|
def format_array(val)
|
6
|
+
return val if val.is_a?(Array)
|
6
7
|
val ? Yajl::Parser.new(:symbolize_keys => true).parse(val) : []
|
7
8
|
end
|
8
9
|
|
9
10
|
def save_array(val)
|
11
|
+
return val if val.is_a?(String)
|
10
12
|
Yajl::Encoder.encode(val)
|
11
13
|
end
|
12
14
|
|
@@ -3,11 +3,11 @@ module Seabright
|
|
3
3
|
module BooleanType
|
4
4
|
|
5
5
|
def format_boolean(val)
|
6
|
-
val
|
6
|
+
(val === true or val === "true") ? true : false
|
7
7
|
end
|
8
8
|
|
9
9
|
def save_boolean(val)
|
10
|
-
val === true ? "true" : "false"
|
10
|
+
(val === true or val === "true") ? "true" : "false"
|
11
11
|
end
|
12
12
|
|
13
13
|
def score_boolean(val)
|
@@ -3,10 +3,12 @@ module Seabright
|
|
3
3
|
module JsonType
|
4
4
|
|
5
5
|
def format_json(val)
|
6
|
+
return val unless val.is_a?(String)
|
6
7
|
val ? Yajl::Parser.new(:symbolize_keys => true).parse(val) : nil
|
7
8
|
end
|
8
9
|
|
9
10
|
def save_json(val)
|
11
|
+
return val if val.is_a?(String)
|
10
12
|
Yajl::Encoder.encode(val)
|
11
13
|
end
|
12
14
|
|
data/lib/redis_object/version.rb
CHANGED
data/spec/adapter_spec.rb
CHANGED
data/spec/benchmark_spec.rb
CHANGED
data/spec/collections_spec.rb
CHANGED
@@ -10,7 +10,7 @@ module CollectionSpec
|
|
10
10
|
describe Seabright::Collections do
|
11
11
|
before do
|
12
12
|
|
13
|
-
|
13
|
+
SpecHelper.flushdb
|
14
14
|
@granddad = GrandDad.create("gramps")
|
15
15
|
@dad = Daddy.create("dad")
|
16
16
|
@son = Son.create("sun")
|
@@ -140,7 +140,7 @@ module CollectionSpec
|
|
140
140
|
@dad << Son.create
|
141
141
|
end
|
142
142
|
|
143
|
-
|
143
|
+
@dad.sons.indexed(:created_at,3,true).count.should eq(3)
|
144
144
|
|
145
145
|
Son.indexed(:created_at,3,true).count.should eq(3)
|
146
146
|
|
data/spec/defaults_spec.rb
CHANGED
data/spec/dumping_spec.rb
CHANGED
@@ -16,9 +16,9 @@ module DumpingSpec
|
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
-
describe Seabright::
|
19
|
+
describe Seabright::Dumping do
|
20
20
|
before do
|
21
|
-
|
21
|
+
SpecHelper.flushdb
|
22
22
|
5.times do
|
23
23
|
d = DumpableObject.create(phone: Random.rand(100)*555, mailed: true, canceled_at: Time.now)
|
24
24
|
d << GenericObject.create(complex: {woot: true, ohnoes: false})
|
@@ -64,13 +64,13 @@ module DumpingSpec
|
|
64
64
|
|
65
65
|
r = RedisObject.dump_everything(:yml)
|
66
66
|
r.size.should > 100
|
67
|
-
|
67
|
+
SpecHelper.flushdb
|
68
68
|
RedisObject.load_dump r, :yml
|
69
69
|
DumpableObject.latest.generic_objects.count.should eq(1)
|
70
70
|
|
71
71
|
# r = RedisObject.dump_everything(:json)
|
72
72
|
# r.size.should > 100
|
73
|
-
#
|
73
|
+
# SpecHelper.flushdb
|
74
74
|
# RedisObject.load_dump r, :json
|
75
75
|
# DumpableObject.latest.generic_objects.count.should eq(1)
|
76
76
|
|
data/spec/field_ref_spec.rb
CHANGED
data/spec/filters_spec.rb
CHANGED
data/spec/indices_spec.rb
CHANGED
data/spec/rename_class_spec.rb
CHANGED
data/spec/sanitization_spec.rb
CHANGED
@@ -16,26 +16,29 @@ module TriggerSpec
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe Seabright::Triggers do
|
19
|
-
before do
|
20
|
-
|
21
|
-
|
19
|
+
before(:each) do
|
20
|
+
SpecHelper.flushdb
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:secret) do
|
24
|
+
SensitiveObject.create(test: Time.now, yay: true, stuff: {test: "1"}, worthless: "yup", sup: "dawg")
|
22
25
|
end
|
23
26
|
|
24
27
|
it "can sanitize a field or two willy nilly" do
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
secret.stuff.should be_a(Hash)
|
30
|
+
secret.sanitize! :stuff, :sup
|
31
|
+
secret.stuff.should eq(nil)
|
29
32
|
|
30
33
|
end
|
31
34
|
|
32
35
|
it "can sanitize by name" do
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
secret.test.should_not eq(nil)
|
38
|
+
secret.yay.should eq(true)
|
39
|
+
secret.sanitize_by_name! :burn
|
40
|
+
secret.test.should eq(nil)
|
41
|
+
secret.yay.should eq(false)
|
39
42
|
|
40
43
|
end
|
41
44
|
|
data/spec/script_cache_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -35,5 +35,13 @@ Debug = if ENV['DEBUG']
|
|
35
35
|
DebugMode.new
|
36
36
|
end
|
37
37
|
|
38
|
+
module SpecHelper
|
39
|
+
|
40
|
+
def self.flushdb
|
41
|
+
RedisObject.store.flushdb
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
38
46
|
raise 'must specify TEST_DB' unless ENV['TEST_DB']
|
39
47
|
RedisObject.configure_store({adapter:'Redis', db:ENV['TEST_DB']},:global,:alias)
|
data/spec/timestamp_spec.rb
CHANGED
data/spec/trigger_spec.rb
CHANGED
data/spec/types_spec.rb
CHANGED
data/spec/views_spec.rb
CHANGED
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.5.
|
4
|
+
version: 1.5.3
|
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-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utf8_utils
|