lib/exegesis/utils/http.rb in mattly-exegesis-0.2.0 vs lib/exegesis/utils/http.rb in mattly-exegesis-0.2.1

- old
+ new

@@ -13,26 +13,32 @@ end url end def escape_id id - /^_design\/(.*)/ =~ id ? "_design/#{CGI.escape($1)}" : CGI.escape(id) + if %r{^_design/(.*)/_view/(.*)} =~ id + "_design/#{CGI.escape($1)}/_view/#{CGI.escape($2)}" + elsif /^_design\/(.*)/ =~ id + "_design/#{CGI.escape($1)}" + else + CGI.escape(id) + end end - def get url - JSON.parse(RestClient.get(url), :max_nesting => false) + def get url, headers={} + JSON.parse(RestClient.get(url, headers), :max_nesting => false) end - def post url, body='' - JSON.parse(RestClient.post(url, (body || '').to_json)) + def post url, body='', headers={} + JSON.parse(RestClient.post(url, body, headers)) end - def put url, body='' - JSON.parse(RestClient.put(url, (body || '').to_json)) + def put url, body='', headers={} + JSON.parse(RestClient.put(url, body, headers)) end - def delete url - JSON.parse(RestClient.delete(url)) + def delete url, headers={} + JSON.parse(RestClient.delete(url, headers)) end end end \ No newline at end of file