better-riak-client 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/LICENSE +16 -0
  2. data/README.markdown +198 -0
  3. data/RELEASE_NOTES.md +211 -0
  4. data/better-riak-client.gemspec +61 -0
  5. data/erl_src/riak_kv_test014_backend.beam +0 -0
  6. data/erl_src/riak_kv_test014_backend.erl +189 -0
  7. data/erl_src/riak_kv_test_backend.beam +0 -0
  8. data/erl_src/riak_kv_test_backend.erl +697 -0
  9. data/erl_src/riak_search_test_backend.beam +0 -0
  10. data/erl_src/riak_search_test_backend.erl +175 -0
  11. data/lib/riak/bucket.rb +221 -0
  12. data/lib/riak/client/beefcake/messages.rb +213 -0
  13. data/lib/riak/client/beefcake/object_methods.rb +111 -0
  14. data/lib/riak/client/beefcake_protobuffs_backend.rb +226 -0
  15. data/lib/riak/client/decaying.rb +36 -0
  16. data/lib/riak/client/excon_backend.rb +162 -0
  17. data/lib/riak/client/feature_detection.rb +88 -0
  18. data/lib/riak/client/http_backend/configuration.rb +211 -0
  19. data/lib/riak/client/http_backend/key_streamer.rb +43 -0
  20. data/lib/riak/client/http_backend/object_methods.rb +106 -0
  21. data/lib/riak/client/http_backend/request_headers.rb +34 -0
  22. data/lib/riak/client/http_backend/transport_methods.rb +201 -0
  23. data/lib/riak/client/http_backend.rb +340 -0
  24. data/lib/riak/client/net_http_backend.rb +82 -0
  25. data/lib/riak/client/node.rb +115 -0
  26. data/lib/riak/client/protobuffs_backend.rb +173 -0
  27. data/lib/riak/client/search.rb +91 -0
  28. data/lib/riak/client.rb +540 -0
  29. data/lib/riak/cluster.rb +151 -0
  30. data/lib/riak/core_ext/blank.rb +53 -0
  31. data/lib/riak/core_ext/deep_dup.rb +13 -0
  32. data/lib/riak/core_ext/extract_options.rb +7 -0
  33. data/lib/riak/core_ext/json.rb +15 -0
  34. data/lib/riak/core_ext/slice.rb +18 -0
  35. data/lib/riak/core_ext/stringify_keys.rb +10 -0
  36. data/lib/riak/core_ext/symbolize_keys.rb +10 -0
  37. data/lib/riak/core_ext/to_param.rb +31 -0
  38. data/lib/riak/core_ext.rb +7 -0
  39. data/lib/riak/encoding.rb +6 -0
  40. data/lib/riak/failed_request.rb +81 -0
  41. data/lib/riak/i18n.rb +5 -0
  42. data/lib/riak/json.rb +52 -0
  43. data/lib/riak/link.rb +94 -0
  44. data/lib/riak/locale/en.yml +53 -0
  45. data/lib/riak/locale/fr.yml +52 -0
  46. data/lib/riak/map_reduce/filter_builder.rb +103 -0
  47. data/lib/riak/map_reduce/phase.rb +98 -0
  48. data/lib/riak/map_reduce.rb +225 -0
  49. data/lib/riak/map_reduce_error.rb +7 -0
  50. data/lib/riak/node/configuration.rb +293 -0
  51. data/lib/riak/node/console.rb +133 -0
  52. data/lib/riak/node/control.rb +207 -0
  53. data/lib/riak/node/defaults.rb +83 -0
  54. data/lib/riak/node/generation.rb +106 -0
  55. data/lib/riak/node/log.rb +34 -0
  56. data/lib/riak/node/version.rb +43 -0
  57. data/lib/riak/node.rb +38 -0
  58. data/lib/riak/robject.rb +318 -0
  59. data/lib/riak/search.rb +3 -0
  60. data/lib/riak/serializers.rb +74 -0
  61. data/lib/riak/stamp.rb +77 -0
  62. data/lib/riak/test_server.rb +89 -0
  63. data/lib/riak/util/escape.rb +76 -0
  64. data/lib/riak/util/headers.rb +53 -0
  65. data/lib/riak/util/multipart/stream_parser.rb +62 -0
  66. data/lib/riak/util/multipart.rb +52 -0
  67. data/lib/riak/util/tcp_socket_extensions.rb +58 -0
  68. data/lib/riak/util/translation.rb +19 -0
  69. data/lib/riak/version.rb +3 -0
  70. data/lib/riak/walk_spec.rb +105 -0
  71. data/lib/riak.rb +21 -0
  72. metadata +348 -0
