riik 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source :rubygems
2
2
 
3
3
  # Specify your gem's dependencies in riik.gemspec
4
4
  gemspec
5
+
6
+ gem 'tddium'
@@ -0,0 +1,92 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ riik (0.3.0)
5
+ excon
6
+ riak-client
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (3.0.5)
12
+ activesupport (= 3.0.5)
13
+ builder (~> 2.1.2)
14
+ i18n (~> 0.4)
15
+ activesupport (3.0.5)
16
+ addressable (2.2.6)
17
+ beefcake (0.3.2)
18
+ builder (2.1.2)
19
+ crack (0.3.1)
20
+ diff-lcs (1.1.3)
21
+ excon (0.7.12)
22
+ guard (0.8.8)
23
+ thor (~> 0.14.6)
24
+ guard-ctags-bundler (0.0.3)
25
+ guard (>= 0.4.0)
26
+ guard-rspec (0.5.7)
27
+ guard (>= 0.8.4)
28
+ guard-yard (1.0.2)
29
+ guard (>= 0.2.2)
30
+ yard (>= 0.7.0)
31
+ highline (1.6.8)
32
+ httparty (0.8.1)
33
+ multi_json
34
+ multi_xml
35
+ i18n (0.6.0)
36
+ json (1.6.1)
37
+ multi_json (1.0.4)
38
+ multi_xml (0.4.1)
39
+ rake (0.9.2.2)
40
+ rdoc (3.11)
41
+ json (~> 1.4)
42
+ redcarpet (1.17.2)
43
+ riak-client (0.9.8)
44
+ beefcake (= 0.3.2)
45
+ builder (~> 2.1.2)
46
+ i18n (>= 0.4.0)
47
+ ripple (0.9.5)
48
+ activemodel (~> 3.0.0)
49
+ activesupport (~> 3.0.0)
50
+ riak-client (~> 0.9.5)
51
+ rspec (2.7.0)
52
+ rspec-core (~> 2.7.0)
53
+ rspec-expectations (~> 2.7.0)
54
+ rspec-mocks (~> 2.7.0)
55
+ rspec-core (2.7.1)
56
+ rspec-expectations (2.7.0)
57
+ diff-lcs (~> 1.1.2)
58
+ rspec-mocks (2.7.0)
59
+ tddium (1.0.1)
60
+ bundler
61
+ highline
62
+ json
63
+ tddium_client (~> 0.1.1)
64
+ thor
65
+ tddium_client (0.1.2)
66
+ httparty
67
+ json
68
+ thor (0.14.6)
69
+ vcr (1.11.3)
70
+ webmock (1.7.8)
71
+ addressable (~> 2.2, > 2.2.5)
72
+ crack (>= 0.1.7)
73
+ yard (0.7.3)
74
+
75
+ PLATFORMS
76
+ ruby
77
+
78
+ DEPENDENCIES
79
+ guard
80
+ guard-ctags-bundler
81
+ guard-rspec
82
+ guard-yard
83
+ rake (~> 0.9.2)
84
+ rdoc
85
+ redcarpet
86
+ riik!
87
+ ripple
88
+ rspec
89
+ tddium
90
+ vcr
91
+ webmock
92
+ yard
@@ -104,13 +104,16 @@ module Riik
104
104
  # Create or return the current Riak client object.
105
105
  #
106
106
  # @return [Riak::RObject]
107
- # @private
108
107
  #
109
108
  def robject
110
- @robject ||= Riak::RObject.new(bucket).tap do |object|
109
+ key = self.respond_to?(:default_key) ? self.default_key : nil
110
+
111
+ @robject ||= Riak::RObject.new(bucket, key).tap do |object|
111
112
  object.content_type = "application/json"
112
113
  end
113
114
  end
114
115
  end
115
116
 
117
+
118
+
116
119
  end
@@ -1,3 +1,3 @@
1
1
  module Riik
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -38,4 +38,6 @@ Gem::Specification.new do |gem|
38
38
  gem.add_development_dependency('guard-rspec')
39
39
  gem.add_development_dependency('guard-yard')
40
40
  gem.add_development_dependency('guard-ctags-bundler')
41
+
42
+ gem.add_development_dependency('tddium')
41
43
  end
