Sha256: 9f66a62d269a219b5437ef6a24115cb23f66970a5563fee427d88244a740c26b

Contents?: true

Size: 1.67 KB

Versions: 111

Compression:

Stored size: 1.67 KB

Contents

module Fog
  module Parsers
    module Storage
      module Google

        class GetBucket < Fog::Parsers::Base

          def reset
            @object = { 'Owner' => {} }
            @response = { 'Contents' => [], 'CommonPrefixes' => [] }
          end

          def start_element(name, attrs = [])
            super
            case name
            when 'CommonPrefixes'
              @in_common_prefixes = true
            end
          end

          def end_element(name)
            case name
            when 'CommonPrefixes'
              @in_common_prefixes = false
            when 'Contents'
              @response['Contents'] << @object
              @object = { 'Owner' => {} }
            when 'DisplayName', 'ID'
              @object['Owner'][name] = value
            when 'ETag'
              @object[name] = value.gsub('"', '')
            when 'IsTruncated'
              if value == 'true'
                @response['IsTruncated'] = true
              else
                @response['IsTruncated'] = false
              end
            when 'LastModified'
              @object['LastModified'] = Time.parse(value)
            when 'Marker', 'Name'
              @response[name] = value
            when 'MaxKeys'
              @response['MaxKeys'] = value.to_i
            when 'Prefix'
              if @in_common_prefixes
                @response['CommonPrefixes'] << value
              else
                @response[name] = value
              end
            when 'Size'
              @object['Size'] = value.to_i
            when 'Delimiter', 'Key', 'StorageClass'
              @object[name] = value
            end
          end

        end

      end
    end
  end
end

Version data entries

111 entries across 111 versions & 19 rubygems

Version Path
fog-1.10.1 lib/fog/google/parsers/storage/get_bucket.rb
fog-parser-fix-1.6.1 lib/fog/google/parsers/storage/get_bucket.rb
fog-test-again-1.6.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-test-me-1.10.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-parser-fix-1.6.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.10.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.9.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/google/parsers/storage/get_bucket.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/google/parsers/storage/get_bucket.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/google/parsers/storage/get_bucket.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/google/parsers/storage/get_bucket.rb
fog-sgonyea-1.8.1 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.8.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.7.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.6.0 lib/fog/google/parsers/storage/get_bucket.rb
fog-1.5.0 lib/fog/google/parsers/storage/get_bucket.rb
rackspace-fog-1.4.2 lib/rackspace-fog/google/parsers/storage/get_bucket.rb
fog-1.4.0 lib/fog/google/parsers/storage/get_bucket.rb
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/google/parsers/storage/get_bucket.rb