lib/mudbug.rb in mudbug-1.0.0.1 vs lib/mudbug.rb in mudbug-1.0.1.1

- old
+ new

@@ -81,16 +81,19 @@ @lager.warn { "abandon processing -- unrecognized Content-type: #{ct}" } return resp.body end attr_reader :options - attr_accessor :host + attr_accessor :host, :protocol def initialize(host = 'localhost', options = {}) @host = host + https = options.delete(:https) + @protocol = https ? 'https' : 'http' @options = options accept :json, :html, :text + yield self if block_given? end # Writes the Accept: header for you # e.g. # accept :json, :html # Accept: application/json, text/html @@ -111,13 +114,14 @@ # def resource(path) uri = URI.parse(path) if uri.host # a full URL was passed in @host = uri.host + @protocol = uri.scheme url = uri.to_s else path = "/#{path}" unless path[0,1] == '/' - url = "http://#{@host}#{path}" + url = "#{@protocol}://#{@host}#{path}" end RestClient::Resource.new(url, @options) end # no payload