fog--fog/lib/fog/connection.rb

28 lines
501 B
Ruby
Raw Normal View History

2010-03-26 18:15:27 +00:00
module Fog
class Connection
2010-03-26 18:15:27 +00:00
def initialize(url)
@excon = Excon.new(url)
end
def request(params, &block)
unless block_given?
if (parser = params.delete(:parser))
body = Nokogiri::XML::SAX::PushParser.new(parser)
block = lambda { |chunk| body << chunk }
end
end
response = @excon.request(params, &block)
2010-03-26 18:15:27 +00:00
if parser
body.finish
response.body = parser.response
end
2009-08-07 07:28:53 +00:00
2010-03-26 18:15:27 +00:00
response
end
end
end