riak-shim 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/FUTURE_WORK.md +1 -2
- data/Gemfile +0 -1
- data/Guardfile +1 -1
- data/lib/riak-shim/store.rb +14 -3
- data/lib/riak-shim/version.rb +1 -1
- data/riak-shim.gemspec +4 -4
- data/spec/persistable_spec.rb +3 -3
- data/spec/store_spec.rb +27 -0
- metadata +25 -16
data/FUTURE_WORK.md
CHANGED
@@ -22,7 +22,6 @@ unhappy with the current interface.
|
|
22
22
|
- Keep expanding tests
|
23
23
|
- find less horrible way to deal with index names
|
24
24
|
- find less horrible way to deal with key accessor
|
25
|
-
- nice error message when
|
26
|
-
- nice error ,essage when back end doesn't support 2i
|
25
|
+
- nice error message when back end doesn't support 2i
|
27
26
|
- nice error message when secondary index is missing?
|
28
27
|
|
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/lib/riak-shim/store.rb
CHANGED
@@ -14,13 +14,16 @@ module Riak
|
|
14
14
|
|
15
15
|
DEFAULT_CONFIG_LOCATION = 'config/database.yml'
|
16
16
|
|
17
|
-
#
|
17
|
+
# Raised when we can't find a configuration which matches the
|
18
18
|
# current RACK_ENV
|
19
19
|
class NoSettingsForCurrentEnvError < StandardError; end
|
20
20
|
|
21
|
-
#
|
21
|
+
# Raised when the RACK_ENV environment variable is not set
|
22
22
|
class RackEnvNotSetError < StandardError; end
|
23
23
|
|
24
|
+
# Raised when we can't connect to Riak
|
25
|
+
class ConnectionError < StandardError; end
|
26
|
+
|
24
27
|
# @return [Hash] the configuration for our current environment
|
25
28
|
def config
|
26
29
|
env = ENV['RACK_ENV'] or raise RackEnvNotSetError.new
|
@@ -44,8 +47,16 @@ module Riak
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def riak
|
47
|
-
@riak
|
50
|
+
return @riak if @riak
|
51
|
+
|
52
|
+
@riak = Riak::Client.new(:http_backend => :Excon,
|
48
53
|
:nodes => [{:host => config['host'], :http_port => config['http_port']}])
|
54
|
+
unless @riak.ping
|
55
|
+
@riak = nil
|
56
|
+
raise ConnectionError.new("Could not connect to Riak at #{config['host']}:#{config['http_port']}")
|
57
|
+
end
|
58
|
+
|
59
|
+
@riak
|
49
60
|
end
|
50
61
|
|
51
62
|
# @return [Riak::Bucket] the bucket coresponding to name
|
data/lib/riak-shim/version.rb
CHANGED
data/riak-shim.gemspec
CHANGED
@@ -15,10 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Riak::Shim::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency 'riak-client', '~>1.
|
19
|
-
gem.add_dependency 'excon', '~>0.
|
20
|
-
gem.add_dependency 'uuidtools', '~>2.1.
|
21
|
-
|
18
|
+
gem.add_dependency 'riak-client', '~>1.2.0'
|
19
|
+
gem.add_dependency 'excon', '~>0.22.1'
|
20
|
+
gem.add_dependency 'uuidtools', '~>2.1.4'
|
21
|
+
gem.add_dependency 'json'
|
22
22
|
gem.add_development_dependency 'rake'
|
23
23
|
gem.add_development_dependency 'rspec'
|
24
24
|
gem.add_development_dependency 'gem-release'
|
data/spec/persistable_spec.rb
CHANGED
@@ -33,15 +33,15 @@ class PersistableExampleWithIndex < PersistableExample
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def create_test_data(
|
37
|
-
|
36
|
+
def create_test_data(quantity)
|
37
|
+
quantity.times do |i|
|
38
38
|
p = PersistableExample.new
|
39
39
|
p.foo, p.bar, p.baz = i, i, i
|
40
40
|
p.save
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe
|
44
|
+
describe Riak::Shim::Persistable do
|
45
45
|
let(:persistable) do
|
46
46
|
p = PersistableExample.new ; p.foo = 'boo' ; p.bar = 'who' ; p
|
47
47
|
end
|
data/spec/store_spec.rb
CHANGED
@@ -4,6 +4,18 @@ require 'riak-shim/store'
|
|
4
4
|
describe Riak::Shim::Store do
|
5
5
|
let(:store) { Riak::Shim::Store.new }
|
6
6
|
|
7
|
+
# Port finding code stolen without remorse from realweb
|
8
|
+
PORT_RANGE = 8000..10000
|
9
|
+
def find_port
|
10
|
+
begin
|
11
|
+
port = random_port
|
12
|
+
end while system("lsof -i tcp:#{port} > /dev/null")
|
13
|
+
port
|
14
|
+
end
|
15
|
+
|
16
|
+
def random_port
|
17
|
+
PORT_RANGE.to_a[rand(PORT_RANGE.to_a.size)]
|
18
|
+
end
|
7
19
|
|
8
20
|
describe '#config_location' do
|
9
21
|
it 'keeps a path of the database config file' do
|
@@ -53,6 +65,21 @@ describe Riak::Shim::Store do
|
|
53
65
|
expect { store.config }.to raise_error(Riak::Shim::Store::RackEnvNotSetError)
|
54
66
|
end
|
55
67
|
end
|
68
|
+
|
69
|
+
context 'with no riak at specified coordinates' do
|
70
|
+
before do
|
71
|
+
store.config['host'] = 'localhost'
|
72
|
+
store.config['http_port'] = find_port
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'raises an informative exception' do
|
76
|
+
expect { store.riak }.to raise_error(Riak::Shim::Store::ConnectionError)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'includes an informative message' do
|
80
|
+
expect { store.riak }.to raise_error(/Could not connect to Riak at/)
|
81
|
+
end
|
82
|
+
end
|
56
83
|
end
|
57
84
|
|
58
85
|
describe '#config' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak-shim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riak-client
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: excon
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.22.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.22.1
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: uuidtools
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.1.
|
53
|
+
version: 2.1.4
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,23 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.1.
|
61
|
+
version: 2.1.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rake
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,21 +225,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
225
|
- - ! '>='
|
210
226
|
- !ruby/object:Gem::Version
|
211
227
|
version: '0'
|
212
|
-
segments:
|
213
|
-
- 0
|
214
|
-
hash: -1927379052997659791
|
215
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
229
|
none: false
|
217
230
|
requirements:
|
218
231
|
- - ! '>='
|
219
232
|
- !ruby/object:Gem::Version
|
220
233
|
version: '0'
|
221
|
-
segments:
|
222
|
-
- 0
|
223
|
-
hash: -1927379052997659791
|
224
234
|
requirements: []
|
225
235
|
rubyforge_project:
|
226
|
-
rubygems_version: 1.8.
|
236
|
+
rubygems_version: 1.8.25
|
227
237
|
signing_key:
|
228
238
|
specification_version: 3
|
229
239
|
summary: A tiny shim between you and riak-client. Reads config/database.yml and generates
|
@@ -234,4 +244,3 @@ test_files:
|
|
234
244
|
- spec/store_spec.rb
|
235
245
|
- spec/support/camelcase.rb
|
236
246
|
- spec/support/database.yml
|
237
|
-
has_rdoc:
|