Sha256: 6eb4ee0c0cfd5b0234370a083edb7e718c1cde59e81fbbcd220a0d961ffa8376
Contents?: true
Size: 872 Bytes
Versions: 1
Compression:
Stored size: 872 Bytes
Contents
require 'cgi' module Exegesis module Http extend self def format_url url, params={} if params && !params.empty? query = params.map do |key, value| value = value.to_json if [:key, :startkey, :endkey, :keys].include?(key) "#{key}=#{CGI.escape(value.to_s)}" end.join('&') url = "#{url}?#{query}" end url end def escape_id id /^_design\/(.*)/ =~ id ? "_design/#{CGI.escape($1)}" : CGI.escape(id) end def get url JSON.parse(RestClient.get(url), :max_nesting => false) end def post url, body='' JSON.parse(RestClient.post(url, (body || '').to_json)) end def put url, body='' JSON.parse(RestClient.put(url, (body || '').to_json)) end def delete url JSON.parse(RestClient.delete(url)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mattly-exegesis-0.2.0 | lib/exegesis/utils/http.rb |