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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f78813ebc99ba319770bd8ef0c4fbdc09514cd4
4
- data.tar.gz: b59f2e73ab356e50cb73f455582c9765d3951684
3
+ metadata.gz: e16e83e57e175e02d6ebed33a8dd35bfbce7170b
4
+ data.tar.gz: 1718c48d2c967b4b31e8b515d2ac5c3c701fc852
5
5
  SHA512:
6
- metadata.gz: be8643028faa6de55130899e3e45c267db0eab94a3af8e2be727cc531a204856aca4b4ad9adc824d0e568a4f9e08fd274078ece81529ed76170f32bb2669067c
7
- data.tar.gz: 260084bd150f5ebb1452e6be392543694c7832a62fa3f8ae7c0cc2c63b0e981c8fd17242d8ab8a2b58ec23af85f1d25e1b27b5c53924aed5776bb0cb66d99f66
6
+ metadata.gz: 631039f1dda5aac88f54ba06ead4fac5bb6e2e861bada761998a784ba153b5821fbc7dff354a31572c28e9b5be6146666f806fdcb14f9d9ce6a0ddb783373c29
7
+ data.tar.gz: 40b0eec8d9862a6d8c4f5d0c8075f49c547ab99693766c4b2d25fe0c0c7ea6da2034241e49c71f9f34d0b8d7b4c80c9031e99324a825a7883357488b2a56df6b
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- comming soon.
25
+ * [rails_kvs_driver-redis_driver](https://github.com/alfa-jpn/rails_kvs_driver-redis_driver)
26
26
 
27
27
  ## Contributing
28
28
 
@@ -1,3 +1,3 @@
1
1
  module RailsKvsDriver
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -25,106 +25,263 @@ shared_examples_for 'RailsKvsDriver example' do |driver_class, driver_config|
25
25
  end
26
26
  end
27
27
 
28
- it 'call set value' do
29
- driver_class::session(driver_config) do |kvs|
30
- expect{ kvs['example'] = 'nico-nico' }.to change{ kvs.all_keys.length }.by(1)
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
- it 'call get value' do
35
- driver_class::session(driver_config) do |kvs|
36
- expect{ kvs['example'] = 'nico-nico' }.to change{ kvs.all_keys.length }.by(1)
37
- expect(kvs['example']).to eq('nico-nico')
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
- it 'call all keys' do
42
- driver_class::session(driver_config) do |kvs|
43
- expect{ kvs['example'] = 'nico-nico' }.to change{ kvs.all_keys.length }.by(1)
44
- expect(kvs.all_keys.length).to eq(1)
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
- it 'call delete value' do
49
- driver_class::session(driver_config) do |kvs|
50
- kvs['example'] = 'nico-nico'
51
- kvs['example2'] = 'movie'
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
- expect{ kvs.delete('example') }.to change{ kvs.all_keys.length }.by(-1)
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
- expect(kvs['example']).to eq(nil)
56
- expect(kvs['example2']).to eq('movie')
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
- it 'call delete_all' do
61
- driver_class::session(driver_config) do |kvs|
62
- kvs['example'] = 'nico-nico'
63
- kvs['example2'] = 'movie'
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
- expect{ kvs.delete_all }.to change{ kvs.all_keys.length }.by(-2)
87
+ sorted_set = kvs.get_sorted_set('example')
66
88
 
67
- expect(kvs['example']).to eq(nil)
68
- expect(kvs['example2']).to eq(nil)
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
- it 'call add_sorted_set' do
73
- driver_class::session(driver_config) do |kvs|
74
- expect{
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
- }.to change{ kvs.all_keys.length }.by(1)
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
- it 'call remove_sorted_set' do
81
- driver_class::session(driver_config) do |kvs|
82
- kvs.add_sorted_set('example', 'element', 1)
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
- expect{
86
- kvs.remove_sorted_set('example', 'element')
87
- }.to change{ kvs.count_sorted_set_member('example') }.by(-1)
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
- it 'call increment_sorted_set' do
92
- driver_class::session(driver_config) do |kvs|
93
- kvs.add_sorted_set('example', 'element', 1)
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
- expect{
96
- kvs.increment_sorted_set('example', 'element', 10)
97
- }.to change{ kvs.sorted_set_score('example', 'element') }.by(10)
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
- expect(sorted_set[0][0]).to eq('element1')
110
- expect(sorted_set[1][0]).to eq('element2')
111
- expect(sorted_set[2][0]).to eq('element5')
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
- it 'call sorted_set_score' do
116
- driver_class::session(driver_config) do |kvs|
117
- kvs.add_sorted_set('example', 'element5', 5)
118
- expect(kvs.sorted_set('example')[0][1]).to eq(5)
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
- it 'call count_sorted_set_member' do
123
- driver_class::session(driver_config) do |kvs|
124
- kvs.add_sorted_set('example', 'element1', 5)
125
- kvs.add_sorted_set('example', 'element2', 5)
126
- kvs.add_sorted_set('example', 'element3', 5)
127
- expect(kvs.count_sorted_set_member('example')).to eq(3)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kvs_driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - alfa-jpn