Sha256: 820bfe486ae34a7607b3a917a0dc3dd199f7649026f80d3e7270848c7ef1b563

Contents?: true

Size: 928 Bytes

Versions: 5

Compression:

Stored size: 928 Bytes

Contents

module Awsum
  class S3
    class BucketParser < Awsum::Parser #:nodoc:
      def initialize(s3)
        @s3 = s3
        @buckets = []
        @text = nil
      end

      def tag_start(tag, attributes)
        case tag
          when 'Bucket'
            @current = {}
            @text = ''
        end
      end

      def text(text)
        @text << text unless @text.nil?
      end

      def tag_end(tag)
        case tag
          when 'Bucket'
            @buckets << Bucket.new(
                          @s3,
                          @current['Name'],
                          Time.parse(@current['CreationDate'])
                        )
            @text = nil
            @current = nil
          else
            text = @text.strip unless @text.nil?
            @current[tag] = (text == '' ? nil : text) unless @current.nil?
        end
      end

      def result
        @buckets
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
awsum-0.5.4 lib/awsum/s3/parsers/bucket_parser.rb
awsum-0.5.3 lib/awsum/s3/parsers/bucket_parser.rb
awsum-0.5.2 lib/awsum/s3/parsers/bucket_parser.rb
awsum-0.5.1 lib/awsum/s3/parsers/bucket_parser.rb
awsum-0.5 lib/awsum/s3/parsers/bucket_parser.rb