@@ -0,0 +1,34 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :put
5
+ uri: http://127.0.0.1:8098/riak/riik_defaultkeyperson/key-Fat?returnbody=true
6
+ body: ! '{"first_name":"Fat","last_name":"Mike"}'
7
+ headers:
8
+ accept:
9
+ - multipart/mixed, application/json;q=0.7, */*;q=0.5
10
+ x-riak-clientid:
11
+ - OR6jNQ==
12
+ content-type:
13
+ - application/json
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ x-riak-vclock:
20
+ - a85hYGBgzGDKBVIcypz/fvodtZDMYEpky2NlOLw65gRfFgA=
21
+ vary:
22
+ - Accept-Encoding
23
+ server:
24
+ - MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
25
+ link:
26
+ - </riak/riik_defaultkeyperson>; rel="up"
27
+ date:
28
+ - Wed, 14 Dec 2011 05:10:27 GMT
29
+ content-type:
30
+ - application/json
31
+ content-length:
32
+ - '39'
33
+ body: ! '{"first_name":"Fat","last_name":"Mike"}'
34
+ http_version: '1.1'
@@ -0,0 +1,36 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://127.0.0.1:8098/riak/riik_defaultkeyperson/key-Fat
6
+ body:
7
+ headers:
8
+ accept:
9
+ - multipart/mixed, application/json;q=0.7, */*;q=0.5
10
+ x-riak-clientid:
11
+ - OR6jNQ==
12
+ response: !ruby/struct:VCR::Response
13
+ status: !ruby/struct:VCR::ResponseStatus
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ x-riak-vclock:
18
+ - a85hYGBgzGDKBVIcypz/fvodtZDMYEpky2NlOLw65gRfFgA=
19
+ vary:
20
+ - Accept-Encoding
21
+ server:
22
+ - MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
23
+ link:
24
+ - </riak/riik_defaultkeyperson>; rel="up"
25
+ last-modified:
26
+ - Wed, 14 Dec 2011 03:34:45 GMT
27
+ etag:
28
+ - ! '"5ABAkxudMeKGIQ2rvyD947"'
29
+ date:
30
+ - Wed, 14 Dec 2011 05:10:27 GMT
31
+ content-type:
32
+ - application/json
33
+ content-length:
34
+ - '39'
35
+ body: ! '{"first_name":"Fat","last_name":"Mike"}'
36
+ http_version: '1.1'
@@ -1,6 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'ripple'
3
- require 'benchmark'
4
2
 
5
3
  module Riik
6
4
 
@@ -28,15 +26,15 @@ module Riik
28
26
  end
29
27
  end
30
28
 
31
- context 'when creating 300 records' do
29
+ context 'when creating 1000 records' do
32
30
  it 'is faster than ripple' do
33
31
  ripple_time = Benchmark.realtime do
34
- 300.times.each do |i|
32
+ 1000.times.each do |i|
35
33
  RippleDocument.create(:number => i)
36
34
  end
37
35
  end
38
36
  riik_time = Benchmark.realtime do
39
- 300.times.each do |i|
37
+ 1000.times.each do |i|
40
38
  RiikDocument.create(:number => i)
41
39
  end
42
40
  end
@@ -44,15 +42,15 @@ module Riik
44
42
  end
45
43
  end
46
44
 
47
- context 'when creating 1000 records' do
45
+ context 'when creating 10000 records' do
48
46
  it 'is faster than ripple' do
49
47
  ripple_time = Benchmark.realtime do
50
- 1000.times.each do |i|
48
+ 10000.times.each do |i|
51
49
  RippleDocument.create(:number => i)
52
50
  end
53
51
  end
54
52
  riik_time = Benchmark.realtime do
55
- 1000.times.each do |i|
53
+ 10000.times.each do |i|
56
54
  RiikDocument.create(:number => i)
57
55
  end
58
56
  end
@@ -18,6 +18,24 @@ module Riik
18
18
  end
19
19
  end
20
20
 
21
+ context 'once created with a default key' do
22
+ let(:person) do
23
+ VCR.use_cassette('creation_of_nonexistent_default_key') do
24
+ DefaultKeyPerson.create(attributes)
25
+ end
26
+ end
27
+
28
+ it 'should exist in riak correctly' do
29
+ VCR.use_cassette('loading_of_valid_default_key') do
30
+ subject.bucket.get(subject.default_key).should be_an_instance_of(Riak::RObject)
31
+
32
+ attributes.each do |key, value|
33
+ subject.send(key).should == value
34
+ end
35
+ end
36
+ end
37
+ end
38
+
21
39
  context 'once created' do
22
40
  let(:person) do
23
41
  VCR.use_cassette('creation_of_nonexistent_key') do
@@ -5,7 +5,11 @@ $LOAD_PATH << File.join(PROJECT_ROOT, "lib")
5
5
 
6
6
  Bundler.require
7
7
 
8
+ Dir[File.join(PROJECT_ROOT,"spec/support/**/*.rb")].each {|f| require f}
9
+
8
10
  require 'riik'
11
+ require 'ripple'
12
+ require 'benchmark'
9
13
 
10
14
  require 'vcr'
11
15
 
@@ -24,4 +28,22 @@ module Riik
24
28
  property :first_name
25
29
  property :last_name
26
30
  end
