File: response.rb

package info (click to toggle)
ruby-fog-xml 0.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 204 kB
  • sloc: ruby: 371; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Fog
  module XML
    class Response
      def initialize(parser)
        @parser = parser
        @data_stream = Nokogiri::XML::SAX::PushParser.new(parser)
        @response_string = +''
      end

      def call(chunk, _remaining, _total)
        @response_string << chunk if ENV["DEBUG_RESPONSE"]
        @data_stream << chunk
      end

      def rewind
        @parser.reset
        @response_string = +''
      end

      def finish
        Fog::Logger.debug "\n#{@response_string}" if ENV["DEBUG_RESPONSE"]
        @data_stream.finish
      end
    end
  end
end