Created
February 8, 2011 21:29
-
-
Save mgomes/817292 to your computer and use it in GitHub Desktop.
Uses Curl
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
def raw_find(view, key) | |
url = URI::parse(CouchPotato::Config.database_name) | |
if key.is_a?(String) | |
http_client = Curl::Easy.new("#{url}/_design/advocacy_polygon/_view/#{EscapeUtils.escape_url(view)}?key=%22#{EscapeUtils.escape_url(key.to_s)}%22&reduce=false&include_docs=true") | |
elsif key.is_a?(Integer) | |
http_client = Curl::Easy.new("#{url}/_design/advocacy_polygon/_view/#{EscapeUtils.escape_url(view)}?key=#{EscapeUtils.escape_url(key.to_s)}&reduce=false&include_docs=true") | |
elsif key.is_a?(Range) | |
http_client = Curl::Easy.new("#{url}/_design/advocacy_polygon/_view/#{EscapeUtils.escape_url(view)}?startkey=#{EscapeUtils.escape_url(key.begin)}&endkey=#{EscapeUtils.escape_url(key.end)}&reduce=false&include_docs=true") | |
else | |
raise SyntaxError | |
end | |
if url.user.present? | |
http_client.userpwd = [url.user, url.password].join(':') | |
end | |
http_client.perform | |
http_client.body_str | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment