riak-client 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Rakefile +74 -0
  2. data/lib/riak.rb +49 -0
  3. data/lib/riak/bucket.rb +176 -0
  4. data/lib/riak/cache_store.rb +82 -0
  5. data/lib/riak/client.rb +139 -0
  6. data/lib/riak/client/curb_backend.rb +82 -0
  7. data/lib/riak/client/http_backend.rb +209 -0
  8. data/lib/riak/client/net_http_backend.rb +49 -0
  9. data/lib/riak/failed_request.rb +37 -0
  10. data/lib/riak/i18n.rb +20 -0
  11. data/lib/riak/invalid_response.rb +25 -0
  12. data/lib/riak/link.rb +73 -0
  13. data/lib/riak/locale/en.yml +37 -0
  14. data/lib/riak/map_reduce.rb +248 -0
  15. data/lib/riak/map_reduce_error.rb +20 -0
  16. data/lib/riak/robject.rb +267 -0
  17. data/lib/riak/util/escape.rb +12 -0
  18. data/lib/riak/util/fiber1.8.rb +48 -0
  19. data/lib/riak/util/headers.rb +44 -0
  20. data/lib/riak/util/multipart.rb +52 -0
  21. data/lib/riak/util/translation.rb +29 -0
  22. data/lib/riak/walk_spec.rb +117 -0
  23. data/spec/fixtures/cat.jpg +0 -0
  24. data/spec/fixtures/multipart-blank.txt +7 -0
  25. data/spec/fixtures/multipart-with-body.txt +16 -0
  26. data/spec/integration/riak/cache_store_spec.rb +129 -0
  27. data/spec/riak/bucket_spec.rb +247 -0
  28. data/spec/riak/client_spec.rb +174 -0
  29. data/spec/riak/curb_backend_spec.rb +53 -0
  30. data/spec/riak/escape_spec.rb +21 -0
  31. data/spec/riak/headers_spec.rb +34 -0
  32. data/spec/riak/http_backend_spec.rb +131 -0
  33. data/spec/riak/link_spec.rb +82 -0
  34. data/spec/riak/map_reduce_spec.rb +352 -0
  35. data/spec/riak/multipart_spec.rb +36 -0
  36. data/spec/riak/net_http_backend_spec.rb +28 -0
  37. data/spec/riak/object_spec.rb +538 -0
  38. data/spec/riak/walk_spec_spec.rb +208 -0
  39. data/spec/spec_helper.rb +30 -0
  40. data/spec/support/http_backend_implementation_examples.rb +215 -0
  41. data/spec/support/mock_server.rb +61 -0
  42. data/spec/support/mocks.rb +3 -0
  43. metadata +187 -0
