Permalink
Browse files

Will now work with keys with slashes in them. Requires Ripple > v0.6.1

  • Loading branch information...
1 parent d578e41 commit 8769011047d03f1c09e12566958092a7f78b12f5 @johnthethird committed Mar 18, 2010
Showing with 22 additions and 12 deletions.
  1. +22 −12 briak.rb
View
@@ -37,7 +37,7 @@
erb :index
end
-get '/get/:bucket/:key' do |bucket, key|
+get %r{/get/([^/]+)/(.*)} do |bucket, key|
@bucket = bucket
@keys = client[bucket].keys.sort
@key = key
@@ -46,7 +46,7 @@
erb :index
end
-post '/put/:bucket/:key' do |bucket, key|
+post %r{/put/([^/]+)/(.*)} do |bucket, key|
@bucket = bucket
@keys = client[bucket].keys.sort
@key = key
@@ -105,6 +105,26 @@
redirect "/get/#{bucket}/#{key}"
end
+get '/test1' do
+ (1..100).each do |i|
+ puts "Saving item #{i}"
+ p = Riak::RObject.new(client['test'], "Parent#{i}")
+ p.content_type = "application/javascript"
+ p.data = {:item => 'one', :batch => i / 10}.to_json
+ p.store
+ (1..100).each do |j|
+ c = Riak::RObject.new(client['test'], "Child#{j}")
+ c.content_type = "application/javascript"
+ c.data = {:item => 'one', :batch => j / 10}.to_json
+ c.store
+ p.links << c.to_link("parent")
+ p.store
+ end
+ end
+end
+
+
+
private
def client
@client ||= Riak::Client.new(:host => session[:host], :port => session[:port].to_i)
@@ -148,13 +168,3 @@ def render_data(bucket, key, robject)
end
end
-module Riak
- class Link
- attr_accessor :bucket
- attr_accessor :key
- def initialize(url, rel)
- @url, @rel = url, rel
- @bucket, @key = $1, $2 if @url =~ %r{/riak/([^/]+)/([^/]+)/?}
- end
- end
-end

0 comments on commit 8769011

Please sign in to comment.