Sha256: 305be783753866d8e7e025ef2c887e4c4978b5cc6fad52dab5f4ea69977536eb

Contents?: true

Size: 1.5 KB

Versions: 71

Compression:

Stored size: 1.5 KB

Contents

module Fog
  module Parsers
    module AWS
      module IAM
        class PolicyParser < Fog::Parsers::Base
          def reset
            @policy = fresh_policy
            @stack = []
          end

          def start_element(name,attrs = [])
            case name
            when 'Policies'
              @stack << name
            when 'Policy'
              @policy = fresh_policy
            when 'member'
              if @stack.last == 'Policies'
                @policy = fresh_policy
              end
            end
            super
          end

          def fresh_policy
            {'AttachmentCount' => 0, 'Description' => ''}
          end

          def end_element(name)
            case name
            when 'Arn', 'DefaultVersionId', 'Description', 'Path', 'PolicyName', 'PolicyId'
              @policy[name] = value
            when 'CreateDate', 'UpdateDate'
              @policy[name] = Time.parse(value)
            when 'IsAttachable'
              @policy[name] = (value == 'true')
            when 'AttachmentCount'
              @policy[name] = value.to_i
            when 'Policy'
              finished_policy(@policy)
              @policy = nil
            when 'Policies'
              if @stack.last == 'Policies'
                @stack.pop
              end
            when 'member'
              if @stack.last == 'Policies'
                finished_policy(@policy)
                @policy = nil
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

71 entries across 69 versions & 3 rubygems

Version Path
fog-aws-3.29.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.28.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.27.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.26.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.25.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.24.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.23.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.22.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.21.1 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.21.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.20.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.19.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.18.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.17.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.16.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.15.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.14.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.13.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.12.0 lib/fog/aws/parsers/iam/policy_parser.rb
fog-aws-3.11.0 lib/fog/aws/parsers/iam/policy_parser.rb