Browse files

Isolate ripple.

  • Loading branch information...
1 parent 11a1d0f commit 59925b4f2245718c43b873e280383675440862a6 @seancribbs seancribbs committed Jan 11, 2012
Showing with 28 additions and 13,375 deletions.
  1. 0 {ripple → }/Gemfile
  2. 0 {ripple → }/Guardfile
  3. +28 −82 Rakefile
  4. +0 −1 VERSION
  5. +0 −30 ci/build_all
  6. +0 −19 ci/create_test_server_yml
  7. +0 −6 ci/disable_jruby_native
  8. 0 {ripple → }/lib/rails/generators/ripple/configuration/configuration_generator.rb
  9. 0 {ripple → }/lib/rails/generators/ripple/configuration/templates/ripple.yml
  10. 0 {ripple → }/lib/rails/generators/ripple/js/js_generator.rb
  11. 0 {ripple → }/lib/rails/generators/ripple/js/templates/js/contrib.js
  12. 0 {ripple → }/lib/rails/generators/ripple/js/templates/js/iso8601.js
  13. 0 {ripple → }/lib/rails/generators/ripple/js/templates/js/ripple.js
  14. 0 {ripple → }/lib/rails/generators/ripple/model/model_generator.rb
  15. 0 {ripple → }/lib/rails/generators/ripple/model/templates/model.rb.erb
  16. 0 {ripple → }/lib/rails/generators/ripple/observer/observer_generator.rb
  17. 0 {ripple → }/lib/rails/generators/ripple/observer/templates/observer.rb.erb
  18. 0 {ripple → }/lib/rails/generators/ripple/test/templates/cucumber.rb.erb
  19. 0 {ripple → }/lib/rails/generators/ripple/test/test_generator.rb
  20. 0 {ripple → }/lib/rails/generators/ripple_generator.rb
  21. 0 {ripple → }/lib/ripple.rb
  22. 0 {ripple → }/lib/ripple/associations.rb
  23. 0 {ripple → }/lib/ripple/associations/embedded.rb
  24. 0 {ripple → }/lib/ripple/associations/instantiators.rb
  25. 0 {ripple → }/lib/ripple/associations/linked.rb
  26. 0 {ripple → }/lib/ripple/associations/many.rb
  27. 0 {ripple → }/lib/ripple/associations/many_embedded_proxy.rb
  28. 0 {ripple → }/lib/ripple/associations/many_linked_proxy.rb
  29. 0 {ripple → }/lib/ripple/associations/many_reference_proxy.rb
  30. 0 {ripple → }/lib/ripple/associations/many_stored_key_proxy.rb
  31. 0 {ripple → }/lib/ripple/associations/one.rb
  32. 0 {ripple → }/lib/ripple/associations/one_embedded_proxy.rb
  33. 0 {ripple → }/lib/ripple/associations/one_key_proxy.rb
  34. 0 {ripple → }/lib/ripple/associations/one_linked_proxy.rb
  35. 0 {ripple → }/lib/ripple/associations/one_stored_key_proxy.rb
  36. 0 {ripple → }/lib/ripple/associations/proxy.rb
  37. 0 {ripple → }/lib/ripple/attribute_methods.rb
  38. 0 {ripple → }/lib/ripple/attribute_methods/dirty.rb
  39. 0 {ripple → }/lib/ripple/attribute_methods/query.rb
  40. 0 {ripple → }/lib/ripple/attribute_methods/read.rb
  41. 0 {ripple → }/lib/ripple/attribute_methods/write.rb
  42. 0 {ripple → }/lib/ripple/callbacks.rb
  43. 0 {ripple → }/lib/ripple/conflict/basic_resolver.rb
  44. 0 {ripple → }/lib/ripple/conflict/document_hooks.rb
  45. 0 {ripple → }/lib/ripple/conflict/resolver.rb
  46. 0 {ripple → }/lib/ripple/conflict/test_helper.rb
  47. 0 {ripple → }/lib/ripple/conversion.rb
  48. 0 {ripple → }/lib/ripple/core_ext.rb
  49. 0 {ripple → }/lib/ripple/core_ext/casting.rb
  50. 0 {ripple → }/lib/ripple/core_ext/indexes.rb
  51. 0 {ripple → }/lib/ripple/core_ext/object.rb
  52. 0 {ripple → }/lib/ripple/document.rb
  53. 0 {ripple → }/lib/ripple/document/bucket_access.rb
  54. 0 {ripple → }/lib/ripple/document/finders.rb
  55. 0 {ripple → }/lib/ripple/document/key.rb
  56. 0 {ripple → }/lib/ripple/document/link.rb
  57. 0 {ripple → }/lib/ripple/document/persistence.rb
  58. 0 {ripple → }/lib/ripple/embedded_document.rb
  59. 0 {ripple → }/lib/ripple/embedded_document/around_callbacks.rb
  60. 0 {ripple → }/lib/ripple/embedded_document/finders.rb
  61. 0 {ripple → }/lib/ripple/embedded_document/persistence.rb
  62. 0 {ripple → }/lib/ripple/i18n.rb
  63. 0 {ripple → }/lib/ripple/indexes.rb
  64. 0 {ripple → }/lib/ripple/inspection.rb
  65. 0 {ripple → }/lib/ripple/locale/en.yml
  66. 0 {ripple → }/lib/ripple/nested_attributes.rb
  67. 0 {ripple → }/lib/ripple/observable.rb
  68. 0 {ripple → }/lib/ripple/properties.rb
  69. 0 {ripple → }/lib/ripple/property_type_mismatch.rb
  70. 0 {ripple → }/lib/ripple/railtie.rb
  71. 0 {ripple → }/lib/ripple/railties/ripple.rake
  72. 0 {ripple → }/lib/ripple/serialization.rb
  73. 0 {ripple → }/lib/ripple/test_server.rb
  74. 0 {ripple → }/lib/ripple/timestamps.rb
  75. 0 {ripple → }/lib/ripple/translation.rb
  76. 0 {ripple → }/lib/ripple/validations.rb
  77. 0 {ripple → }/lib/ripple/validations/associated_validator.rb
  78. 0 {ripple → }/lib/ripple/version.rb
  79. +0 −32 riak-client/.gitignore
  80. +0 −1 riak-client/.rspec
  81. +0 −2 riak-client/.watchr
  82. +0 −34 riak-client/Gemfile
  83. +0 −14 riak-client/Guardfile
  84. +0 −49 riak-client/Rakefile
  85. BIN riak-client/erl_src/riak_kv_test_backend.beam
  86. +0 −540 riak-client/erl_src/riak_kv_test_backend.erl
  87. BIN riak-client/erl_src/riak_search_test_backend.beam
  88. +0 −175 riak-client/erl_src/riak_search_test_backend.erl
  89. +0 −2 riak-client/lib/active_support/cache/riak_store.rb
  90. +0 −21 riak-client/lib/riak.rb
  91. +0 −221 riak-client/lib/riak/bucket.rb
  92. +0 −84 riak-client/lib/riak/cache_store.rb
  93. +0 −539 riak-client/lib/riak/client.rb
  94. +0 −165 riak-client/lib/riak/client/beefcake/messages.rb
  95. +0 −111 riak-client/lib/riak/client/beefcake/object_methods.rb
  96. +0 −179 riak-client/lib/riak/client/beefcake_protobuffs_backend.rb
  97. +0 −28 riak-client/lib/riak/client/decaying.rb
  98. +0 −81 riak-client/lib/riak/client/excon_backend.rb
  99. +0 −320 riak-client/lib/riak/client/http_backend.rb
  100. +0 −198 riak-client/lib/riak/client/http_backend/configuration.rb
  101. +0 −43 riak-client/lib/riak/client/http_backend/key_streamer.rb
  102. +0 −106 riak-client/lib/riak/client/http_backend/object_methods.rb
  103. +0 −34 riak-client/lib/riak/client/http_backend/request_headers.rb
  104. +0 −201 riak-client/lib/riak/client/http_backend/transport_methods.rb
  105. +0 −83 riak-client/lib/riak/client/net_http_backend.rb
  106. +0 −111 riak-client/lib/riak/client/node.rb
  107. +0 −180 riak-client/lib/riak/client/pool.rb
  108. +0 −122 riak-client/lib/riak/client/protobuffs_backend.rb
  109. +0 −91 riak-client/lib/riak/client/search.rb
  110. +0 −151 riak-client/lib/riak/cluster.rb
  111. +0 −7 riak-client/lib/riak/core_ext.rb
  112. +0 −53 riak-client/lib/riak/core_ext/blank.rb
  113. +0 −13 riak-client/lib/riak/core_ext/deep_dup.rb
  114. +0 −7 riak-client/lib/riak/core_ext/extract_options.rb
  115. +0 −15 riak-client/lib/riak/core_ext/json.rb
  116. +0 −18 riak-client/lib/riak/core_ext/slice.rb
  117. +0 −10 riak-client/lib/riak/core_ext/stringify_keys.rb
  118. +0 −10 riak-client/lib/riak/core_ext/symbolize_keys.rb
  119. +0 −31 riak-client/lib/riak/core_ext/to_param.rb
  120. +0 −6 riak-client/lib/riak/encoding.rb
  121. +0 −81 riak-client/lib/riak/failed_request.rb
  122. +0 −3 riak-client/lib/riak/i18n.rb
  123. +0 −28 riak-client/lib/riak/json.rb
  124. +0 −96 riak-client/lib/riak/link.rb
  125. +0 −52 riak-client/lib/riak/locale/en.yml
  126. +0 −226 riak-client/lib/riak/map_reduce.rb
  127. +0 −103 riak-client/lib/riak/map_reduce/filter_builder.rb
  128. +0 −98 riak-client/lib/riak/map_reduce/phase.rb
  129. +0 −7 riak-client/lib/riak/map_reduce_error.rb
  130. +0 −38 riak-client/lib/riak/node.rb
  131. +0 −286 riak-client/lib/riak/node/configuration.rb
  132. +0 −139 riak-client/lib/riak/node/console.rb
  133. +0 −207 riak-client/lib/riak/node/control.rb
  134. +0 −70 riak-client/lib/riak/node/defaults.rb
  135. +0 −106 riak-client/lib/riak/node/generation.rb
  136. +0 −34 riak-client/lib/riak/node/log.rb
  137. +0 −37 riak-client/lib/riak/node/version.rb
  138. +0 −316 riak-client/lib/riak/robject.rb
  139. +0 −3 riak-client/lib/riak/search.rb
  140. +0 −74 riak-client/lib/riak/serializers.rb
  141. +0 −77 riak-client/lib/riak/stamp.rb
  142. +0 −75 riak-client/lib/riak/test_server.rb
  143. +0 −76 riak-client/lib/riak/util/escape.rb
  144. +0 −53 riak-client/lib/riak/util/headers.rb
  145. +0 −52 riak-client/lib/riak/util/multipart.rb
  146. +0 −62 riak-client/lib/riak/util/multipart/stream_parser.rb
  147. +0 −58 riak-client/lib/riak/util/tcp_socket_extensions.rb
  148. +0 −19 riak-client/lib/riak/util/translation.rb
  149. +0 −3 riak-client/lib/riak/version.rb
  150. +0 −105 riak-client/lib/riak/walk_spec.rb
  151. +0 −31 riak-client/riak-client.gemspec
  152. +0 −59 riak-client/spec/failover/failover.rb
  153. BIN riak-client/spec/fixtures/cat.jpg
  154. +0 −7 riak-client/spec/fixtures/multipart-blank.txt
  155. +0 −10 riak-client/spec/fixtures/multipart-mapreduce.txt
  156. +0 −16 riak-client/spec/fixtures/multipart-with-body.txt
  157. +0 −17 riak-client/spec/fixtures/multipart-with-marked-tombstones.txt
  158. +0 −16 riak-client/spec/fixtures/multipart-with-unmarked-tombstone.txt
  159. +0 −15 riak-client/spec/fixtures/server.cert.crt
  160. +0 −15 riak-client/spec/fixtures/server.cert.key
  161. +0 −1 riak-client/spec/fixtures/test.pem
  162. +0 −129 riak-client/spec/integration/riak/cache_store_spec.rb
  163. +0 −88 riak-client/spec/integration/riak/cluster_spec.rb
  164. +0 −47 riak-client/spec/integration/riak/http_backends_spec.rb
  165. +0 −184 riak-client/spec/integration/riak/node_spec.rb
  166. +0 −21 riak-client/spec/integration/riak/protobuffs_backends_spec.rb
  167. +0 −38 riak-client/spec/integration/riak/test_server_spec.rb
  168. +0 −179 riak-client/spec/integration/riak/threading_spec.rb
  169. +0 −23 riak-client/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb
  170. +0 −62 riak-client/spec/riak/beefcake_protobuffs_backend_spec.rb
  171. +0 −213 riak-client/spec/riak/bucket_spec.rb
  172. +0 −418 riak-client/spec/riak/client_spec.rb
  173. +0 −15 riak-client/spec/riak/core_ext/to_param_spec.rb
  174. +0 −69 riak-client/spec/riak/escape_spec.rb
  175. +0 −65 riak-client/spec/riak/excon_backend_spec.rb
  176. +0 −38 riak-client/spec/riak/headers_spec.rb
  177. +0 −273 riak-client/spec/riak/http_backend/configuration_spec.rb
  178. +0 −252 riak-client/spec/riak/http_backend/object_methods_spec.rb
  179. +0 −97 riak-client/spec/riak/http_backend/transport_methods_spec.rb
  180. +0 −338 riak-client/spec/riak/http_backend_spec.rb
  181. +0 −85 riak-client/spec/riak/link_spec.rb
  182. +0 −32 riak-client/spec/riak/map_reduce/filter_builder_spec.rb
  183. +0 −136 riak-client/spec/riak/map_reduce/phase_spec.rb
  184. +0 −367 riak-client/spec/riak/map_reduce_spec.rb
  185. +0 −23 riak-client/spec/riak/multipart_spec.rb
  186. +0 −15 riak-client/spec/riak/net_http_backend_spec.rb
  187. +0 −173 riak-client/spec/riak/node_spec.rb
  188. +0 −306 riak-client/spec/riak/pool_spec.rb
  189. +0 −455 riak-client/spec/riak/robject_spec.rb
  190. +0 −178 riak-client/spec/riak/search_spec.rb
  191. +0 −96 riak-client/spec/riak/serializers_spec.rb
  192. +0 −54 riak-client/spec/riak/stamp_spec.rb
  193. +0 −53 riak-client/spec/riak/stream_parser_spec.rb
  194. +0 −195 riak-client/spec/riak/walk_spec_spec.rb
  195. +0 −41 riak-client/spec/spec_helper.rb
  196. +0 −39 riak-client/spec/support/drb_mock_server.rb
  197. +0 −253 riak-client/spec/support/http_backend_implementation_examples.rb
  198. +0 −10 riak-client/spec/support/integration_setup.rb
  199. +0 −81 riak-client/spec/support/mock_server.rb
  200. +0 −4 riak-client/spec/support/mocks.rb
  201. +0 −30 riak-client/spec/support/test_server.rb
  202. +0 −14 riak-client/spec/support/test_server.yml.example
  203. +0 −277 riak-client/spec/support/unified_backend_examples.rb
  204. +0 −31 riak-sessions/.gitignore
  205. +0 −1 riak-sessions/.rspec
  206. +0 −14 riak-sessions/Gemfile
  207. +0 −32 riak-sessions/Rakefile
  208. +0 −7 riak-sessions/lib/riak-sessions.rb
  209. +0 −5 riak-sessions/lib/riak-sessions/version.rb
  210. +0 −130 riak-sessions/lib/riak/session_store.rb
  211. +0 −70 riak-sessions/lib/ripple/session_store.rb
  212. +0 −29 riak-sessions/riak-sessions.gemspec
  213. +0 −11 riak-sessions/spec/fixtures/session_autoload_test/session_autoload_test/foo.rb
  214. +0 −201 riak-sessions/spec/riak_session_store_spec.rb
  215. +0 −127 riak-sessions/spec/ripple_session_store_spec.rb
  216. +0 −21 riak-sessions/spec/spec_helper.rb
  217. +0 −86 riak-sessions/spec/support/ripple_session_support.rb
  218. +0 −31 riak-sessions/spec/support/rspec-rails-neuter.rb
  219. +0 −24 riak-sessions/spec/support/test_server.rb
  220. +0 −14 riak-sessions/spec/support/test_server.yml.example
  221. 0 {ripple → }/ripple.gemspec
  222. +0 −33 ripple/.gitignore
  223. +0 −1 ripple/.rspec
  224. +0 −44 ripple/Rakefile
  225. 0 {ripple → }/spec/fixtures/config.yml
  226. 0 {ripple → }/spec/generators/ripple/configuration_generator_spec.rb
  227. 0 {ripple → }/spec/generators/ripple/js_generator_spec.rb
  228. 0 {ripple → }/spec/generators/ripple/model_generator_spec.rb
  229. 0 {ripple → }/spec/generators/ripple/observer_generator_spec.rb
  230. 0 {ripple → }/spec/generators/ripple/test_generator_spec.rb
  231. 0 {ripple → }/spec/generators/ripple_generator_spec.rb
  232. 0 {ripple → }/spec/integration/ripple/associations_spec.rb
  233. 0 {ripple → }/spec/integration/ripple/conflict_resolution_spec.rb
  234. 0 {ripple → }/spec/integration/ripple/nested_attributes_spec.rb
  235. 0 {ripple → }/spec/integration/ripple/persistence_spec.rb
  236. 0 {ripple → }/spec/integration/ripple/search_associations_spec.rb
  237. 0 {ripple → }/spec/ripple/associations/many_embedded_proxy_spec.rb
  238. 0 {ripple → }/spec/ripple/associations/many_linked_proxy_spec.rb
  239. 0 {ripple → }/spec/ripple/associations/many_reference_proxy_spec.rb
  240. 0 {ripple → }/spec/ripple/associations/many_stored_key_proxy_spec.rb
  241. 0 {ripple → }/spec/ripple/associations/one_embedded_proxy_spec.rb
  242. 0 {ripple → }/spec/ripple/associations/one_key_proxy_spec.rb
  243. 0 {ripple → }/spec/ripple/associations/one_linked_proxy_spec.rb
  244. 0 {ripple → }/spec/ripple/associations/one_stored_key_proxy_spec.rb
  245. 0 {ripple → }/spec/ripple/associations/proxy_spec.rb
  246. 0 {ripple → }/spec/ripple/associations_spec.rb
  247. 0 {ripple → }/spec/ripple/attribute_methods/dirty_spec.rb
  248. 0 {ripple → }/spec/ripple/attribute_methods_spec.rb
  249. 0 {ripple → }/spec/ripple/bucket_access_spec.rb
  250. 0 {ripple → }/spec/ripple/callbacks_spec.rb
  251. 0 {ripple → }/spec/ripple/conflict/resolver_spec.rb
  252. 0 {ripple → }/spec/ripple/conversion_spec.rb
  253. 0 {ripple → }/spec/ripple/core_ext_spec.rb
  254. 0 {ripple → }/spec/ripple/document/link_spec.rb
  255. 0 {ripple → }/spec/ripple/document_spec.rb
  256. 0 {ripple → }/spec/ripple/embedded_document/finders_spec.rb
  257. 0 {ripple → }/spec/ripple/embedded_document/persistence_spec.rb
  258. 0 {ripple → }/spec/ripple/embedded_document_spec.rb
  259. 0 {ripple → }/spec/ripple/finders_spec.rb
  260. 0 {ripple → }/spec/ripple/indexes_spec.rb
  261. 0 {ripple → }/spec/ripple/inspection_spec.rb
  262. 0 {ripple → }/spec/ripple/key_spec.rb
  263. 0 {ripple → }/spec/ripple/observable_spec.rb
  264. 0 {ripple → }/spec/ripple/persistence_spec.rb
  265. 0 {ripple → }/spec/ripple/properties_spec.rb
  266. 0 {ripple → }/spec/ripple/ripple_spec.rb
  267. 0 {ripple → }/spec/ripple/serialization_spec.rb
  268. 0 {ripple → }/spec/ripple/timestamps_spec.rb
  269. 0 {ripple → }/spec/ripple/validations/associated_validator_spec.rb
  270. 0 {ripple → }/spec/ripple/validations_spec.rb
  271. 0 {ripple → }/spec/spec_helper.rb
  272. 0 {ripple → }/spec/support/associations.rb
  273. 0 {ripple → }/spec/support/associations/proxies.rb
  274. 0 {ripple → }/spec/support/generator_setup.rb
  275. 0 {ripple → }/spec/support/integration_setup.rb
  276. 0 {ripple → }/spec/support/models.rb
  277. 0 {ripple → }/spec/support/models/address.rb
  278. 0 {ripple → }/spec/support/models/box.rb
  279. 0 {ripple → }/spec/support/models/car.rb
  280. 0 {ripple → }/spec/support/models/cardboard_box.rb
  281. 0 {ripple → }/spec/support/models/clock.rb
  282. 0 {ripple → }/spec/support/models/clock_observer.rb
  283. 0 {ripple → }/spec/support/models/company.rb
  284. 0 {ripple → }/spec/support/models/credit_card.rb
  285. 0 {ripple → }/spec/support/models/customer.rb
  286. 0 {ripple → }/spec/support/models/email.rb
  287. 0 {ripple → }/spec/support/models/family.rb
  288. 0 {ripple → }/spec/support/models/favorite.rb
  289. 0 {ripple → }/spec/support/models/indexer.rb
  290. 0 {ripple → }/spec/support/models/invoice.rb
  291. 0 {ripple → }/spec/support/models/late_invoice.rb
  292. 0 {ripple → }/spec/support/models/nested.rb
  293. 0 {ripple → }/spec/support/models/ninja.rb
  294. 0 {ripple → }/spec/support/models/note.rb
  295. 0 {ripple → }/spec/support/models/page.rb
  296. 0 {ripple → }/spec/support/models/paid_invoice.rb
  297. 0 {ripple → }/spec/support/models/post.rb
  298. 0 {ripple → }/spec/support/models/profile.rb
  299. 0 {ripple → }/spec/support/models/subscription.rb
  300. 0 {ripple → }/spec/support/models/tasks.rb
