rails_kvs_driver 0.1.2 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rails_kvs_driver/version.rb +1 -1
- data/spec/common_example.rb +227 -70
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e16e83e57e175e02d6ebed33a8dd35bfbce7170b
|
4
|
+
data.tar.gz: 1718c48d2c967b4b31e8b515d2ac5c3c701fc852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 631039f1dda5aac88f54ba06ead4fac5bb6e2e861bada761998a784ba153b5821fbc7dff354a31572c28e9b5be6146666f806fdcb14f9d9ce6a0ddb783373c29
|
7
|
+
data.tar.gz: 40b0eec8d9862a6d8c4f5d0c8075f49c547ab99693766c4b2d25fe0c0c7ea6da2034241e49c71f9f34d0b8d7b4c80c9031e99324a825a7883357488b2a56df6b
|
data/README.md
CHANGED
data/spec/common_example.rb
CHANGED
@@ -25,106 +25,263 @@ shared_examples_for 'RailsKvsDriver example' do |driver_class, driver_config|
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
context 'override methods' do
|
29
|
+
it 'call []' do
|
30
|
+
driver_class::session(driver_config) do |kvs|
|
31
|
+
kvs['example'] = 'nico-nico'
|
32
|
+
expect(kvs['example']).to eq('nico-nico')
|
33
|
+
expect(kvs['nothing key']).to be_nil
|
34
|
+
end
|
31
35
|
end
|
32
|
-
end
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
it 'call []=' do
|
38
|
+
driver_class::session(driver_config) do |kvs|
|
39
|
+
expect{ kvs['example'] = 'nico-nico' }.to change{ kvs.keys.length }.by(1)
|
40
|
+
end
|
38
41
|
end
|
39
|
-
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
it 'call add_sorted_set' do
|
44
|
+
driver_class::session(driver_config) do |kvs|
|
45
|
+
expect{
|
46
|
+
kvs.add_sorted_set('example', 'element', 1)
|
47
|
+
}.to change{ kvs.get_sorted_set_keys.length }.by(1)
|
48
|
+
end
|
45
49
|
end
|
46
|
-
end
|
47
50
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
it 'call count_sorted_set_member' do
|
52
|
+
driver_class::session(driver_config) do |kvs|
|
53
|
+
kvs.add_sorted_set('example', 'element1', 5)
|
54
|
+
kvs.add_sorted_set('example', 'element2', 5)
|
55
|
+
kvs.add_sorted_set('example', 'element3', 5)
|
56
|
+
expect(kvs.count_sorted_set_member('example')).to eq(3)
|
57
|
+
end
|
58
|
+
end
|
52
59
|
|
53
|
-
|
60
|
+
it 'call delete' do
|
61
|
+
driver_class::session(driver_config) do |kvs|
|
62
|
+
kvs['example'] = 'nico-nico'
|
63
|
+
kvs['example2'] = 'movie'
|
54
64
|
|
55
|
-
|
56
|
-
|
65
|
+
expect{ kvs.delete('example') }.to change{ kvs.keys.length }.by(-1)
|
66
|
+
|
67
|
+
expect(kvs.has_key?('example')).to be_false
|
68
|
+
expect(kvs.has_key?('example2')).to be_true
|
69
|
+
end
|
57
70
|
end
|
58
|
-
end
|
59
71
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
72
|
+
it 'call delete_all' do
|
73
|
+
driver_class::session(driver_config) do |kvs|
|
74
|
+
kvs['example'] = 'nico-nico'
|
75
|
+
kvs['example2'] = 'movie'
|
76
|
+
|
77
|
+
expect{ kvs.delete_all }.to change{ kvs.keys.length }.by(-2)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'call get_sorted_set' do
|
82
|
+
driver_class::session(driver_config) do |kvs|
|
83
|
+
kvs.add_sorted_set('example', 'element1', 1)
|
84
|
+
kvs.add_sorted_set('example', 'element5', 5)
|
85
|
+
kvs.add_sorted_set('example', 'element2', 2)
|
64
86
|
|
65
|
-
|
87
|
+
sorted_set = kvs.get_sorted_set('example')
|
66
88
|
|
67
|
-
|
68
|
-
|
89
|
+
expect(sorted_set[0][0]).to eq('element1')
|
90
|
+
expect(sorted_set[1][0]).to eq('element2')
|
91
|
+
expect(sorted_set[2][0]).to eq('element5')
|
92
|
+
|
93
|
+
expect(kvs.get_sorted_set('nothing key')).to be_nil
|
94
|
+
end
|
69
95
|
end
|
70
|
-
end
|
71
96
|
|
72
|
-
|
73
|
-
|
74
|
-
|
97
|
+
it 'call get_sorted_set_keys' do
|
98
|
+
driver_class::session(driver_config) do |kvs|
|
99
|
+
kvs['example'] = 'nico-nico'
|
100
|
+
kvs.add_sorted_set('example0_ss', 'element0', 5)
|
101
|
+
kvs.add_sorted_set('example1_ss', 'element0', 5)
|
102
|
+
|
103
|
+
expect(kvs.get_sorted_set_keys.length).to eq(2)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'call get_sorted_set_score' do
|
108
|
+
driver_class::session(driver_config) do |kvs|
|
109
|
+
kvs.add_sorted_set('example', 'element5', 5)
|
110
|
+
expect(kvs.get_sorted_set('example')[0][1]).to eq(5)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'call increment_sorted_set' do
|
115
|
+
driver_class::session(driver_config) do |kvs|
|
75
116
|
kvs.add_sorted_set('example', 'element', 1)
|
76
|
-
|
117
|
+
|
118
|
+
expect{
|
119
|
+
kvs.increment_sorted_set('example', 'element', 10)
|
120
|
+
}.to change{ kvs.get_sorted_set_score('example', 'element') }.by(10)
|
121
|
+
end
|
77
122
|
end
|
78
|
-
end
|
79
123
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
kvs.add_sorted_set('example', 'element2', 1)
|
124
|
+
it 'call has_key?' do
|
125
|
+
driver_class::session(driver_config) do |kvs|
|
126
|
+
kvs['example'] = 'nico-nico'
|
84
127
|
|
85
|
-
|
86
|
-
kvs.
|
87
|
-
|
128
|
+
expect(kvs.has_key?('example')).to be_true
|
129
|
+
expect(kvs.has_key?('nothing key')).to be_false
|
130
|
+
end
|
88
131
|
end
|
89
|
-
end
|
90
132
|
|
91
|
-
|
92
|
-
|
93
|
-
|
133
|
+
it 'call keys' do
|
134
|
+
driver_class::session(driver_config) do |kvs|
|
135
|
+
kvs['example0'] = 'nico-nico'
|
136
|
+
kvs['example1'] = 'nico-nico'
|
137
|
+
kvs.add_sorted_set('example_ss', 'element5', 5)
|
138
|
+
|
139
|
+
expect(kvs.keys.length).to eq(2)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'call remove_sorted_set' do
|
144
|
+
driver_class::session(driver_config) do |kvs|
|
145
|
+
kvs.add_sorted_set('example', 'element', 1)
|
146
|
+
kvs.add_sorted_set('example', 'element2', 1)
|
94
147
|
|
95
|
-
|
96
|
-
|
97
|
-
|
148
|
+
expect{
|
149
|
+
kvs.remove_sorted_set('example', 'element')
|
150
|
+
}.to change{ kvs.count_sorted_set_member('example') }.by(-1)
|
151
|
+
end
|
98
152
|
end
|
99
153
|
end
|
100
154
|
|
101
|
-
it 'call sorted_set' do
|
102
|
-
driver_class::session(driver_config) do |kvs|
|
103
|
-
kvs.add_sorted_set('example', 'element1', 1)
|
104
|
-
kvs.add_sorted_set('example', 'element5', 5)
|
105
|
-
kvs.add_sorted_set('example', 'element2', 2)
|
106
155
|
|
107
|
-
sorted_set = kvs.sorted_set('example')
|
108
156
|
|
109
|
-
|
110
|
-
|
111
|
-
|
157
|
+
|
158
|
+
context 'inheritance methods' do
|
159
|
+
|
160
|
+
it 'call each' do
|
161
|
+
driver_class::session(driver_config) do |kvs|
|
162
|
+
kvs['example0'] = 'nico-nico0'
|
163
|
+
kvs['example1'] = 'nico-nico1'
|
164
|
+
|
165
|
+
kvs.each do |key, value|
|
166
|
+
expect(value).to eq(kvs[key])
|
167
|
+
end
|
168
|
+
end
|
112
169
|
end
|
113
|
-
end
|
114
170
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
171
|
+
it 'call length' do
|
172
|
+
driver_class::session(driver_config) do |kvs|
|
173
|
+
kvs['example0'] = 'nico-nico0'
|
174
|
+
kvs['example1'] = 'nico-nico1'
|
175
|
+
|
176
|
+
expect(kvs.length).to eq(2)
|
177
|
+
end
|
119
178
|
end
|
120
|
-
end
|
121
179
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
180
|
+
context 'sorted_sets' do
|
181
|
+
|
182
|
+
it 'call []' do
|
183
|
+
driver_class::session(driver_config) do |kvs|
|
184
|
+
kvs.add_sorted_set('example', 'element', 1024)
|
185
|
+
kvs.add_sorted_set('example', 'element2', 1)
|
186
|
+
|
187
|
+
expect(kvs.sorted_sets['example'].length).to eq(2)
|
188
|
+
expect(kvs.sorted_sets['example','element']).to eq(1024)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'call []=' do
|
193
|
+
driver_class::session(driver_config) do |kvs|
|
194
|
+
kvs.sorted_sets['example'] = ['element', 1]
|
195
|
+
kvs.sorted_sets['example'] = ['element2', 1]
|
196
|
+
|
197
|
+
expect(kvs.sorted_sets['example'].length).to eq(2)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'call count' do
|
202
|
+
driver_class::session(driver_config) do |kvs|
|
203
|
+
kvs.add_sorted_set('example', 'element', 1)
|
204
|
+
kvs.add_sorted_set('example', 'element2', 1)
|
205
|
+
|
206
|
+
expect(kvs.sorted_sets.count('example')).to eq(2)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'call delete' do
|
211
|
+
driver_class::session(driver_config) do |kvs|
|
212
|
+
kvs.add_sorted_set('example', 'element', 1)
|
213
|
+
kvs.add_sorted_set('example2', 'element2', 1)
|
214
|
+
|
215
|
+
expect{kvs.sorted_sets.delete('example2')}.to change{kvs.sorted_sets.length}.by(-1)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'call each' do
|
220
|
+
driver_class::session(driver_config) do |kvs|
|
221
|
+
kvs.add_sorted_set('example', 'element', 1)
|
222
|
+
kvs.add_sorted_set('example2', 'element2', 1)
|
223
|
+
|
224
|
+
kvs.sorted_sets.each do |key|
|
225
|
+
expect(kvs.sorted_sets[key].length).not_to eq(0)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'call each_member' do
|
231
|
+
driver_class::session(driver_config) do |kvs|
|
232
|
+
kvs.add_sorted_set('example', 'element', 10)
|
233
|
+
kvs.add_sorted_set('example', 'element2', 1)
|
234
|
+
|
235
|
+
kvs.sorted_sets.each_member('example') do |member, score, position|
|
236
|
+
expect(kvs.sorted_sets['example', member]).to eq(score)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'call has_key?' do
|
242
|
+
driver_class::session(driver_config) do |kvs|
|
243
|
+
kvs.add_sorted_set('example', 'element', 10)
|
244
|
+
|
245
|
+
expect(kvs.sorted_sets.has_key?('example')).to be_true
|
246
|
+
expect(kvs.sorted_sets.has_key?('nothing key')).to be_false
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'call increment' do
|
251
|
+
driver_class::session(driver_config) do |kvs|
|
252
|
+
kvs.add_sorted_set('example', 'element', 10)
|
253
|
+
|
254
|
+
expect{kvs.sorted_sets.increment('example','element', 1)}.to change{kvs.sorted_sets['example','element']}.by(1)
|
255
|
+
expect{kvs.sorted_sets.increment('example','element', -1)}.to change{kvs.sorted_sets['example','element']}.by(-1)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'call keys' do
|
260
|
+
driver_class::session(driver_config) do |kvs|
|
261
|
+
kvs.add_sorted_set('example', 'element', 10)
|
262
|
+
kvs.add_sorted_set('example2', 'element', 1)
|
263
|
+
|
264
|
+
expect(kvs.sorted_sets.keys.length).to eq(2)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'call length' do
|
269
|
+
driver_class::session(driver_config) do |kvs|
|
270
|
+
kvs.add_sorted_set('example', 'element', 10)
|
271
|
+
kvs.add_sorted_set('example2', 'element', 1)
|
272
|
+
|
273
|
+
expect(kvs.sorted_sets.length).to eq(2)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'call remove' do
|
278
|
+
driver_class::session(driver_config) do |kvs|
|
279
|
+
kvs.add_sorted_set('example', 'element', 10)
|
280
|
+
kvs.add_sorted_set('example', 'element', 1)
|
281
|
+
|
282
|
+
expect{kvs.sorted_sets.remove('example', 'element')}.to change{kvs.sorted_sets.count('example')}.by(-1)
|
283
|
+
end
|
284
|
+
end
|
128
285
|
end
|
129
286
|
end
|
130
287
|
end
|