Sha256: 939b762c25b406411b1a57098ff47cb31aa8c98a48a397b98e42c963026b0679

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Fog
  module Parsers
    module AWS
      module IAM

        class RoleParser < Fog::Parsers::Base

          def reset
            @role = {}
            @stack = []
          end

          def start_element(name,attrs = [])
            case name
            when 'Roles'
              @stack << name
            when 'Role'
              @role = {}
            when 'member'
              if @stack.last == 'Roles'
                @role = {}
              end
            end
            super
          end

          def end_element(name)
            case name
            when 'Arn', 'AssumeRolePolicyDocument', 'Path', 'RoleId','RoleName'
              @role[name] = value if @role
            when 'CreateDate'
              @role[name] = Time.parse(value) if @role
            when 'Role'
              finished_role(@role)
              @role = nil
            when 'Roles'
              if @stack.last == 'Roles'
                @stack.pop
              end
            when 'member'
              if @stack.last == 'Roles'
                finished_role(@role)
                @role = nil
              end
            end
          end

        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-1.22.0 lib/fog/aws/parsers/iam/role_parser.rb
fog-1.21.0 lib/fog/aws/parsers/iam/role_parser.rb