@@ -0,0 +1,58 @@
1
+ require 'time'
2
+ require 'timeout'
3
+ require 'socket'
4
+
5
+ # Borrowed from Webrat and Selenium client, watches for TCP port
6
+ # liveness of the spawned server.
7
+ # @private
8
+ class TCPSocket
9
+ def self.wait_for_service(options)
10
+ verbose_wait until listening_service?(options)
11
+ end
12
+
13
+ def self.wait_for_service_termination(options)
14
+ verbose_wait while listening_service?(options)
15
+ end
16
+
17
+ def self.listening_service?(options)
18
+ Timeout::timeout(options[:timeout] || 20) do
19
+ begin
20
+ socket = TCPSocket.new(options[:host], options[:port])
21
+ socket.close unless socket.nil?
22
+ true
23
+ rescue Errno::ECONNREFUSED,
24
+ Errno::EBADF # Windows
25
+ false
26
+ end
27
+ end
28
+ end
29
+
30
+ def self.verbose_wait
31
+ # Removed the puts call so as not to clutter up test output.
32
+ sleep 2
33
+ end
34
+
35
+ def self.wait_for_service_with_timeout(options)
36
+ start_time = Time.now
37
+
38
+ until listening_service?(options)
39
+ verbose_wait
40
+
41
+ if options[:timeout] && (Time.now > start_time + options[:timeout])
42
+ raise SocketError.new("Socket did not open within #{options[:timeout]} seconds")
43
+ end
44
+ end
45
+ end
46
+
47
+ def self.wait_for_service_termination_with_timeout(options)
48
+ start_time = Time.now
49
+
50
+ while listening_service?(options)
51
+ verbose_wait
52
+
53
+ if options[:timeout] && (Time.now > start_time + options[:timeout])
54
+ raise SocketError.new("Socket did not terminate within #{options[:timeout]} seconds")
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,19 @@
1
+ require 'riak/i18n'
2
+
3
+ module Riak
4
+ module Util
5
+ # Methods for doing i18n string lookup
6
+ module Translation
7
+ # The scope of i18n messages
8
+ def i18n_scope
9
+ :riak
10
+ end
11
+
12
+ # Provides the translation for a given internationalized message
13
+ def t(message, options={})
14
+ I18n.t("#{i18n_scope}.#{message}", options)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,3 @@
1
+ module Riak
2
+ VERSION = "1.0.5"
3
+ end
@@ -0,0 +1,105 @@
1
+ require 'riak/util/translation'
2
+ require 'riak/util/escape'
3
+ require 'riak/link'
4
+
5
+ module Riak
6
+ # The specification of how to follow links from one object to another in Riak,
7
+ # when using the link-walker resource.
8
+ # Example link-walking operation:
9
+ # GET /riak/artists/REM/albums,_,_/tracks,_,1
10
+ # This operation would have two WalkSpecs:
11
+ # Riak::WalkSpec.new({:bucket => 'albums'})
12
+ # Riak::WalkSpec.new({:bucket => 'tracks', :result => true})
13
+ class WalkSpec
14
+ include Util::Translation
15
+ include Util::Escape
16
+
17
+ # @return [String] The bucket followed links should be restricted to. "_" represents all buckets.
18
+ attr_accessor :bucket
19
+
20
+ # @return [String] The "riaktag" or "rel" that followed links should be restricted to. "_" represents all tags.
21
+ attr_accessor :tag
22
+
23
+ # @return [Boolean] Whether objects should be returned from this phase of link walking. Default is false.
24
+ attr_accessor :keep
25
+
26
+ # Normalize a list of walk specs into WalkSpec objects.
27
+ def self.normalize(*params)
28
+ params.flatten!
29
+ specs = []
30
+ while params.length > 0
31
+ param = params.shift
32
+ case param
33
+ when Hash
34
+ specs << new(param)
35
+ when WalkSpec
36
+ specs << param
37
+ else
38
+ if params.length >= 2
39
+ specs << new(param, params.shift, params.shift)
40
+ else
41
+ raise ArgumentError, t("too_few_arguments", :params => params.inspect)
42
+ end
43
+ end
44
+ end
45
+ specs
46
+ end
47
+
48
+ # Creates a walk-spec for use in finding other objects in Riak.
49
+ # @overload initialize(hash)
50
+ # Creates a walk-spec from a hash.
51
+ # @param [Hash] hash options for the walk-spec
52
+ # @option hash [String] :bucket ("_") the bucket the links should point to (default '_' is all)
53
+ # @option hash [String] :tag ("_") the tag to filter links by (default '_' is all)
54
+ # @option hash [Boolean] :keep (false) whether to return results from following this link specification
55
+ # @overload initialize(bucket, tag, keep)
56
+ # Creates a walk-spec from a bucket-tag-result triple.
57
+ # @param [String] bucket the bucket the links should point to (default '_' is all)
58
+ # @param [String] tag the tag to filter links by (default '_' is all)
59
+ # @param [Boolean] keep whether to return results from following this link specification
60
+ # @see {Riak::RObject#walk}
61
+ def initialize(*args)
62
+ args.flatten!
63
+ case args.size
64
+ when 1
65
+ hash = args.first
66
+ raise ArgumentError, t("hash_type", :hash => hash.inspect) unless Hash === hash
67
+ assign(hash[:bucket], hash[:tag], hash[:keep])
68
+ when 3
69
+ assign(*args)
70
+ else
71
+ raise ArgumentError, t("wrong_argument_count_walk_spec")
72
+ end
73
+ end
74
+
75
+ # Converts the walk-spec into the form required by the link-walker resource URL
76
+ def to_s
77
+ b = @bucket && escape(@bucket) || '_'
78
+ t = @tag && escape(@tag) || '_'
79
+ "#{b},#{t},#{@keep ? '1' : '_'}"
80
+ end
81
+
82
+ def ==(other)
83
+ other.is_a?(WalkSpec) && other.bucket == bucket && other.tag == tag && other.keep == keep
84
+ end
85
+
86
+ def ===(other)
87
+ self == other || case other
88
+ when WalkSpec
89
+ other.keep == keep &&
90
+ (bucket == "_" || bucket == other.bucket) &&
91
+ (tag == "_" || tag == other.tag)
92
+ when Link
93
+ (bucket == "_" || bucket == other.url.split("/")[2]) &&
94
+ (tag == "_" || tag == other.rel)
95
+ end
96
+ end
97
+
98
+ private
99
+ def assign(bucket, tag, result)
100
+ @bucket = bucket || "_"
101
+ @tag = tag || "_"
102
+ @keep = result || false
103
+ end
104
+ end
105
+ end
data/lib/riak.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'riak/encoding'
2
+ require 'riak/core_ext'
3
+ require 'riak/client'
4
+ require 'riak/map_reduce'
5
+ require 'riak/util/translation'
6
+
7
+ # The Riak module contains all aspects of the client interface to
8
+ # Riak.
9
+ module Riak
10
+ # Utility classes and mixins
11
+ module Util; end
12
+ extend Util::Translation
13
+
14
+ class << self
15
+ # Only change this if you really know what you're doing. Better to
16
+ # err on the side of caution and assume you don't.
17
+ # @private
18
+ attr_accessor :disable_list_keys_warnings
19
+ end
20
+ self.disable_list_keys_warnings = false
21
+ end
metadata ADDED
@@ -0,0 +1,348 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: better-riak-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon Frisby
9
+ - Sean Cribbs
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-10-10 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: !binary |-
17
+ aTE4bg==
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - !binary |-
22
+ Pj0=
23
+ - !ruby/object:Gem::Version
24
+ version: !binary |-
25
+ MC40LjA=
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - !binary |-
32
+ Pj0=
33
+ - !ruby/object:Gem::Version
34
+ version: !binary |-
35
+ MC40LjA=
36
+ - !ruby/object:Gem::Dependency
37
+ name: !binary |-
38
+ YnVpbGRlcg==
39
+ requirement: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - !binary |-
43
+ Pj0=
44
+ - !ruby/object:Gem::Version
45
+ version: !binary |-
46
+ Mi4xLjI=
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - !binary |-
53
+ Pj0=
54
+ - !ruby/object:Gem::Version
55
+ version: !binary |-
56
+ Mi4xLjI=
57
+ - !ruby/object:Gem::Dependency
58
+ name: !binary |-
59
+ YmVlZmNha2U=
60
+ requirement: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - !binary |-
64
+ fj4=
65
+ - !ruby/object:Gem::Version
66
+ version: !binary |-
67
+ MC4zLjc=
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - !binary |-
74
+ fj4=
75
+ - !ruby/object:Gem::Version
76
+ version: !binary |-
77
+ MC4zLjc=
78
+ - !ruby/object:Gem::Dependency
79
+ name: !binary |-
80
+ bXVsdGlfanNvbg==
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - !binary |-
85
+ fj4=
86
+ - !ruby/object:Gem::Version
87
+ version: !binary |-
88
+ MS4w
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - !binary |-
95
+ fj4=
96
+ - !ruby/object:Gem::Version
97
+ version: !binary |-
98
+ MS4w
99
+ - !ruby/object:Gem::Dependency
100
+ name: !binary |-
101
+ aW5uZXJ0dWJl
102
+ requirement: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - !binary |-
106
+ fj4=
107
+ - !ruby/object:Gem::Version
108
+ version: !binary |-
109
+ MS4wLjI=
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - !binary |-
116
+ fj4=
117
+ - !ruby/object:Gem::Version
118
+ version: !binary |-
119
+ MS4wLjI=
120
+ - !ruby/object:Gem::Dependency
121
+ name: !binary |-
122
+ cnNwZWM=
123
+ requirement: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - !binary |-
127
+ fj4=
128
+ - !ruby/object:Gem::Version
129
+ version: !binary |-
130
+ Mi4xMC4w
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - !binary |-
137
+ fj4=
138
+ - !ruby/object:Gem::Version
139
+ version: !binary |-
140
+ Mi4xMC4w
141
+ - !ruby/object:Gem::Dependency
142
+ name: !binary |-
143
+ ZmFrZXdlYg==
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - !binary |-
148
+ Pj0=
149
+ - !ruby/object:Gem::Version
150
+ version: !binary |-
151
+ MS4y
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - !binary |-
158
+ Pj0=
159
+ - !ruby/object:Gem::Version
160
+ version: !binary |-
161
+ MS4y
162
+ - !ruby/object:Gem::Dependency
163
+ name: !binary |-
164
+ cmFjaw==
165
+ requirement: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - !binary |-
169
+ Pj0=
170
+ - !ruby/object:Gem::Version
171
+ version: !binary |-
172
+ MS4w
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ none: false
177
+ requirements:
178
+ - - !binary |-
179
+ Pj0=
180
+ - !ruby/object:Gem::Version
181
+ version: !binary |-
182
+ MS4w
183
+ - !ruby/object:Gem::Dependency
184
+ name: !binary |-
185
+ ZXhjb24=
186
+ requirement: !ruby/object:Gem::Requirement
187
+ none: false
188
+ requirements:
189
+ - - !binary |-
190
+ Pj0=
191
+ - !ruby/object:Gem::Version
192
+ version: !binary |-
193
+ MC42LjE=
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ none: false
198
+ requirements:
199
+ - - !binary |-
200
+ Pj0=
201
+ - !ruby/object:Gem::Version
202
+ version: !binary |-
203
+ MC42LjE=
204
+ - !ruby/object:Gem::Dependency
205
+ name: !binary |-
206
+ cmFrZQ==
207
+ requirement: !ruby/object:Gem::Requirement
208
+ none: false
209
+ requirements:
210
+ - - ! '>='
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ type: :development
214
+ prerelease: false
215
+ version_requirements: !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ - !ruby/object:Gem::Dependency
222
+ name: !binary |-
223
+ eWFqbC1ydWJ5
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ description: better-riak-client is an improved version of Basho's official Ruby client
239
+ for Riak. It's a drop-in replacement that supports everything the official client
240
+ does, in a gem that isn't bloated to multiple megabytes in size, and that fixes
241
+ various outstanding issues like broken SSL validation.
242
+ email:
243
+ - jon@cloudability.com
244
+ - sean@basho.com
245
+ executables: []
246
+ extensions: []
247
+ extra_rdoc_files: []
248
+ files:
249
+ - LICENSE
250
+ - README.markdown
251
+ - RELEASE_NOTES.md
252
+ - better-riak-client.gemspec
253
+ - erl_src/riak_kv_test014_backend.beam
254
+ - erl_src/riak_kv_test014_backend.erl
255
+ - erl_src/riak_kv_test_backend.beam
256
+ - erl_src/riak_kv_test_backend.erl
257
+ - erl_src/riak_search_test_backend.beam
258
+ - erl_src/riak_search_test_backend.erl
259
+ - lib/riak.rb
260
+ - lib/riak/bucket.rb
261
+ - lib/riak/client.rb
262
+ - lib/riak/client/beefcake/messages.rb
263
+ - lib/riak/client/beefcake/object_methods.rb
264
+ - lib/riak/client/beefcake_protobuffs_backend.rb
265
+ - lib/riak/client/decaying.rb
266
+ - lib/riak/client/excon_backend.rb
267
+ - lib/riak/client/feature_detection.rb
268
+ - lib/riak/client/http_backend.rb
269
+ - lib/riak/client/http_backend/configuration.rb
270
+ - lib/riak/client/http_backend/key_streamer.rb
271
+ - lib/riak/client/http_backend/object_methods.rb
272
+ - lib/riak/client/http_backend/request_headers.rb
273
+ - lib/riak/client/http_backend/transport_methods.rb
274
+ - lib/riak/client/net_http_backend.rb
275
+ - lib/riak/client/node.rb
276
+ - lib/riak/client/protobuffs_backend.rb
277
+ - lib/riak/client/search.rb
278
+ - lib/riak/cluster.rb
279
+ - lib/riak/core_ext.rb
280
+ - lib/riak/core_ext/blank.rb
281
+ - lib/riak/core_ext/deep_dup.rb
282
+ - lib/riak/core_ext/extract_options.rb
283
+ - lib/riak/core_ext/json.rb
284
+ - lib/riak/core_ext/slice.rb
285
+ - lib/riak/core_ext/stringify_keys.rb
286
+ - lib/riak/core_ext/symbolize_keys.rb
287
+ - lib/riak/core_ext/to_param.rb
288
+ - lib/riak/encoding.rb
289
+ - lib/riak/failed_request.rb
290
+ - lib/riak/i18n.rb
291
+ - lib/riak/json.rb
292
+ - lib/riak/link.rb
293
+ - lib/riak/locale/en.yml
294
+ - lib/riak/locale/fr.yml
295
+ - lib/riak/map_reduce.rb
296
+ - lib/riak/map_reduce/filter_builder.rb
297
+ - lib/riak/map_reduce/phase.rb
298
+ - lib/riak/map_reduce_error.rb
299
+ - lib/riak/node.rb
300
+ - lib/riak/node/configuration.rb
301
+ - lib/riak/node/console.rb
302
+ - lib/riak/node/control.rb
303
+ - lib/riak/node/defaults.rb
304
+ - lib/riak/node/generation.rb
305
+ - lib/riak/node/log.rb
306
+ - lib/riak/node/version.rb
307
+ - lib/riak/robject.rb
308
+ - lib/riak/search.rb
309
+ - lib/riak/serializers.rb
310
+ - lib/riak/stamp.rb
311
+ - lib/riak/test_server.rb
312
+ - lib/riak/util/escape.rb
313
+ - lib/riak/util/headers.rb
314
+ - lib/riak/util/multipart.rb
315
+ - lib/riak/util/multipart/stream_parser.rb
316
+ - lib/riak/util/tcp_socket_extensions.rb
317
+ - lib/riak/util/translation.rb
318
+ - lib/riak/version.rb
319
+ - lib/riak/walk_spec.rb
320
+ homepage: http://github.com/cloudability/better-riak-client
321
+ licenses: []
322
+ post_install_message:
323
+ rdoc_options: []
324
+ require_paths:
325
+ - lib
326
+ required_ruby_version: !ruby/object:Gem::Requirement
327
+ none: false
328
+ requirements:
329
+ - - ! '>='
330
+ - !ruby/object:Gem::Version
331
+ version: '0'
332
+ segments:
333
+ - 0
334
+ hash: -1989266685970245244
335
+ required_rubygems_version: !ruby/object:Gem::Requirement
336
+ none: false
337
+ requirements:
338
+ - - ! '>='
339
+ - !ruby/object:Gem::Version
340
+ version: '0'
341
+ requirements: []
342
+ rubyforge_project:
343
+ rubygems_version: 1.8.24
344
+ signing_key:
345
+ specification_version: 3
346
+ summary: better-riak-client is an improved version of Basho's official Ruby client
347
+ for Riak.
348
+ test_files: []