Sorry, we could not display the entire diff because too many files (316) changed.
View
0 ripple/Gemfile → Gemfile
File renamed without changes.
View
0 ripple/Guardfile → Guardfile
File renamed without changes.
View
110 Rakefile
@@ -1,98 +1,44 @@
require 'rubygems'
-require 'rake'
-require 'rake/clean'
+require 'rubygems/package_task'
+require 'rspec/core'
+require 'rspec/core/rake_task'
-PROJECTS = %w{riak-client ripple riak-sessions}
-
-begin
- require 'yard'
- desc "Generate YARD documentation."
- YARD::Rake::YardocTask.new do |yard|
- docfiles = FileList['{riak-client,ripple,riak-sessions}/lib/**/*.rb']
- docfiles.exclude '**/generators/**/templates/*'
- yard.files = docfiles.to_a + ['-','RELEASE_NOTES.textile']
- yard.options = ["--no-private"]
- end
+def gemspec
+ $ripple_gemspec ||= Gem::Specification.load("ripple.gemspec")
+end
- desc "Generate YARD documentation into a repo on the gh-pages branch."
- task :doc => :yard do
- original_dir = Dir.pwd
- docs_dir = File.expand_path(File.join(original_dir, "..", "ripple-docs"))
- rm_rf File.join(docs_dir, "*")
- cp_r File.join(original_dir, "doc", "."), docs_dir
- touch File.join(docs_dir, '.nojekyll')
- end
-rescue LoadError, NameError
+Gem::PackageTask.new(gemspec) do |pkg|
+ pkg.need_zip = false
+ pkg.need_tar = false
end
-namespace :spec do
- PROJECTS.each do |dir|
- desc "Run specs for sub-project #{dir}."
- task dir do
- Dir.chdir(dir) do
- system 'rake spec'
- end
- end
- end
+task :gem => :gemspec
- desc "Run integration specs for all sub-projects."
- task :integration do
- %w{riak-client ripple}.each do |dir|
- Dir.chdir(dir) do
- system 'rake spec:integration'
- end
- end
- end
+desc %{Validate the gemspec file.}
+task :gemspec do
+ gemspec.validate
end
-desc "Regenerate all gemspecs."
-task :gemspecs do
- PROJECTS.each do |dir|
- Dir.chdir(dir) do
- system "rake gemspec"
- end
- end
+desc %{Release the gem to RubyGems.org}
+task :release => :gem do
+ system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
end
-desc "Release all gems to Rubygems.org."
-task :release do
- PROJECTS.each do |dir|
- Dir.chdir(dir) do
- system "rake release"
- end
- end
+desc "Run Unit Specs Only"
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.rspec_opts = %w[--profile --tag ~integration]
end
-desc "Cleans up white space for each project"
-task :clean_whitespace do
- PROJECTS.each do |dir|
- Dir.chdir(dir) do
- no_file_cleaned = true
- puts
- puts ("=" * 20) + " #{dir} " + ("=" * 20)
-
- Dir["**/*.rb"].each do |file|
- contents = File.read(file)
- cleaned_contents = contents.gsub(/([ \t]+)$/, '')
-
- unless cleaned_contents == contents
- no_file_cleaned = false
- puts " - Cleaned #{file}"
- File.open(file, 'w') { |f| f.write(cleaned_contents) }
- end
- end
+namespace :spec do
+ desc "Run Integration Specs Only"
+ RSpec::Core::RakeTask.new(:integration) do |spec|
+ spec.rspec_opts = %w[--profile --tag integration]
+ end
- if no_file_cleaned
- puts "No files with trailing whitespace found"
- end
- end
+ desc "Run All Specs"
+ RSpec::Core::RakeTask.new(:all) do |spec|
+ spec.rspec_opts = %w[--profile]
end
end
-desc "Run all sub-project specs."
-task :spec => ["spec:riak-client", "spec:ripple", "spec:riak-sessions"]
-
-task :default => :spec
-
-CLOBBER.include(".yardoc")
-CLOBBER.include("doc")
+task :default => "spec:all"
View
1 VERSION
@@ -1 +0,0 @@
-1.0.0.pre
View
30 ci/build_all
@@ -1,30 +0,0 @@
-#!/usr/bin/env bash
-
-retval=0
-
-projects=( riak-client riak-sessions ripple )
-
-ulimit -n 1024
-
-for p in "${projects[@]}"
-do
- cd $p
-
- echo
- echo
- echo "------------------ $p --------------------"
- echo
-
- export BUNDLE_GEMFILE=Gemfile
- bundle install
- echo "--color" > .rspec
- rake
- thisretval=$?
- retval=$(($retval+$thisretval))
-
- echo "------------------ $p (Exit $thisretval) ------------------"
-
- cd ..
-done
-
-exit $retval
View
19 ci/create_test_server_yml
@@ -1,19 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'yaml'
-
-settings = {
- 'root' => File.expand_path('.riaktest'),
- 'source' => ENV['RIAK_BIN_DIR']
-}
-
-settings_string = settings.to_yaml
-
-projects = %w[ riak-client riak-sessions ripple ]
-
-projects.each do |project|
- File.open("#{project}/spec/support/test_server.yml", 'w') do |f|
- f.write(settings_string)
- end
-end
-
View
6 ci/disable_jruby_native
@@ -1,6 +0,0 @@
-#!/usr/bin/env bash
-
-if [ -n "$CI" -a -n "$TRAVIS" ]; then
- (echo $MY_RUBY_HOME | grep -q jruby) && find "$MY_RUBY_HOME" -name "libjruby-cext.*" -exec mv {} {}.bad \;
-fi
-exit 0
View
0 .../configuration/configuration_generator.rb → .../configuration/configuration_generator.rb
File renamed without changes.
View
0 ...ripple/configuration/templates/ripple.yml → ...ripple/configuration/templates/ripple.yml
File renamed without changes.
View
0 ...ails/generators/ripple/js/js_generator.rb → ...ails/generators/ripple/js/js_generator.rb
File renamed without changes.
View
0 ...erators/ripple/js/templates/js/contrib.js → ...erators/ripple/js/templates/js/contrib.js
File renamed without changes.
View
0 ...erators/ripple/js/templates/js/iso8601.js → ...erators/ripple/js/templates/js/iso8601.js
File renamed without changes.
View
0 ...nerators/ripple/js/templates/js/ripple.js → ...nerators/ripple/js/templates/js/ripple.js
File renamed without changes.
View
0 ...enerators/ripple/model/model_generator.rb → ...enerators/ripple/model/model_generator.rb
File renamed without changes.
View
0 ...ators/ripple/model/templates/model.rb.erb → ...ators/ripple/model/templates/model.rb.erb
File renamed without changes.
View
0 ...ors/ripple/observer/observer_generator.rb → ...ors/ripple/observer/observer_generator.rb
File renamed without changes.
View
0 ...ripple/observer/templates/observer.rb.erb → ...ripple/observer/templates/observer.rb.erb
File renamed without changes.
View
0 ...ors/ripple/test/templates/cucumber.rb.erb → ...ors/ripple/test/templates/cucumber.rb.erb
File renamed without changes.
View
0 .../generators/ripple/test/test_generator.rb → .../generators/ripple/test/test_generator.rb
File renamed without changes.
View
0 .../lib/rails/generators/ripple_generator.rb → lib/rails/generators/ripple_generator.rb
File renamed without changes.
View
0 ripple/lib/ripple.rb → lib/ripple.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations.rb → lib/ripple/associations.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations/embedded.rb → lib/ripple/associations/embedded.rb
File renamed without changes.
View
0 .../lib/ripple/associations/instantiators.rb → lib/ripple/associations/instantiators.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations/linked.rb → lib/ripple/associations/linked.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations/many.rb → lib/ripple/associations/many.rb
File renamed without changes.
View
0 ...ipple/associations/many_embedded_proxy.rb → ...ipple/associations/many_embedded_proxy.rb
File renamed without changes.
View
0 .../ripple/associations/many_linked_proxy.rb → lib/ripple/associations/many_linked_proxy.rb
File renamed without changes.
View
0 ...pple/associations/many_reference_proxy.rb → ...pple/associations/many_reference_proxy.rb
File renamed without changes.
View
0 ...ple/associations/many_stored_key_proxy.rb → ...ple/associations/many_stored_key_proxy.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations/one.rb → lib/ripple/associations/one.rb
File renamed without changes.
View
0 ...ripple/associations/one_embedded_proxy.rb → ...ripple/associations/one_embedded_proxy.rb
File renamed without changes.
View
0 .../lib/ripple/associations/one_key_proxy.rb → lib/ripple/associations/one_key_proxy.rb
File renamed without changes.
View
0 ...b/ripple/associations/one_linked_proxy.rb → lib/ripple/associations/one_linked_proxy.rb
File renamed without changes.
View
0 ...pple/associations/one_stored_key_proxy.rb → ...pple/associations/one_stored_key_proxy.rb
File renamed without changes.
View
0 ripple/lib/ripple/associations/proxy.rb → lib/ripple/associations/proxy.rb
File renamed without changes.
View
0 ripple/lib/ripple/attribute_methods.rb → lib/ripple/attribute_methods.rb
File renamed without changes.
View
0 ripple/lib/ripple/attribute_methods/dirty.rb → lib/ripple/attribute_methods/dirty.rb
File renamed without changes.
View
0 ripple/lib/ripple/attribute_methods/query.rb → lib/ripple/attribute_methods/query.rb
File renamed without changes.
View
0 ripple/lib/ripple/attribute_methods/read.rb → lib/ripple/attribute_methods/read.rb
File renamed without changes.
View
0 ripple/lib/ripple/attribute_methods/write.rb → lib/ripple/attribute_methods/write.rb
File renamed without changes.
View
0 ripple/lib/ripple/callbacks.rb → lib/ripple/callbacks.rb
File renamed without changes.
View
0 ripple/lib/ripple/conflict/basic_resolver.rb → lib/ripple/conflict/basic_resolver.rb
File renamed without changes.
View
0 ripple/lib/ripple/conflict/document_hooks.rb → lib/ripple/conflict/document_hooks.rb
File renamed without changes.
View
0 ripple/lib/ripple/conflict/resolver.rb → lib/ripple/conflict/resolver.rb
File renamed without changes.
View
0 ripple/lib/ripple/conflict/test_helper.rb → lib/ripple/conflict/test_helper.rb
File renamed without changes.
View
0 ripple/lib/ripple/conversion.rb → lib/ripple/conversion.rb
File renamed without changes.
View
0 ripple/lib/ripple/core_ext.rb → lib/ripple/core_ext.rb
File renamed without changes.
View
0 ripple/lib/ripple/core_ext/casting.rb → lib/ripple/core_ext/casting.rb
File renamed without changes.
View
0 ripple/lib/ripple/core_ext/indexes.rb → lib/ripple/core_ext/indexes.rb
File renamed without changes.
View
0 ripple/lib/ripple/core_ext/object.rb → lib/ripple/core_ext/object.rb
File renamed without changes.
View
0 ripple/lib/ripple/document.rb → lib/ripple/document.rb
File renamed without changes.
View
0 ripple/lib/ripple/document/bucket_access.rb → lib/ripple/document/bucket_access.rb
File renamed without changes.
View
0 ripple/lib/ripple/document/finders.rb → lib/ripple/document/finders.rb
File renamed without changes.
View
0 ripple/lib/ripple/document/key.rb → lib/ripple/document/key.rb
File renamed without changes.
View
0 ripple/lib/ripple/document/link.rb → lib/ripple/document/link.rb
File renamed without changes.
View
0 ripple/lib/ripple/document/persistence.rb → lib/ripple/document/persistence.rb
File renamed without changes.
View
0 ripple/lib/ripple/embedded_document.rb → lib/ripple/embedded_document.rb
File renamed without changes.
View
0 ...ple/embedded_document/around_callbacks.rb → ...ple/embedded_document/around_callbacks.rb
File renamed without changes.
View
0 ...e/lib/ripple/embedded_document/finders.rb → lib/ripple/embedded_document/finders.rb
File renamed without changes.
View
0 ...b/ripple/embedded_document/persistence.rb → lib/ripple/embedded_document/persistence.rb
File renamed without changes.
View
0 ripple/lib/ripple/i18n.rb → lib/ripple/i18n.rb
File renamed without changes.
View
0 ripple/lib/ripple/indexes.rb → lib/ripple/indexes.rb
File renamed without changes.
View
0 ripple/lib/ripple/inspection.rb → lib/ripple/inspection.rb
File renamed without changes.
View
0 ripple/lib/ripple/locale/en.yml → lib/ripple/locale/en.yml
File renamed without changes.
View
0 ripple/lib/ripple/nested_attributes.rb → lib/ripple/nested_attributes.rb
File renamed without changes.
View
0 ripple/lib/ripple/observable.rb → lib/ripple/observable.rb
File renamed without changes.
View
0 ripple/lib/ripple/properties.rb → lib/ripple/properties.rb
File renamed without changes.
View
0 ripple/lib/ripple/property_type_mismatch.rb → lib/ripple/property_type_mismatch.rb
File renamed without changes.
View
0 ripple/lib/ripple/railtie.rb → lib/ripple/railtie.rb
File renamed without changes.
View
0 ripple/lib/ripple/railties/ripple.rake → lib/ripple/railties/ripple.rake
File renamed without changes.
View
0 ripple/lib/ripple/serialization.rb → lib/ripple/serialization.rb
File renamed without changes.
View
0 ripple/lib/ripple/test_server.rb → lib/ripple/test_server.rb
File renamed without changes.
View
0 ripple/lib/ripple/timestamps.rb → lib/ripple/timestamps.rb
File renamed without changes.
View
0 ripple/lib/ripple/translation.rb → lib/ripple/translation.rb
File renamed without changes.
View
0 ripple/lib/ripple/validations.rb → lib/ripple/validations.rb
File renamed without changes.
View
0 ...ipple/validations/associated_validator.rb → ...ipple/validations/associated_validator.rb
File renamed without changes.
View
0 ripple/lib/ripple/version.rb → lib/ripple/version.rb
File renamed without changes.
View
32 riak-client/.gitignore
@@ -1,32 +0,0 @@
-## MAC OS
-.DS_Store
-
-## TEXTMATE
-*.tmproj
-tmtags
-
-## EMACS
-*~
-\#*
-.\#*
-
-## VIM
-*.swp
-
-## PROJECT::GENERAL
-coverage/**/*
-rdoc/**/*
-pkg/**/*
-
-## PROJECT::SPECIFIC
-doc
-.yardoc
-.bundle
-spec/support/test_server.yml
-Gemfile.lock
-**/bin
-*.rbc
-.rvmrc
-
-.ripplenode
-.riaktest
View
1 riak-client/.rspec
@@ -1 +0,0 @@
---color
View
2 riak-client/.watchr
@@ -1,2 +0,0 @@
-watch("spec/(.*)_spec.rb") {|md| system %Q[echo "-----------------------------------------"; rvm --with-rubies jruby,1.8.7,1.9.2 exec "rvm tools identifier; echo; rspec #{md[0]}"] }
-trap("INT") { exit }
View
34 riak-client/Gemfile
@@ -1,34 +0,0 @@
-source :rubygems
-
-gemspec
-gem 'bundler'
-
-unless ENV['TRAVIS']
- gem 'guard-rspec'
- gem 'rb-fsevent'
- gem 'growl'
-end
-
-platforms :mri do
- gem 'yajl-ruby'
-end
-
-platforms :jruby do
- gem 'jruby-openssl'
-end
-
-group :integration do
- if ENV['RAILS31']
- gem 'activesupport', '~> 3.1.0'
- else
- gem 'activesupport', '~> 3.0.10'
- end
-end
-
-# platforms :mri_18, :jruby do
-# gem 'ruby-debug'
-# end
-
-# platforms :mri_19 do
-# gem 'ruby-debug19'
-# end
View
14 riak-client/Guardfile
@@ -1,14 +0,0 @@
-# A sample Guardfile
-# More info at https://github.com/guard/guard#readme
-gemset = ENV['RVM_GEMSET'] || 'ripple'
-gemset = "@#{gemset}" unless gemset.to_s == ''
-
-rvms = %w[ 1.8.7 1.9.2 jruby ].map do |version|
- "#{version}@#{gemset}"
-end
-
-guard 'rspec', :cli => '--profile --tag "~slow"', :rvm => rvms do
- watch(%r{^spec/.+_spec\.rb$})
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
- watch('spec/spec_helper.rb') { "spec/riak" }
-end
View
49 riak-client/Rakefile
@@ -1,49 +0,0 @@
-require 'rubygems'
-require 'rubygems/package_task'
-require 'rspec/core'
-require 'rspec/core/rake_task'
-
-def gemspec
- $riakclient_gemspec ||= Gem::Specification.load("riak-client.gemspec")
-end
-
-Gem::PackageTask.new(gemspec) do |pkg|
- pkg.need_zip = false
- pkg.need_tar = false
-end
-
-task :gem => :gemspec
-
-desc %{Validate the gemspec file.}
-task :gemspec do
- gemspec.validate
-end
-
-desc %{Release the gem to RubyGems.org}
-task :release => :gem do
- system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
-end
-
-desc "Run Unit Specs Only"
-RSpec::Core::RakeTask.new(:spec) do |spec|
- spec.rspec_opts = %w[--profile --tag ~integration --tag ~slow]
-end
-
-namespace :spec do
- desc "Run Integration Specs Only (without explicitly slow specs)"
- RSpec::Core::RakeTask.new(:integration) do |spec|
- spec.rspec_opts = %w[--profile --tag '~slow' --tag integration]
- end
-
- desc "Run All Specs (without explicitly slow specs)"
- RSpec::Core::RakeTask.new(:all) do |spec|
- spec.rspec_opts = %w[--profile --tag '~slow']
- end
-end
-
-desc "Run All Specs (including slow specs)"
-RSpec::Core::RakeTask.new(:ci) do |spec|
- spec.rspec_opts = %w[--profile]
-end
-
-task :default => :ci
View
BIN riak-client/erl_src/riak_kv_test_backend.beam
Binary file not shown.
View
540 riak-client/erl_src/riak_kv_test_backend.erl
@@ -1,540 +0,0 @@
-%% -------------------------------------------------------------------
-%%
-%% riak_memory_backend: storage engine using ETS tables
-%%
-%% Copyright (c) 2007-2011 Basho Technologies, Inc. All Rights Reserved.
-%%
-%% This file is provided to you under the Apache License,
-%% Version 2.0 (the "License"); you may not use this file
-%% except in compliance with the License. You may obtain
-%% a copy of the License at
-%%
-%% http://www.apache.org/licenses/LICENSE-2.0
-%%
-%% Unless required by applicable law or agreed to in writing,
-%% software distributed under the License is distributed on an
-%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-%% KIND, either express or implied. See the License for the
-%% specific language governing permissions and limitations
-%% under the License.
-%%
-%% -------------------------------------------------------------------
-
-%% @doc riak_kv_memory_backend is a Riak storage backend that uses ets
-%% tables to store all data in memory.
-%%
-%% === Configuration Options ===
-%%
-%% The following configuration options are available for the memory backend.
-%% The options should be specified in the `memory_backend' section of your
-%% app.config file.
-%%
-%% <ul>
-%% <li>`ttl' - The time in seconds that an object should live before being expired.</li>
-%% <li>`max_memory' - The amount of memory in megabytes to limit the backend to.</li>
-%% </ul>
-%%
-
--module(riak_kv_test_backend).
--behavior(riak_kv_backend).
-
-%% KV Backend API
--export([api_version/0,
- start/2,
- stop/1,
- get/3,
- put/5,
- delete/4,
- drop/1,
- fold_buckets/4,
- fold_keys/4,
- fold_objects/4,
- is_empty/1,
- status/1,
- callback/3,
- reset/0,
- capabilities/1,
- capabilities/2]).
-
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
--endif.
-
--define(API_VERSION, 1).
--define(CAPABILITIES, [async_fold]).
-
--record(state, {data_ref :: integer() | atom(),
- time_ref :: integer() | atom(),
- max_memory :: undefined | integer(),
- used_memory=0 :: integer(),
- ttl :: integer()}).
-
--type state() :: #state{}.
--type config() :: [].
-
-%% ===================================================================
-%% Public API
-%% ===================================================================
-
-%% TestServer reset
-
--spec reset() -> ok | {error, timeout}.
-reset() ->
- {ok, Ring} = riak_core_ring_manager:get_my_ring(),
- [ catch ets:delete_all_objects(list_to_atom("kv" ++ integer_to_list(P))) ||
- P <- riak_core_ring:my_indices(Ring) ],
- ok.
-
-%% KV Backend API
-
-%% @doc Return the major version of the
-%% current API and a capabilities list.
--spec api_version() -> {ok, integer()} | {integer(), [atom()]}.
-api_version() ->
- case lists:member({capabilities, 1}, riak_kv_backend:behaviour_info(callbacks)) of
- true -> % Using 1.1 API or later
- {ok, ?API_VERSION};
- _ -> % Using 1.0 API
- {?API_VERSION, ?CAPABILITIES}
- end.
-
-%% @doc Return the capabilities of the backend.
--spec capabilities(state()) -> {ok, [atom()]}.
-capabilities(_) ->
- {ok, ?CAPABILITIES}.
-
-%% @doc Return the capabilities of the backend.
--spec capabilities(riak_object:bucket(), state()) -> {ok, [atom()]}.
-capabilities(_, _) ->
- {ok, ?CAPABILITIES}.
-
-%% @doc Start the memory backend
--spec start(integer(), config()) -> {ok, state()}.
-start(Partition, _Config) ->
- %% TTL = config_value(ttl, Config),
- %% MemoryMB = config_value(max_memory, Config),
- %% case MemoryMB of
- %% undefined ->
- %% MaxMemory = undefined,
- %% TimeRef = undefined;
- %% _ ->
- %% MaxMemory = MemoryMB * 1024 * 1024,
- %% TimeRef = ets:new(list_to_atom(integer_to_list(Partition)), [ordered_set])
- %% end,
- DataRef = ets:new(list_to_atom("kv" ++ integer_to_list(Partition)), [named_table, public]),
- {ok, #state{data_ref=DataRef
- %% max_memory=MaxMemory,
- %% time_ref=TimeRef,
- %% ttl=TTL
- }}.
-
-%% @doc Stop the memory backend
--spec stop(state()) -> ok.
-stop(#state{data_ref=DataRef,
- max_memory=MaxMemory,
- time_ref=TimeRef}) ->
- catch ets:delete(DataRef),
- case MaxMemory of
- undefined ->
- ok;
- _ ->
- catch ets:delete(TimeRef)
- end,
- ok.
-
-%% @doc Retrieve an object from the memory backend
--spec get(riak_object:bucket(), riak_object:key(), state()) ->
- {ok, any(), state()} |
- {ok, not_found, state()} |
- {error, term(), state()}.
-get(Bucket, Key, State=#state{data_ref=DataRef,
- ttl=TTL}) ->
- case ets:lookup(DataRef, {Bucket, Key}) of
- [] -> {error, not_found, State};
- [{{Bucket, Key}, {{ts, Timestamp}, Val}}] ->
- case exceeds_ttl(Timestamp, TTL) of
- true ->
- delete(Bucket, Key, undefined, State),
- {error, not_found, State};
- false ->
- {ok, Val, State}
- end;
- [{{Bucket, Key}, Val}] ->
- {ok, Val, State};
- Error ->
- {error, Error, State}
- end.
-
-%% @doc Insert an object into the memory backend.
-%% NOTE: The memory backend does not currently
-%% support secondary indexing and the _IndexSpecs
-%% parameter is ignored.
--type index_spec() :: {add, Index, SecondaryKey} | {remove, Index, SecondaryKey}.
--spec put(riak_object:bucket(), riak_object:key(), [index_spec()], binary(), state()) ->
- {ok, state()} |
- {error, term(), state()}.
-put(Bucket, PrimaryKey, _IndexSpecs, Val, State=#state{data_ref=DataRef,
- max_memory=MaxMemory,
- time_ref=TimeRef,
- ttl=TTL,
- used_memory=UsedMemory}) ->
- Now = now(),
- case TTL of
- undefined ->
- Val1 = Val;
- _ ->
- Val1 = {{ts, Now}, Val}
- end,
- case do_put(Bucket, PrimaryKey, Val1, DataRef) of
- {ok, Size} ->
- %% If the memory is capped update timestamp table
- %% and check if the memory usage is over the cap.
- case MaxMemory of
- undefined ->
- UsedMemory1 = UsedMemory;
- _ ->
- time_entry(Bucket, PrimaryKey, Now, TimeRef),
- Freed = trim_data_table(MaxMemory,
- UsedMemory + Size,
- DataRef,
- TimeRef,
- 0),
- UsedMemory1 = UsedMemory + Size - Freed
- end,
- {ok, State#state{used_memory=UsedMemory1}};
- {error, Reason} ->
- {error, Reason, State}
- end.
-
-%% @doc Delete an object from the memory backend
-%% NOTE: The memory backend does not currently
-%% support secondary indexing and the _IndexSpecs
-%% parameter is ignored.
--spec delete(riak_object:bucket(), riak_object:key(), [index_spec()], state()) ->
- {ok, state()}.
-delete(Bucket, Key, _IndexSpecs, State=#state{data_ref=DataRef,
- time_ref=TimeRef,
- used_memory=UsedMemory}) ->
- case TimeRef of
- undefined ->
- UsedMemory1 = UsedMemory;
- _ ->
- %% Lookup the object so we can delete its
- %% entry from the time table and account
- %% for the memory used.
- [Object] = ets:lookup(DataRef, {Bucket, Key}),
- case Object of
- {_, {{ts, Timestamp}, _}} ->
- ets:delete(TimeRef, Timestamp),
- UsedMemory1 = UsedMemory - object_size(Object);
- _ ->
- UsedMemory1 = UsedMemory
- end
- end,
- ets:delete(DataRef, {Bucket, Key}),
- {ok, State#state{used_memory=UsedMemory1}}.
-
-%% @doc Fold over all the buckets.
--spec fold_buckets(riak_kv_backend:fold_buckets_fun(),
- any(),
- [],
- state()) -> {ok, any()}.
-fold_buckets(FoldBucketsFun, Acc, Opts, #state{data_ref=DataRef}) ->
- FoldFun = fold_buckets_fun(FoldBucketsFun),
- case lists:member(async_fold, Opts) of
- true ->
- BucketFolder =
- fun() ->
- {Acc0, _} = ets:foldl(FoldFun, {Acc, sets:new()}, DataRef),
- Acc0
- end,
- {async, BucketFolder};
- false ->
- {Acc0, _} = ets:foldl(FoldFun, {Acc, sets:new()}, DataRef),
- {ok, Acc0}
- end.
-
-%% @doc Fold over all the keys for one or all buckets.
--spec fold_keys(riak_kv_backend:fold_keys_fun(),
- any(),
- [{atom(), term()}],
- state()) -> {ok, term()} | {async, fun()}.
-fold_keys(FoldKeysFun, Acc, Opts, #state{data_ref=DataRef}) ->
- Bucket = proplists:get_value(bucket, Opts),
- FoldFun = fold_keys_fun(FoldKeysFun, Bucket),
- case lists:member(async_fold, Opts) of
- true ->
- {async, get_folder(FoldFun, Acc, DataRef)};
- false ->
- Acc0 = ets:foldl(FoldFun, Acc, DataRef),
- {ok, Acc0}
- end.
-
-%% @doc Fold over all the objects for one or all buckets.
--spec fold_objects(riak_kv_backend:fold_objects_fun(),
- any(),
- [{atom(), term()}],
- state()) -> {ok, any()} | {async, fun()}.
-fold_objects(FoldObjectsFun, Acc, Opts, #state{data_ref=DataRef}) ->
- Bucket = proplists:get_value(bucket, Opts),
- FoldFun = fold_objects_fun(FoldObjectsFun, Bucket),
- case lists:member(async_fold, Opts) of
- true ->
- {async, get_folder(FoldFun, Acc, DataRef)};
- false ->
- Acc0 = ets:foldl(FoldFun, Acc, DataRef),
- {ok, Acc0}
- end.
-
-%% @doc Delete all objects from this memory backend
--spec drop(state()) -> {ok, state()}.
-drop(State=#state{data_ref=DataRef,
- time_ref=TimeRef}) ->
- ets:delete_all_objects(DataRef),
- case TimeRef of
- undefined ->
- ok;
- _ ->
- ets:delete_all_objects(TimeRef)
- end,
- {ok, State}.
-
-%% @doc Returns true if this memory backend contains any
-%% non-tombstone values; otherwise returns false.
--spec is_empty(state()) -> boolean().
-is_empty(#state{data_ref=DataRef}) ->
- ets:info(DataRef, size) =:= 0.
-
-%% @doc Get the status information for this memory backend
--spec status(state()) -> [{atom(), term()}].
-status(#state{data_ref=DataRef,
- time_ref=TimeRef}) ->
- DataStatus = ets:info(DataRef),
- case TimeRef of
- undefined ->
- [{data_table_status, DataStatus}];
- _ ->
- TimeStatus = ets:info(TimeRef),
- [{data_table_status, DataStatus},
- {time_table_status, TimeStatus}]
- end.
-
-%% @doc Register an asynchronous callback
--spec callback(reference(), any(), state()) -> {ok, state()}.
-callback(_Ref, _Msg, State) ->
- {ok, State}.
-
-%% ===================================================================
-%% Internal functions
-%% ===================================================================
-
-%% @TODO Some of these implementations may be suboptimal.
-%% Need to do some measuring and testing to refine the
-%% implementations.
-
-%% @private
-%% Return a function to fold over the buckets on this backend
-fold_buckets_fun(FoldBucketsFun) ->
- fun({{Bucket, _}, _}, {Acc, BucketSet}) ->
- case sets:is_element(Bucket, BucketSet) of
- true ->
- {Acc, BucketSet};
- false ->
- {FoldBucketsFun(Bucket, Acc),
- sets:add_element(Bucket, BucketSet)}
- end
- end.
-
-%% @private
-%% Return a function to fold over keys on this backend
-fold_keys_fun(FoldKeysFun, undefined) ->
- fun({{Bucket, Key}, _}, Acc) ->
- FoldKeysFun(Bucket, Key, Acc)
- end;
-fold_keys_fun(FoldKeysFun, Bucket) ->
- fun({{B, Key}, _}, Acc) ->
- case B =:= Bucket of
- true ->
- FoldKeysFun(Bucket, Key, Acc);
- false ->
- Acc
- end
- end.
-
-%% @private
-%% Return a function to fold over keys on this backend
-fold_objects_fun(FoldObjectsFun, undefined) ->
- fun({{Bucket, Key}, Value}, Acc) ->
- FoldObjectsFun(Bucket, Key, Value, Acc)
- end;
-fold_objects_fun(FoldObjectsFun, Bucket) ->
- fun({{B, Key}, Value}, Acc) ->
- case B =:= Bucket of
- true ->
- FoldObjectsFun(Bucket, Key, Value, Acc);
- false ->
- Acc
- end
- end.
-
-%% @private
-get_folder(FoldFun, Acc, DataRef) ->
- fun() ->
- ets:foldl(FoldFun, Acc, DataRef)
- end.
-
-%% @private
-do_put(Bucket, Key, Val, Ref) ->
- Object = {{Bucket, Key}, Val},
- true = ets:insert(Ref, Object),
- {ok, object_size(Object)}.
-
-%% @private
-config_value(Key, Config) ->
- config_value(Key, Config, undefined).
-
-%% @private
-config_value(Key, Config, Default) ->
- case proplists:get_value(Key, Config) of
- undefined ->
- app_helper:get_env(memory_backend, Key, Default);
- Value ->
- Value
- end.
-
-%% Check if this timestamp is past the ttl setting.
-exceeds_ttl(Timestamp, TTL) ->
- Diff = (timer:now_diff(now(), Timestamp) / 1000 / 1000),
- Diff > TTL.
-
-%% @private
-time_entry(Bucket, Key, Now, TimeRef) ->
- ets:insert(TimeRef, {Now, {Bucket, Key}}).
-
-%% @private
-%% @doc Dump some entries if the max memory size has
-%% been breached.
-trim_data_table(MaxMemory, UsedMemory, _, _, Freed) when
- (UsedMemory - Freed) =< MaxMemory ->
- Freed;
-trim_data_table(MaxMemory, UsedMemory, DataRef, TimeRef, Freed) ->
- %% Delete the oldest object
- OldestSize = delete_oldest(DataRef, TimeRef),
- trim_data_table(MaxMemory,
- UsedMemory,
- DataRef,
- TimeRef,
- Freed + OldestSize).
-
-%% @private
-delete_oldest(DataRef, TimeRef) ->
- OldestTime = ets:first(TimeRef),
- case OldestTime of
- '$end_of_table' ->
- 0;
- _ ->
- OldestKey = ets:lookup_element(TimeRef, OldestTime, 2),
- ets:delete(TimeRef, OldestTime),
- case ets:lookup(DataRef, OldestKey) of
- [] ->
- delete_oldest(DataRef, TimeRef);
- [Object] ->
- ets:delete(DataRef, OldestKey),
- object_size(Object)
- end
- end.
-
-%% @private
-object_size(Object) ->
- case Object of
- {{Bucket, Key}, {{ts, _}, Val}} ->
- ok;
- {{Bucket, Key}, Val} ->
- ok
- end,
- size(Bucket) + size(Key) + size(Val).
-
-%% ===================================================================
-%% EUnit tests
-%% ===================================================================
-
--ifdef(TEST).
-
-simple_test_() ->
- riak_kv_backend:standard_test(?MODULE, []).
-
-ttl_test_() ->
- Config = [{ttl, 15}],
- {ok, State} = start(42, Config),
-
- Bucket = <<"Bucket">>,
- Key = <<"Key">>,
- Value = <<"Value">>,
-
- [
- %% Put an object
- ?_assertEqual({ok, State}, put(Bucket, Key, [], Value, State)),
- %% Wait 1 second to access it
- ?_assertEqual(ok, timer:sleep(1000)),
- ?_assertEqual({ok, Value, State}, get(Bucket, Key, State)),
- %% Wait 3 seconds and access it again
- ?_assertEqual(ok, timer:sleep(3000)),
- ?_assertEqual({ok, Value, State}, get(Bucket, Key, State)),
- %% Wait 15 seconds and it should expire
- {timeout, 30000, ?_assertEqual(ok, timer:sleep(15000))},
- %% This time it should be gone
- ?_assertEqual({error, not_found, State}, get(Bucket, Key, State))
- ].
-
-%% @private
-max_memory_test_() ->
- %% Set max size to 1.5kb
- Config = [{max_memory, 1.5 * (1 / 1024)}],
- {ok, State} = start(42, Config),
-
- Bucket = <<"Bucket">>,
- Key1 = <<"Key1">>,
- Value1 = list_to_binary(string:copies("1", 1024)),
- Key2 = <<"Key2">>,
- Value2 = list_to_binary(string:copies("2", 1024)),
-
- %% Write Key1 to the datastore
- {ok, State1} = put(Bucket, Key1, [], Value1, State),
- timer:sleep(timer:seconds(1)),
- %% Write Key2 to the datastore
- {ok, State2} = put(Bucket, Key2, [], Value2, State1),
-
- [
- %% Key1 should be kicked out
- ?_assertEqual({error, not_found, State2}, get(Bucket, Key1, State2)),
- %% Key2 should still be present
- ?_assertEqual({ok, Value2, State2}, get(Bucket, Key2, State2))
- ].
-
--ifdef(EQC).
-
-eqc_test_() ->
- {spawn,
- [{inorder,
- [{setup,
- fun setup/0,
- fun cleanup/1,
- [
- {timeout, 60000,
- [?_assertEqual(true,
- backend_eqc:test(?MODULE, true))]}
- ]}]}]}.
-
-setup() ->
- application:load(sasl),
- application:set_env(sasl, sasl_error_logger, {file, "riak_kv_memory_backend_eqc_sasl.log"}),
- error_logger:tty(false),
- error_logger:logfile({open, "riak_kv_memory_backend_eqc.log"}),
- ok.
-
-cleanup(_) ->
- ok.
-
--endif. % EQC
-
--endif. % TEST
View
BIN riak-client/erl_src/riak_search_test_backend.beam
Binary file not shown.
View
175 riak-client/erl_src/riak_search_test_backend.erl
@@ -1,175 +0,0 @@
-%% -------------------------------------------------------------------
-%%
-%% Copyright (c) 2007-2010 Basho Technologies, Inc. All Rights Reserved.
-%%
-%% -------------------------------------------------------------------
-
--module(riak_search_test_backend).
--behavior(riak_search_backend).
-
--export([
- reset/0,
- start/2,
- stop/1,
- index/2,
- delete/2,
- stream/6,
- range/8,
- info/5,
- fold/3,
- is_empty/1,
- drop/1
- ]).
--export([
- stream_results/3
- ]).
-
--include_lib("riak_search/include/riak_search.hrl").
-
--record(state, {partition, table}).
-
-reset() ->
- {ok, Ring} = riak_core_ring_manager:get_my_ring(),
- [ ets:delete_all_objects(list_to_atom("rs" ++ integer_to_list(P))) ||
- P <- riak_core_ring:my_indices(Ring) ],
- riak_search_config:clear(),
- ok.
-
-start(Partition, _Config) ->
- Table = ets:new(list_to_atom("rs" ++ integer_to_list(Partition)),
- [named_table, public, ordered_set]),
- {ok, #state{partition=Partition, table=Table}}.
-
-stop(State) ->
- maybe_delete(State).
-
-index(IFTVPKList, #state{table=Table}=State) ->
- lists:foreach(
- fun({I, F, T, V, P, K}) ->
- Key = {b(I), b(F), b(T), b(V)},
- case ets:lookup(Table, Key) of
- [{_, _, ExistingKeyClock}] ->
- if ExistingKeyClock > K ->
- %% stored data is newer
- ok;
- true ->
- %% stored data is older
- ets:update_element(Table, Key,
- [{2, P},{3, K}])
- end;
- [] ->
- ets:insert(Table, {Key, P, K})
- end
- end,
- IFTVPKList),
- {reply, {indexed, node()}, State}.
-
-delete(IFTVKList, State) ->
- Table = State#state.table,
- lists:foreach(fun(IFTVK) -> delete_fun(IFTVK, Table) end, IFTVKList),
- {reply, {deleted, node()}, State}.
-
-delete_fun({I, F, T, V, K}, Table) ->
- Key = {b(I), b(F), b(T), b(V)},
- case ets:lookup(Table, Key) of
- [{Key, _Props, ExistingKeyClock}] ->
- if ExistingKeyClock > K ->
- %% stored data is newer
- ok;
- true ->
- %% stored data is older
- ets:delete(Table, Key)
- end;
- [] ->
- ok
- end;
-delete_fun({I, F, T, V, _P, K}, Table) ->
- %% copied idea from merge_index_backend
- %% other operations include Props, though delete shouldn't
- delete_fun({I, F, T, V, K}, Table).
-
-info(Index, Field, Term, Sender, State) ->
- Count = ets:select_count(State#state.table,
- [{{{b(Index), b(Field), b(Term), '_'},
- '_', '_'},
- [],[true]}]),
- riak_search_backend:info_response(Sender, [{Term, node(), Count}]),
- noreply.
-
--define(STREAM_SIZE, 100).
-
-range(Index, Field, StartTerm, EndTerm, _Size, FilterFun, Sender, State) ->
- ST = b(StartTerm),
- ET = b(EndTerm),
- spawn(riak_search_ets_backend, stream_results,
- [Sender,
- FilterFun,
- ets:select(State#state.table,
- [{{{b(Index), b(Field), '$1', '$2'}, '$3', '_'},
- [{'>=', '$1', ST}, {'=<', '$1', ET}],
- [{{'$2', '$3'}}]}],
- ?STREAM_SIZE)]),
- noreply.
-
-stream(Index, Field, Term, FilterFun, Sender, State) ->
- spawn(riak_search_ets_backend, stream_results,
- [Sender,
- FilterFun,
- ets:select(State#state.table,
- [{{{b(Index), b(Field), b(Term), '$1'}, '$2', '_'},
- [], [{{'$1', '$2'}}]}],
- ?STREAM_SIZE)]),
- noreply.
-
-stream_results(Sender, FilterFun, {Results0, Continuation}) ->
- case lists:filter(fun({V,P}) -> FilterFun(V, P) end, Results0) of
- [] ->
- ok;
- Results ->
- riak_search_backend:response_results(Sender, Results)
- end,
- stream_results(Sender, FilterFun, ets:select(Continuation));
-stream_results(Sender, _, '$end_of_table') ->
- riak_search_backend:response_done(Sender).
-
-fold(FoldFun, Acc, State) ->
- Fun = fun({{I,F,T,V},P,K}, {OuterAcc, {{I,{F,T}},InnerAcc}}) ->
- %% same IFT, just accumulate doc/props/clock
- {OuterAcc, {{I,{F,T}},[{V,P,K}|InnerAcc]}};
- ({{I,F,T,V},P,K}, {OuterAcc, {FoldKey, VPKList}}) ->
- %% finished a string of IFT, send it off
- %% (sorted order is assumed)
- NewOuterAcc = FoldFun(FoldKey, VPKList, OuterAcc),
- {NewOuterAcc, {{I,{F,T}},[{V,P,K}]}};
- ({{I,F,T,V},P,K}, {OuterAcc, undefined}) ->
- %% first round through the fold - just start building
- {OuterAcc, {{I,{F,T}},[{V,P,K}]}}
- end,
- {OuterAcc0, Final} = ets:foldl(Fun, {Acc, undefined}, State#state.table),
- OuterAcc = case Final of
- {FoldKey, VPKList} ->
- %% one last IFT to send off
- FoldFun(FoldKey, VPKList, OuterAcc0);
- undefined ->
- %% this partition was empty
- OuterAcc0
- end,
- {reply, OuterAcc, State}.
-
-is_empty(State) ->
- 0 == ets:info(State#state.table, size).
-
-drop(State) ->
- maybe_delete(State).
-
-maybe_delete(State) ->
- case lists:member(State#state.table, ets:all()) of
- true ->
- ets:delete(State#state.table),
- ok;
- false ->
- ok
- end.
-
-b(Binary) when is_binary(Binary) -> Binary;
-b(List) when is_list(List) -> iolist_to_binary(List).
View
2 riak-client/lib/active_support/cache/riak_store.rb
@@ -1,2 +0,0 @@
-require 'riak'
-require 'riak/cache_store'
View
21 riak-client/lib/riak.rb
@@ -1,21 +0,0 @@
-require 'riak/encoding'
-require 'riak/core_ext'
-require 'riak/client'
-require 'riak/map_reduce'
-require 'riak/util/translation'
-
-# The Riak module contains all aspects of the client interface to
-# Riak.
-module Riak
- # Utility classes and mixins
- module Util; end
- extend Util::Translation
-
- class << self
- # Only change this if you really know what you're doing. Better to
- # err on the side of caution and assume you don't.
- # @private
- attr_accessor :disable_list_keys_warnings
- end
- self.disable_list_keys_warnings = false
-end
View
221 riak-client/lib/riak/bucket.rb
@@ -1,221 +0,0 @@
-require 'riak/util/translation'
-require 'riak/client'
-require 'riak/robject'
-require 'riak/failed_request'
-
-module Riak
- # Represents and encapsulates operations on a Riak bucket. You may retrieve a bucket
- # using {Client#bucket}, or create it manually and retrieve its meta-information later.
- class Bucket
- include Util::Translation
-
- # (Riak Search) The precommit specification for kv/search integration
- SEARCH_PRECOMMIT_HOOK = {"mod" => "riak_search_kv_hook", "fun" => "precommit"}
-
- # @return [Riak::Client] the associated client
- attr_reader :client
-
- # @return [String] the bucket name
- attr_reader :name
-
- # Create a Riak bucket manually.
- # @param [Client] client the {Riak::Client} for this bucket
- # @param [String] name the name of the bucket
- def initialize(client, name)
- raise ArgumentError, t("client_type", :client => client.inspect) unless Client === client
- raise ArgumentError, t("string_type", :string => name.inspect) unless String === name
- @client, @name = client, name
- end
-
- # Retrieves a list of keys in this bucket.
- # If a block is given, keys will be streamed through
- # the block (useful for large buckets). When streaming,
- # results of the operation will not be returned to the caller.
- # @yield [Array<String>] a list of keys from the current chunk
- # @return [Array<String>] Keys in this bucket
- # @note This operation has serious performance implications and
- # should not be used in production applications.
- def keys(&block)
- warn(t('list_keys', :backtrace => caller.join("\n "))) unless Riak.disable_list_keys_warnings
- if block_given?
- @client.list_keys(self, &block)
- else
- @client.list_keys(self)
- end
- end
-
- # Sets internal properties on the bucket
- # Note: this results in a request to the Riak server!
- # @param [Hash] properties new properties for the bucket
- # @option properties [Fixnum] :n_val (3) The N value (replication factor)
- # @option properties [true,false] :allow_mult (false) Whether to permit object siblings
- # @option properties [true,false] :last_write_wins (false) Whether to ignore vclocks
- # @option properties [Array<Hash>] :precommit ([]) precommit hooks
- # @option properties [Array<Hash>] :postcommit ([])postcommit hooks
- # @option properties [Fixnum,String] :r ("quorum") read quorum (numeric or
- # symbolic)
- # @option properties [Fixnum,String] :w ("quorum") write quorum (numeric or
- # symbolic)
- # @option properties [Fixnum,String] :dw ("quorum") durable write quorum
- # (numeric or symbolic)
- # @option properties [Fixnum,String] :rw ("quorum") delete quorum (numeric or
- # symbolic)
- # @return [Hash] the merged bucket properties
- # @raise [FailedRequest] if the new properties were not accepted by the Riakserver
- # @see #n_value, #allow_mult, #r, #w, #dw, #rw
- def props=(properties)
- raise ArgumentError, t("hash_type", :hash => properties.inspect) unless Hash === properties
- props.merge!(properties)
- @client.set_bucket_props(self, properties)
- props
- end
- alias :'properties=' :'props='
-
- # @return [Hash] Internal Riak bucket properties.
- # @see #props=
- def props
- @props ||= @client.get_bucket_props(self)
- end
- alias :properties :props
-
- # Retrieve an object from within the bucket.
- # @param [String] key the key of the object to retrieve
- # @param [Hash] options query parameters for the request
- # @option options [Fixnum] :r - the read quorum for the request - how many nodes should concur on the read
- # @return [Riak::RObject] the object
- # @raise [FailedRequest] if the object is not found or some other error occurs
- def get(key, options={})
- @client.get_object(self, key, options)
- end
- alias :[] :get
-
- # Create a new blank object
- # @param [String] key the key of the new object
- # @return [RObject] the new, unsaved object
- def new(key=nil)
- RObject.new(self, key).tap do |obj|
- obj.content_type = "application/json"
- end
- end
-
- # Fetches an object if it exists, otherwise creates a new one with the given key
- # @param [String] key the key to fetch or create
- # @return [RObject] the new or existing object
- def get_or_new(key, options={})
- begin
- get(key, options)
- rescue Riak::FailedRequest => fr
- if fr.not_found?
- new(key)
- else
- raise fr
- end
- end
- end
-
- # Checks whether an object exists in Riak.
- # @param [String] key the key to check
- # @param [Hash] options quorum options
- # @option options [Fixnum] :r - the read quorum value for the request (R)
- # @return [true, false] whether the key exists in this bucket
- def exists?(key, options={})
- begin
- get(key, options)
- true
- rescue Riak::FailedRequest
- false
- end
- end
- alias :exist? :exists?
-
- # Deletes a key from the bucket
- # @param [String] key the key to delete
- # @param [Hash] options quorum options
- # @option options [Fixnum] :rw - the read/write quorum for the
- # delete
- # @option options [String] :vclock - the vector clock of the
- # object being deleted
- def delete(key, options={})
- client.delete_object(self, key, options)
- end
-
- # Queries a secondary index on the bucket.
- # @note This will only work if your Riak installation supports 2I.
- # @param [String] index the name of the index
- # @param [String,Integer,Range] query the value of the index, or a
- # Range of values to query
- # @return [Array<String>] a list of keys that match the index
- # query
- def get_index(index, query)
- client.get_index(self, index, query)
- end
-
- # @return [true, false] whether the bucket allows divergent siblings
- def allow_mult
- props['allow_mult']
- end
-
- # Set the allow_mult property. *NOTE* This will result in a PUT request to Riak.
- # @param [true, false] value whether the bucket should allow siblings
- def allow_mult=(value)
- self.props = {'allow_mult' => value}
- value
- end
-
- # @return [Fixnum] the N value, or number of replicas for this bucket
- def n_value
- props['n_val']
- end
- alias :n_val :n_value
-
- # Set the N value (number of replicas). *NOTE* This will result in a PUT request to Riak.
- # Setting this value after the bucket has objects stored in it may have unpredictable results.
- # @param [Fixnum] value the number of replicas the bucket should keep of each object
- def n_value=(value)
- self.props = {'n_val' => value}
- value
- end
- alias :'n_val=' :'n_value='
-
- %w(r w dw rw).each do |q|
- define_method(q) { props[q] }
- define_method("#{q}=") { |value|
- self.props = { q => value }
- value
- }
- end
-
- # (Riak Search) Installs a precommit hook that automatically indexes objects
- # into riak_search.
- def enable_index!
- unless is_indexed?
- self.props = {"precommit" => (props['precommit'] + [SEARCH_PRECOMMIT_HOOK]), "search" => true}
- end
- end
-
- # (Riak Search) Removes the precommit hook that automatically indexes objects
- # into riak_search.
- def disable_index!
- if is_indexed?
- self.props = {"precommit" => (props['precommit'] - [SEARCH_PRECOMMIT_HOOK]), "search" => false}
- end
- end
-
- # (Riak Search) Detects whether the bucket is automatically indexed into
- # riak_search.
- # @return [true,false] whether the bucket includes the search indexing hook
- def is_indexed?
- props['search'] == true || props['precommit'].include?(SEARCH_PRECOMMIT_HOOK)
- end
-
- # @return [String] a representation suitable for IRB and debugging output
- def inspect
- "#<Riak::Bucket {#{name}}#{" keys=[#{keys.join(',')}]" if defined?(@keys)}>"
- end
-
- # @return [true,false] whether the other is equivalent
- def ==(other)
- Bucket === other && other.client == client && other.name == name
- end
- end
-end
View
84 riak-client/lib/riak/cache_store.rb
@@ -1,84 +0,0 @@
-
-require 'yaml'
-require 'riak/client'
-require 'riak/bucket'
-require 'riak/robject'
-require 'riak/failed_request'
-require 'active_support/version'
-
-if ActiveSupport::VERSION::STRING < "3.0.0"
- raise LoadError, "ActiveSupport 3.0.0 or greater is required to use Riak::CacheStore."
-else
- require 'active_support/cache'
-end
-
-module Riak
- # An ActiveSupport::Cache::Store implementation that uses Riak.
- # Compatible only with ActiveSupport version 3 or greater.
- class CacheStore < ActiveSupport::Cache::Store
- attr_accessor :client
-
- # Creates a Riak-backed cache store.
- def initialize(options = {})
- super
- @bucket_name = options.delete(:bucket) || '_cache'
- @n_value = options.delete(:n_value) || 2
- @r = options.delete(:r) || 1
- @w = options.delete(:w) || 1
- @dw = options.delete(:dw) || 0
- @rw = options.delete(:rw) || "quorum"
- @client = Riak::Client.new(options)
- set_bucket_defaults
- end
-
- def bucket
- @bucket ||= @client.bucket(@bucket_name)
- end
-
- def delete_matched(matcher, options={})
- instrument(:delete_matched, matcher) do
- bucket.keys do |keys|
- keys.grep(matcher).each do |k|
- bucket.delete(k)
- end
- end
- end
- end
-
- protected
- def set_bucket_defaults
- begin
- new_values = {}
- new_values['n_val'] = @n_value unless bucket.n_value == @n_value
- new_values['r'] = @r unless bucket.r == @r
- new_values['w'] = @w unless bucket.w == @w
- new_values['dw'] = @dw unless bucket.dw == @dw
- new_values['rw'] = @rw unless bucket.rw == @rw
- bucket.props = new_values unless new_values.empty?
- rescue
- end
- end
-
- def write_entry(key, value, options={})
- object = bucket.get_or_new(key)
- object.content_type = 'application/yaml'
- object.data = value
- object.store
- end
-
- def read_entry(key, options={})
- begin
- bucket.get(key).data
- rescue Riak::FailedRequest => fr
- raise fr unless fr.not_found?
- nil
- end
- end
-
- def delete_entry(key, options={})
- bucket.delete(key)
- end
- end
-end
-
-ActiveSupport::Cache::RiakStore = Riak::CacheStore unless defined?(ActiveSupport::Cache::RiakStore)
View
539 riak-client/lib/riak/client.rb
@@ -1,539 +0,0 @@
-require 'tempfile'
-require 'delegate'
-require 'riak'
-require 'riak/util/translation'
-require 'riak/util/escape'
-require 'riak/failed_request'
-require 'riak/client/pool'
-require 'riak/client/decaying'
-require 'riak/client/node'
-require 'riak/client/search'
-require 'riak/client/http_backend'
-require 'riak/client/net_http_backend'
-require 'riak/client/excon_backend'
-require 'riak/client/protobuffs_backend'
-require 'riak/client/beefcake_protobuffs_backend'
-require 'riak/bucket'
-require 'riak/stamp'
-
-module Riak
- # A client connection to Riak.
- class Client
- include Util::Translation
- include Util::Escape
-
- # When using integer client IDs, the exclusive upper-bound of valid values.
- MAX_CLIENT_ID = 4294967296
-
- # Array of valid protocols
- PROTOCOLS = %w[http https pbc]
-
- # Regexp for validating hostnames, lifted from uri.rb in Ruby 1.8.6
- HOST_REGEX = /^(?:(?:(?:[a-zA-Z\d](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:[-a-zA-Z\d]*[a-zA-Z\d])?)\.?|\d{1,3}\.\d{1,3}