From 3e5422fc1c503777140fbd609582da5c48e09086 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Lopes Ribeiro Date: Sat, 18 Oct 2014 23:09:53 -0300 Subject: [PATCH] Using `fog-xml` --- fog.gemspec | 1 + lib/fog/xml.rb | 4 --- lib/fog/xml/connection.rb | 24 --------------- lib/fog/xml/sax_parser_connection.rb | 45 ---------------------------- 4 files changed, 1 insertion(+), 73 deletions(-) delete mode 100644 lib/fog/xml.rb delete mode 100644 lib/fog/xml/connection.rb delete mode 100644 lib/fog/xml/sax_parser_connection.rb diff --git a/fog.gemspec b/fog.gemspec index cd0421f57..25907219f 100644 --- a/fog.gemspec +++ b/fog.gemspec @@ -48,6 +48,7 @@ Gem::Specification.new do |s| ## that are needed for an end user to actually USE your code. s.add_dependency("fog-core", "~> 1.24") s.add_dependency("fog-json") + s.add_dependency("fog-xml") s.add_dependency('nokogiri', '~> 1.5', '>= 1.5.11') s.add_dependency('ipaddress', '~>0.5') diff --git a/lib/fog/xml.rb b/lib/fog/xml.rb deleted file mode 100644 index 2fea6aaa6..000000000 --- a/lib/fog/xml.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "nokogiri" -require "fog/core/parser" -require "fog/xml/sax_parser_connection" -require "fog/xml/connection" diff --git a/lib/fog/xml/connection.rb b/lib/fog/xml/connection.rb deleted file mode 100644 index 32fd7d98d..000000000 --- a/lib/fog/xml/connection.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Fog - # @note Extracting XML components out of core is a work in progress. - # - # The {XML} module includes functionality that is common between APIs using - # XML to send and receive data. - # - # The intent is to provide common code for provider APIs using XML but not - # require it for those using JSON. - # - # @todo Add +require "fog/xml"+ and/or +include Fog::XML+ to providers using - # its services - # - module XML - class Connection < Fog::XML::SAXParserConnection - def request(params, &block) - if (parser = params.delete(:parser)) - super(parser, params) - else - original_request(params) - end - end - end - end -end diff --git a/lib/fog/xml/sax_parser_connection.rb b/lib/fog/xml/sax_parser_connection.rb deleted file mode 100644 index f80f98f5c..000000000 --- a/lib/fog/xml/sax_parser_connection.rb +++ /dev/null @@ -1,45 +0,0 @@ -module Fog - module XML - class SAXParserConnection < Fog::Core::Connection - # Makes a request using the connection using Excon - # - # @param [Hash] params - # @option params [String] :body text to be sent over a socket - # @option params [Hash] :headers The default headers to supply in a request - # @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String - # @option params [String] :path appears after 'scheme://host:port/' - # @option params [Fixnum] :port The port on which to connect, to the destination host - # @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value' - # @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used - # @option params [Proc] :response_block - # @option params [Nokogiri::XML::SAX::Document] :parser - # - # @return [Excon::Response] - # - # @raise [Excon::Errors::StubNotFound] - # @raise [Excon::Errors::Timeout] - # @raise [Excon::Errors::SocketError] - # - def request(parser, params) - reset unless @persistent - - # Prepare the SAX parser - data_stream = Nokogiri::XML::SAX::PushParser.new(parser) - response_string = "" - params[:response_block] = lambda do |chunk, remaining, total| - response_string << chunk if ENV['DEBUG_RESPONSE'] - data_stream << chunk - end - - # Make request which read chunks into parser - response = @excon.request(params) - Fog::Logger.debug "\n#{response_string}" if ENV['DEBUG_RESPONSE'] - - # Cease parsing and override response.body with parsed data - data_stream.finish - response.body = parser.response - response - end - end - end -end