Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/fb/http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Fb
class HTTPRequest
# Initializes a Request object.
# @param [Hash] options the options for the request.
# @option options [Symbol] :method (:get) The HTTP method to use.
# @option options [Class] :expected_response (Net::HTTPSuccess) The class
# of response that the request should obtain when run.
# @option options [String] :host The host of the request URI.
Expand All @@ -26,6 +27,7 @@ class HTTPRequest
# @option options [Proc] :error_message The block that will be invoked
# when a request fails.
def initialize(options = {})
@method = options.fetch :method, :get
@expected_response = options.fetch :expected_response, Net::HTTPSuccess
@host = options.fetch :host, 'graph.facebook.com'
@path = options[:path]
Expand Down Expand Up @@ -63,11 +65,13 @@ def query

# @return [Net::HTTPRequest] the full HTTP request object.
def http_request
@http_request ||= Net::HTTP::Get.new uri.request_uri
net_http_class = Object.const_get "Net::HTTP::#{@method.capitalize}"
@http_request ||= net_http_class.new uri.request_uri
end

def as_curl
'curl'.tap do |curl|
curl << " -X #{http_request.method}"
http_request.each_header{|k, v| curl << %Q{ -H "#{k}: #{v}"}}
curl << %Q{ "#{url}"}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fb/support/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module Fb
module Support
# @return [String] the SemVer-compatible gem version.
# @see http://semver.org
VERSION = '1.0.0.alpha1'
VERSION = '1.0.0.alpha2'
end
end