@@ -0,0 +1,61 @@
1
+ # Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Based on code from Rob Styles and Chris Tierney found at:
16
+ # http://dynamicorange.com/2009/02/18/ruby-mock-web-server/
17
+ require 'rack'
18
+
19
+ class MockServer
20
+ attr_accessor :port
21
+
22
+ def initialize(pause = 1)
23
+ self.port = 4000 + rand(61535)
24
+ @block = nil
25
+ @parent_thread = Thread.current
26
+ @thread = Thread.new do
27
+ Rack::Handler::WEBrick.run(self, :Port => port, :AccessLog => [], :Logger => NullLogger.new, :Host => '127.0.0.1')
28
+ end
29
+ sleep pause # give the server time to fire up… YUK!
30
+ end
31
+
32
+ def stop
33
+ Thread.kill(@thread)
34
+ end
35
+
36
+ def attach(&block)
37
+ @block = block
38
+ end
39
+
40
+ def detach()
41
+ @block = nil
42
+ end
43
+
44
+ def call(env)
45
+ begin
46
+ raise "Specify a handler for the request using attach(block), the block should return a valid rack response and can test expectations" unless @block
47
+ @block.call(env)
48
+ rescue Exception => e
49
+ @parent_thread.raise e
50
+ [ 500, { 'Content-Type' => 'text/plain', 'Content-Length' => '13' }, [ 'Bad test code' ]]
51
+ end
52
+ end
53
+
54
+ class NullLogger
55
+ def fatal(msg) end
56
+ def error(msg) end
57
+ def warn(msg) end
58
+ def info(msg) end
59
+ def debug(msg) end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ def mock_response(overrides={})
2
+ {:headers => {"content-type" => ["application/json"]}, :body => '{}'}.merge(overrides)
3
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riak-client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 7
8
+ - 0
9
+ version: 0.7.0
10
+ platform: ruby
11
+ authors:
12
+ - Sean Cribbs
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-06 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 0
30
+ - 0
31
+ - beta
32
+ - 6
33
+ version: 2.0.0.beta.6
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: fakeweb
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 1
45
+ - 2
46
+ version: "1.2"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rack
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 0
59
+ version: "1.0"
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: curb
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ - 6
72
+ version: "0.6"
73
+ type: :development
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: activesupport
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 2
84
+ - 3
85
+ - 5
86
+ version: 2.3.5
87
+ type: :runtime
88
+ version_requirements: *id005
89
+ description: riak-client is a rich client for Riak, the distributed database by Basho. It supports the full HTTP interface including storage operations, bucket configuration, link-walking and map-reduce.
90
+ email: seancribbs@gmail.com
91
+ executables: []
92
+
93
+ extensions: []
94
+
95
+ extra_rdoc_files: []
96
+
97
+ files:
98
+ - lib/riak/bucket.rb
99
+ - lib/riak/cache_store.rb
100
+ - lib/riak/client/curb_backend.rb
101
+ - lib/riak/client/http_backend.rb
102
+ - lib/riak/client/net_http_backend.rb
103
+ - lib/riak/client.rb
104
+ - lib/riak/failed_request.rb
105
+ - lib/riak/i18n.rb
106
+ - lib/riak/invalid_response.rb
107
+ - lib/riak/link.rb
108
+ - lib/riak/locale/en.yml
109
+ - lib/riak/map_reduce.rb
110
+ - lib/riak/map_reduce_error.rb
111
+ - lib/riak/robject.rb
112
+ - lib/riak/util/escape.rb
113
+ - lib/riak/util/fiber1.8.rb
114
+ - lib/riak/util/headers.rb
115
+ - lib/riak/util/multipart.rb
116
+ - lib/riak/util/translation.rb
117
+ - lib/riak/walk_spec.rb
118
+ - lib/riak.rb
119
+ - Rakefile
120
+ - spec/fixtures/cat.jpg
121
+ - spec/fixtures/multipart-blank.txt
122
+ - spec/fixtures/multipart-with-body.txt
123
+ - spec/integration/riak/cache_store_spec.rb
124
+ - spec/riak/bucket_spec.rb
125
+ - spec/riak/client_spec.rb
126
+ - spec/riak/curb_backend_spec.rb
127
+ - spec/riak/escape_spec.rb
128
+ - spec/riak/headers_spec.rb
129
+ - spec/riak/http_backend_spec.rb
130
+ - spec/riak/link_spec.rb
131
+ - spec/riak/map_reduce_spec.rb
132
+ - spec/riak/multipart_spec.rb
133
+ - spec/riak/net_http_backend_spec.rb
134
+ - spec/riak/object_spec.rb
135
+ - spec/riak/walk_spec_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/support/http_backend_implementation_examples.rb
138
+ - spec/support/mock_server.rb
139
+ - spec/support/mocks.rb
140
+ has_rdoc: true
141
+ homepage: http://seancribbs.github.com/ripple
142
+ licenses: []
143
+
144
+ post_install_message:
145
+ rdoc_options: []
146
+
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ requirements:
164
+ - `gem install curb` for better HTTP performance
165
+ rubyforge_project:
166
+ rubygems_version: 1.3.6
167
+ signing_key:
168
+ specification_version: 3
169
+ summary: riak-client is a rich client for Riak, the distributed database by Basho.
170
+ test_files:
171
+ - spec/integration/riak/cache_store_spec.rb
172
+ - spec/riak/bucket_spec.rb
173
+ - spec/riak/client_spec.rb
174
+ - spec/riak/curb_backend_spec.rb
175
+ - spec/riak/escape_spec.rb
176
+ - spec/riak/headers_spec.rb
177
+ - spec/riak/http_backend_spec.rb
178
+ - spec/riak/link_spec.rb
179
+ - spec/riak/map_reduce_spec.rb
180
+ - spec/riak/multipart_spec.rb
181
+ - spec/riak/net_http_backend_spec.rb
182
+ - spec/riak/object_spec.rb
183
+ - spec/riak/walk_spec_spec.rb
184
+ - spec/spec_helper.rb
185
+ - spec/support/http_backend_implementation_examples.rb
186
+ - spec/support/mock_server.rb
187
+ - spec/support/mocks.rb