31
+
32
+ class DefaultKeyPerson
33
+ include Riik::Document
34
+
35
+ property :first_name
36
+ property :last_name
37
+
38
+ def default_key
39
+ "key-#{first_name}"
40
+ end
41
+ end
42
+ end
43
+
44
+ # Ripple configuration.
45
+ #
46
+ if ENV['TDDIUM_RIAK_HOST']
47
+ Riik.client = Riak::Client.new({:host => ENV['TDDIUM_RIAK_HOST'], :http_port => ENV['TDDIUM_RIAK_HTTP_PORT'].to_i})
48
+ Ripple.client = Riak::Client.new({:host => ENV['TDDIUM_RIAK_HOST'], :http_port => ENV['TDDIUM_RIAK_HTTP_PORT'].to_i})
27
49
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-02 00:00:00.000000000 Z
12
+ date: 2011-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: riak-client
16
- requirement: &11983080 !ruby/object:Gem::Requirement
16
+ requirement: &6801680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *11983080
24
+ version_requirements: *6801680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: excon
27
- requirement: &11982220 !ruby/object:Gem::Requirement
27
+ requirement: &6800200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *11982220
35
+ version_requirements: *6800200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &11981240 !ruby/object:Gem::Requirement
38
+ requirement: &6798460 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *11981240
46
+ version_requirements: *6798460
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &11980600 !ruby/object:Gem::Requirement
49
+ requirement: &6797700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *11980600
57
+ version_requirements: *6797700
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: redcarpet
60
- requirement: &11980100 !ruby/object:Gem::Requirement
60
+ requirement: &6797080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *11980100
68
+ version_requirements: *6797080
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: vcr
71
- requirement: &11979540 !ruby/object:Gem::Requirement
71
+ requirement: &6795880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *11979540
79
+ version_requirements: *6795880
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: webmock
82
- requirement: &11979020 !ruby/object:Gem::Requirement
82
+ requirement: &6794860 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *11979020
90
+ version_requirements: *6794860
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rspec
93
- requirement: &11978500 !ruby/object:Gem::Requirement
93
+ requirement: &6793980 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *11978500
101
+ version_requirements: *6793980
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &11977820 !ruby/object:Gem::Requirement
104
+ requirement: &6808420 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.9.2
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *11977820
112
+ version_requirements: *6808420
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: ripple
115
- requirement: &11977240 !ruby/object:Gem::Requirement
115
+ requirement: &6807280 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *11977240
123
+ version_requirements: *6807280
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard
126
- requirement: &12025440 !ruby/object:Gem::Requirement
126
+ requirement: &6805440 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *12025440
134
+ version_requirements: *6805440
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: guard-rspec
137
- requirement: &12024880 !ruby/object:Gem::Requirement
137
+ requirement: &6804460 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *12024880
145
+ version_requirements: *6804460
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard-yard
148
- requirement: &12024380 !ruby/object:Gem::Requirement
148
+ requirement: &6803340 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *12024380
156
+ version_requirements: *6803340
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: guard-ctags-bundler
159
- requirement: &12023860 !ruby/object:Gem::Requirement
159
+ requirement: &6801980 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,7 +164,18 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *12023860
167
+ version_requirements: *6801980
168
+ - !ruby/object:Gem::Dependency
169
+ name: tddium
170
+ requirement: &7472780 !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: *7472780
168
179
  description: Lightweight object mapper for Riak.
169
180
  email:
170
181
  - cmeiklejohn@criticalpair.com
@@ -178,6 +189,7 @@ files:
178
189
  - .travis.yml
179
190
  - .yardopts
180
191
  - Gemfile
192
+ - Gemfile.lock
181
193
  - Guardfile
182
194
  - LICENSE
183
195
  - README.markdown
@@ -189,8 +201,10 @@ files:
189
201
  - lib/riik/document/persistence.rb
190
202
  - lib/riik/version.rb
191
203
  - riik.gemspec
204
+ - spec/fixtures/vcr_cassettes/creation_of_nonexistent_default_key.yml
192
205
  - spec/fixtures/vcr_cassettes/creation_of_nonexistent_key.yml
193
206
  - spec/fixtures/vcr_cassettes/deletion_of_valid_key.yml
207
+ - spec/fixtures/vcr_cassettes/loading_of_valid_default_key.yml
194
208
  - spec/fixtures/vcr_cassettes/loading_of_valid_key.yml
195
209
  - spec/fixtures/vcr_cassettes/updating_of_valid_key.yml
196
210
  - spec/lib/performance_spec.rb
@@ -199,6 +213,7 @@ files:
199
213
  - spec/lib/riik/document_spec.rb
200
214
  - spec/lib/riik_spec.rb
201
215
  - spec/spec_helper.rb
216
+ - spec/support/.gitkeep
202
217
  homepage: http://critialpair.com
203
218
  licenses: []
204
219
  post_install_message:
@@ -213,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
228
  version: '0'
214
229
  segments:
215
230
  - 0
216
- hash: -3432467302917107998
231
+ hash: -21663660701635647
217
232
  required_rubygems_version: !ruby/object:Gem::Requirement
218
233
  none: false
219
234
  requirements:
@@ -222,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
237
  version: '0'
223
238
  segments:
224
239
  - 0
225
- hash: -3432467302917107998
240
+ hash: -21663660701635647
226
241
  requirements: []
227
242
  rubyforge_project:
228
243
  rubygems_version: 1.8.11