rails_kvs_driver 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/rails_kvs_driver.rb +246 -0
- data/lib/rails_kvs_driver/version.rb +3 -0
- data/rails_kvs_driver.gemspec +27 -0
- data/spec/rails_kvs_driver_spec.rb +150 -0
- data/spec/spec_helper.rb +7 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fbaf6fd75ff39b74ea85707b45a3500cca71e3a8
|
4
|
+
data.tar.gz: d2b015e79daa282a8fd27c29b393d19506c6a078
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6648bdb2a961f6c47cef36b5c7b5d51b88a66a1a4efe7749b1c8341c5f8242ecfb1938d28b791b3ff24858f8ade7adcb2a2eabdabb399e0c5075dee44f9393f7
|
7
|
+
data.tar.gz: bd42ee65d4696cb8cc5914619a1615e01670788b513945cf40ec9136ba5bf6f5dcb69c66ee8387586fdd2fb1c71e70279317c7e76f1ae90e63c57427bb7cf1eb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Atsushi Nakamura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# RailsKvsDriver
|
2
|
+
|
3
|
+
rails kvs driver wrap access key-value store.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rails_kvs_driver'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rails_kvs_driver
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
comming soon.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,246 @@
|
|
1
|
+
require 'rails_kvs_driver/version'
|
2
|
+
require 'connection_pool'
|
3
|
+
|
4
|
+
module RailsKvsDriver
|
5
|
+
# This abstract class wrap accessing to Key-Value Store.
|
6
|
+
# @abstract
|
7
|
+
class Base
|
8
|
+
|
9
|
+
# @attr DriverConnectionPool [Hash] This Constants pools the connecting driver.
|
10
|
+
# {
|
11
|
+
# driver_class_name => [{:config => driver_config, :pool => ConnectionPool }, .... ]
|
12
|
+
#
|
13
|
+
# ...
|
14
|
+
#
|
15
|
+
# }
|
16
|
+
DriverConnectionPool = Hash.new
|
17
|
+
|
18
|
+
# @attr @kvs_instance [Object] instance of KVS.
|
19
|
+
attr_accessor :kvs_instance
|
20
|
+
|
21
|
+
# @attr @driver_config [Hash] config of driver.
|
22
|
+
# {
|
23
|
+
# :host => 'localhost' # host of KVS.
|
24
|
+
# :port => 6379 # port of KVS.
|
25
|
+
# :namespace => 'Example' # namespace of avoid a conflict with key
|
26
|
+
# :timeout_sec => 5 # timeout seconds.
|
27
|
+
# :pool_size => 5 # connection pool size.
|
28
|
+
# }
|
29
|
+
attr_accessor :driver_config
|
30
|
+
|
31
|
+
# initialize driver, and connect kvs.
|
32
|
+
# @param driver_config [Hash] driver config.
|
33
|
+
def initialize(driver_config)
|
34
|
+
@driver_config = validate_driver_config!(driver_config)
|
35
|
+
connect
|
36
|
+
end
|
37
|
+
|
38
|
+
# connect with driver config.
|
39
|
+
# @return [Boolean] result
|
40
|
+
def connect
|
41
|
+
raise NoMethodError
|
42
|
+
end
|
43
|
+
|
44
|
+
# get value from kvs.
|
45
|
+
# @param key [String] key.
|
46
|
+
# @return [String] value
|
47
|
+
# @abstract get value from kvs.
|
48
|
+
def [](key)
|
49
|
+
raise NoMethodError
|
50
|
+
end
|
51
|
+
|
52
|
+
# set value to kvs.
|
53
|
+
# @param key [String] key.
|
54
|
+
# @param value [String] value.
|
55
|
+
# @return [Boolean] result
|
56
|
+
# @abstract set value to kvs.
|
57
|
+
def []=(key, value)
|
58
|
+
raise NoMethodError
|
59
|
+
end
|
60
|
+
|
61
|
+
# get all keys from kvs.
|
62
|
+
# @return [Array<String>] array of key names.
|
63
|
+
# @abstract get all keys from kvs.
|
64
|
+
def all_keys
|
65
|
+
raise NoMethodError
|
66
|
+
end
|
67
|
+
|
68
|
+
# delete key from kvs.
|
69
|
+
# @return [Boolean] result.
|
70
|
+
# @abstract delete key from kvs.
|
71
|
+
def delete(key)
|
72
|
+
raise NoMethodError
|
73
|
+
end
|
74
|
+
|
75
|
+
# delete all keys from kvs.
|
76
|
+
# @return [Boolean] result.
|
77
|
+
# @abstract delete all keys from kvs.
|
78
|
+
def delete_all(key)
|
79
|
+
raise NoMethodError
|
80
|
+
end
|
81
|
+
|
82
|
+
# add sorted set to kvs.
|
83
|
+
# when the key doesn't exist, it's made newly.
|
84
|
+
# @note same as sorted set of redis. refer to redis.
|
85
|
+
#
|
86
|
+
# @param key [String] key of sorted set.
|
87
|
+
# @param member [String] member of sorted set.
|
88
|
+
# @param score [Float] score of sorted set.
|
89
|
+
# @return [Boolean] result.
|
90
|
+
# @abstract add sorted set to kvs.
|
91
|
+
def add_sorted_set(key, member, score)
|
92
|
+
raise NoMethodError
|
93
|
+
end
|
94
|
+
|
95
|
+
# remove sorted set from kvs.
|
96
|
+
# This function doesn't delete a key.
|
97
|
+
# @note same as sorted set of redis. refer to redis.
|
98
|
+
#
|
99
|
+
# @param key [String] key of sorted set.
|
100
|
+
# @param member [String] member of sorted set.
|
101
|
+
# @return [Boolean] result.
|
102
|
+
# @abstract remove sorted set from kvs.
|
103
|
+
def remove_sorted_set(key, member)
|
104
|
+
raise NoMethodError
|
105
|
+
end
|
106
|
+
|
107
|
+
# increment score of member from sorted set.
|
108
|
+
# @note same as sorted set of redis. refer to redis.
|
109
|
+
#
|
110
|
+
# @param key [String] key of sorted set.
|
111
|
+
# @param member [String] member of sorted set.
|
112
|
+
# @param score [Float] increment score.
|
113
|
+
# @return [Float] value after increment
|
114
|
+
# @abstract increment score of member from sorted set.
|
115
|
+
def increment_sorted_set(key, member, score)
|
116
|
+
raise NoMethodError
|
117
|
+
end
|
118
|
+
|
119
|
+
# get the score of member.
|
120
|
+
# @note same as sorted set of redis. refer to redis.
|
121
|
+
#
|
122
|
+
# @param key [String] key of sorted set.
|
123
|
+
# @param member [String] member of sorted set.
|
124
|
+
# @return [Float] score of member.
|
125
|
+
# @abstract get the score of member.
|
126
|
+
def get_sorted_set_score(key, member)
|
127
|
+
raise NoMethodError
|
128
|
+
end
|
129
|
+
|
130
|
+
# get array of sorted set.
|
131
|
+
# @note same as sorted set of redis. refer to redis.
|
132
|
+
#
|
133
|
+
# @param key [String] key of sorted set.
|
134
|
+
# @param start [Integer] start index
|
135
|
+
# @param stop [Integer] stop index
|
136
|
+
# @param reverse [Boolean] order by desc
|
137
|
+
# @return [Array<String, Float>>] array of the member and score.
|
138
|
+
# @abstract get array of sorted set.
|
139
|
+
def get_sorted_set(key, start=0, stop=-1, reverse=false)
|
140
|
+
raise NoMethodError
|
141
|
+
end
|
142
|
+
|
143
|
+
# count members of sorted set
|
144
|
+
# @note same as sorted set of redis. refer to redis.
|
145
|
+
#
|
146
|
+
# @param key [String] key of sorted set.
|
147
|
+
# @return [Integer] members num
|
148
|
+
def count_sorted_set_member(key)
|
149
|
+
raise NoMethodError
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
# connect kvs and exec block.
|
154
|
+
# This function pools the connecting driver.
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
# config = {
|
158
|
+
# :host => 'localhost' # host of KVS.
|
159
|
+
# :port => 6379 # port of KVS.
|
160
|
+
# :namespace => 'Example' # namespace of avoid a conflict with key
|
161
|
+
# :timeout_sec => 5 # timeout seconds.
|
162
|
+
# :pool_size => 5 # connection pool size.
|
163
|
+
# }
|
164
|
+
# result = Driver.session(config) do |kvs|
|
165
|
+
# kvs['example'] = 'abc'
|
166
|
+
# kvs['example']
|
167
|
+
# end
|
168
|
+
#
|
169
|
+
# puts result # => 'abc'
|
170
|
+
#
|
171
|
+
# @param driver_config [Hash] driver_config.
|
172
|
+
# @param &block [{|driver_instance| #something... }] exec block.
|
173
|
+
# @return [Object] status
|
174
|
+
def self.session(driver_config, &block)
|
175
|
+
driver_connection_pool(self, driver_config).with &block
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
private
|
180
|
+
# get driver connection pool
|
181
|
+
# if doesn't exist pool, it's made newly.
|
182
|
+
#
|
183
|
+
# @param driver_class [RailsKvsDriver::Base] driver_class
|
184
|
+
# @param driver_config [Hash] driver_config
|
185
|
+
# @return [ConnectionPool] connection pool of driver
|
186
|
+
def self.driver_connection_pool(driver_class, driver_config)
|
187
|
+
pool = search_driver_connection_pool(driver_class, driver_config)
|
188
|
+
return (pool.nil?) ? set_driver_connection_pool(driver_class, driver_config) : pool
|
189
|
+
end
|
190
|
+
|
191
|
+
# set driver connection pool
|
192
|
+
#
|
193
|
+
# @param driver_class [RailsKvsDriver::Base] driver_class
|
194
|
+
# @param driver_config [Hash] driver_config
|
195
|
+
# @return [ConnectionPool] connection pool of driver
|
196
|
+
def self.set_driver_connection_pool(driver_class, driver_config)
|
197
|
+
conf = {
|
198
|
+
size: driver_config[:pool_size],
|
199
|
+
timeout: driver_config[:timeout_sec]
|
200
|
+
}
|
201
|
+
pool = ConnectionPool.new(conf) { driver_class.new(driver_config) }
|
202
|
+
|
203
|
+
DriverConnectionPool[driver_class.name] = Array.new unless DriverConnectionPool.has_key?(driver_class.name)
|
204
|
+
DriverConnectionPool[driver_class.name].push({config: driver_config, pool: pool})
|
205
|
+
|
206
|
+
return pool
|
207
|
+
end
|
208
|
+
|
209
|
+
# search driver connection pool
|
210
|
+
#
|
211
|
+
# @param driver_class [RailsKvsDriver::Base] driver_class
|
212
|
+
# @param driver_config [Hash] driver_config
|
213
|
+
# @return [ConnectionPool] connection pool of driver, or nil
|
214
|
+
def self.search_driver_connection_pool(driver_class, driver_config)
|
215
|
+
DriverConnectionPool[driver_class.name].each do |pool_set|
|
216
|
+
if pool_set[:config] == driver_config
|
217
|
+
return pool_set[:pool]
|
218
|
+
end
|
219
|
+
end if DriverConnectionPool.has_key?(driver_class.name)
|
220
|
+
|
221
|
+
return nil
|
222
|
+
end
|
223
|
+
|
224
|
+
# Validate driver_config.
|
225
|
+
# This method raise ArgumentError, if missing driver_config.
|
226
|
+
#
|
227
|
+
# @param driver_config [Hash] driver config.
|
228
|
+
# @return [Hash] driver_config
|
229
|
+
def validate_driver_config!(driver_config)
|
230
|
+
raise_argument_error!(:host) unless driver_config.has_key? :host
|
231
|
+
raise_argument_error!(:port) unless driver_config.has_key? :port
|
232
|
+
raise_argument_error!(:namespace) unless driver_config.has_key? :namespace
|
233
|
+
raise_argument_error!(:timeout_sec) unless driver_config.has_key? :timeout_sec
|
234
|
+
raise_argument_error!(:pool_size) unless driver_config.has_key? :pool_size
|
235
|
+
|
236
|
+
return driver_config
|
237
|
+
end
|
238
|
+
|
239
|
+
# raise argument error.
|
240
|
+
#
|
241
|
+
# @param key [String] not exists key.
|
242
|
+
def raise_argument_error!(key)
|
243
|
+
raise "driver_config does not include #{key}", ArgumentError
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_kvs_driver/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_kvs_driver"
|
8
|
+
spec.version = RailsKvsDriver::VERSION
|
9
|
+
spec.authors = ["alfa-jpn"]
|
10
|
+
spec.email = ["a.nkmr.ja@gmail.com"]
|
11
|
+
spec.description = "rails kvs driver wrap access key-value store."
|
12
|
+
spec.summary = "rails kvs driver wrap access key-value store."
|
13
|
+
spec.homepage = "https://github.com/alfa-jpn/rails-kvs-driver"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "yard"
|
25
|
+
|
26
|
+
spec.add_dependency "connection_pool"
|
27
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'rails_kvs_driver'
|
4
|
+
|
5
|
+
describe RailsKvsDriver do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@driver_config = {
|
9
|
+
:host => 'localhost', # host of KVS.
|
10
|
+
:port => 6379, # port of KVS.
|
11
|
+
:namespace => 'Example', # namespace of avoid a conflict with key
|
12
|
+
:timeout_sec => 5, # timeout seconds.
|
13
|
+
:pool_size => 5, # connection pool size.
|
14
|
+
}
|
15
|
+
|
16
|
+
class MockDriver < RailsKvsDriver::Base
|
17
|
+
def connect
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'raise NoMethodError when does not override connect' do
|
24
|
+
expect{RailsKvsDriver::Base.new}.to raise_error
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'raise NoMethodError when does not override []' do
|
28
|
+
expect{MockDriver.new.respond_to?('[]')}.to be_true
|
29
|
+
expect{MockDriver.new['a']}.to raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raise NoMethodError when does not override []=' do
|
33
|
+
expect{MockDriver.new.respond_to?('[]=')}.to be_true
|
34
|
+
expect{MockDriver.new['a']='b'}.to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'raise NoMethodError when does not override all_keys' do
|
38
|
+
expect{MockDriver.new.respond_to?(:all_keys)}.to be_true
|
39
|
+
expect{MockDriver.new.all_keys}.to raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'raise NoMethodError when does not override delete' do
|
43
|
+
expect{MockDriver.new.respond_to?(:delete)}.to be_true
|
44
|
+
expect{MockDriver.new.delete}.to raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'raise NoMethodError when does not override delete_all' do
|
48
|
+
expect{MockDriver.new.respond_to?(:delete_all)}.to be_true
|
49
|
+
expect{MockDriver.new.delete_all}.to raise_error
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'raise NoMethodError when does not override add_sorted_set' do
|
53
|
+
expect{MockDriver.new.respond_to?(:add_sorted_set)}.to be_true
|
54
|
+
expect{MockDriver.new.add_sorted_set}.to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raise NoMethodError when does not override remove_sorted_set' do
|
58
|
+
expect{MockDriver.new.respond_to?(:remove_sorted_set)}.to be_true
|
59
|
+
expect{MockDriver.new.remove_sorted_set}.to raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'raise NoMethodError when does not override increment_sorted_set' do
|
63
|
+
expect{MockDriver.new.respond_to?(:increment_sorted_set)}.to be_true
|
64
|
+
expect{MockDriver.new.increment_sorted_set}.to raise_error
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raise NoMethodError when does not override get_sorted_set' do
|
68
|
+
expect{MockDriver.new.respond_to?(:get_sorted_set)}.to be_true
|
69
|
+
expect{MockDriver.new.get_sorted_set}.to raise_error
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'raise NoMethodError when does not override count_sorted_set_member' do
|
73
|
+
expect{MockDriver.new.respond_to?(:count_sorted_set_member)}.to be_true
|
74
|
+
expect{MockDriver.new.count_sorted_set_member}.to raise_error
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'call initialize' do
|
78
|
+
it 'exec validation' do
|
79
|
+
expect{ MockDriver.new(@driver_config) }.not_to raise_error
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'coping instance of driver_config' do
|
83
|
+
expect(MockDriver.new(@driver_config).driver_config).to eq(@driver_config)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'call validate_driver_config' do
|
88
|
+
it 'raise ArgumentError when there is not host.' do
|
89
|
+
@driver_config.delete(:host)
|
90
|
+
expect{ MockDriver.new(@driver_config) }.to raise_error
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'raise ArgumentError when there is not port.' do
|
94
|
+
@driver_config.delete(:port)
|
95
|
+
expect{ MockDriver.new(@driver_config) }.to raise_error
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'raise ArgumentError when there is not namespace.' do
|
99
|
+
@driver_config.delete(:namespace)
|
100
|
+
expect{ MockDriver.new(@driver_config) }.to raise_error
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'raise ArgumentError when there is not timeout_sec.' do
|
104
|
+
@driver_config.delete(:timeout_sec)
|
105
|
+
expect{ MockDriver.new(@driver_config) }.to raise_error
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'raise ArgumentError when there is not pool_size.' do
|
109
|
+
@driver_config.delete(:pool_size)
|
110
|
+
expect{ MockDriver.new(@driver_config) }.to raise_error
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'call session' do
|
115
|
+
before(:each) do
|
116
|
+
class MockDriver2 < RailsKvsDriver::Base
|
117
|
+
def connect
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'DriverConnectionPool is same instance.' do
|
123
|
+
expect(MockDriver::DriverConnectionPool.equal?(RailsKvsDriver::Base::DriverConnectionPool)).to be_true
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'to hand over driver instance to the block' do
|
127
|
+
MockDriver.session(@driver_config) do |instance|
|
128
|
+
expect(instance.class).to eq(MockDriver)
|
129
|
+
end
|
130
|
+
|
131
|
+
MockDriver2.session(@driver_config) do |instance|
|
132
|
+
expect(instance.class).to eq(MockDriver2)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'The structure of DriverConnectionPool is correct.' do
|
137
|
+
MockDriver.session(@driver_config) {}
|
138
|
+
MockDriver2.session(@driver_config) {}
|
139
|
+
MockDriver2.session(@driver_config.merge(a:0)) {}
|
140
|
+
MockDriver2.session(@driver_config.merge(a:1)) {}
|
141
|
+
|
142
|
+
expect(MockDriver::DriverConnectionPool.length).to eq(2)
|
143
|
+
expect(MockDriver::DriverConnectionPool['MockDriver2'].length).to eq(3)
|
144
|
+
expect(MockDriver::DriverConnectionPool['MockDriver2'][0].length).to eq(2)
|
145
|
+
expect(MockDriver::DriverConnectionPool['MockDriver2'][0].has_key? :config).to be_true
|
146
|
+
expect(MockDriver::DriverConnectionPool['MockDriver2'][0].has_key? :pool).to be_true
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_kvs_driver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alfa-jpn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: connection_pool
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: rails kvs driver wrap access key-value store.
|
84
|
+
email:
|
85
|
+
- a.nkmr.ja@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/rails_kvs_driver.rb
|
96
|
+
- lib/rails_kvs_driver/version.rb
|
97
|
+
- rails_kvs_driver.gemspec
|
98
|
+
- spec/rails_kvs_driver_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: https://github.com/alfa-jpn/rails-kvs-driver
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.0.3
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: rails kvs driver wrap access key-value store.
|
124
|
+
test_files:
|
125
|
+
- spec/rails_kvs_driver_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
has_rdoc:
|