Created
January 9, 2010 02:56
-
-
Save joewilliams/272679 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# uses rest_client and carrot, seems to quit when no more data is in the stream | |
require 'rubygems' | |
require "yajl/http_stream" | |
require 'rest_client' | |
require 'carrot' | |
def main | |
url = "http://localhost:5984/" | |
db = "test" | |
feed_type = "continuous" | |
since = "0" | |
q = Carrot.queue("changes") | |
Yajl::HttpStream.get("#{url}#{db}/_changes?feed=#{feed_type}&since=#{since}", :symbolize_keys => true) do |hash| | |
if hash[:id] | |
p hash | |
json = RestClient.get("#{url}#{db}/#{hash[:id]}") | |
p json | |
q.publish(json) | |
end | |
end | |
end | |
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
joe@ubuntu:~$ ruby code/changes_pub_carrot.rb | |
joe@ubuntu:~$ ruby code/changes_pub_carrot.rb | |
{:changes=>[{:rev=>"1-967a00dff5e02add41819138abb3284d"}], :id=>"3883bafcd1b1bf21ba95445137153dea", :seq=>1} | |
"{\"_id\":\"3883bafcd1b1bf21ba95445137153dea\",\"_rev\":\"1-967a00dff5e02add41819138abb3284d\"}\n" | |
joe@ubuntu:~$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment