Sha256: 204957f0cf4fe0a3f075a44ecc485f186df63a1235dcba1cb05cf0a512ded560

Contents?: true

Size: 1.64 KB

Versions: 33

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module Aws
  module Xml
    class Parser
      class Stack

        def initialize(ref, result = nil, &unhandled_callback)
          @ref = ref
          @frame = self
          @result = result
          @unhandled_callback = unhandled_callback
        end

        attr_reader :frame

        attr_reader :result

        def start_element(name)
          @frame = @frame.child_frame(name.to_s)
        end

        def attr(name, value)
          if name.to_s == 'encoding' && value.to_s == 'base64'
            @frame = BlobFrame.new(name, @frame.parent, @frame.ref)
          else
            # don't try to parse shapes from xml namespace
            return if name.to_s == 'xmlns'
            start_element(name)
            text(value)
            end_element(name)
          end
        end

        def text(value)
          @frame.set_text(value)
        end

        def end_element(*args)
          @frame.parent.consume_child_frame(@frame)
          if @frame.parent.is_a?(FlatListFrame)
            @frame = @frame.parent
            @frame.parent.consume_child_frame(@frame)
          end
          @frame = @frame.parent
        end

        def error(msg, line = nil, column = nil)
          raise ParsingError.new(msg, line, column)
        end

        def child_frame(name)
          Frame.new(name, self, @ref, @result)
        end

        def consume_child_frame(frame)
          @result = frame.result
        end

        # @api private
        def yield_unhandled_value(path, value)
          if @unhandled_callback
            @unhandled_callback.call(path, value)
          end
        end

      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
aws-sdk-core-3.214.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.213.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.212.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.211.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.210.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.209.1 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.209.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.208.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.207.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.206.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.205.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.204.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.203.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.202.2 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.202.1 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.202.0 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.201.5 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.201.4 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.201.3 lib/aws-sdk-core/xml/parser/stack.rb
aws-sdk-core-3.201.2 lib/aws-sdk-core/xml/parser/stack.rb