2010-09-18 13:40:48 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
module Google
|
2010-09-18 13:40:48 -04:00
|
|
|
|
|
|
|
class GetBucket < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@object = { 'Owner' => {} }
|
2010-11-19 17:09:06 -05:00
|
|
|
@response = { 'Contents' => [], 'CommonPrefixes' => [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
super
|
|
|
|
case name
|
|
|
|
when 'CommonPrefixes'
|
|
|
|
@in_common_prefixes = true
|
|
|
|
end
|
2010-09-18 13:40:48 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
2010-11-19 17:09:06 -05:00
|
|
|
when 'CommonPrefixes'
|
|
|
|
@in_common_prefixes = false
|
2010-09-18 13:40:48 -04:00
|
|
|
when 'Contents'
|
|
|
|
@response['Contents'] << @object
|
|
|
|
@object = { 'Owner' => {} }
|
|
|
|
when 'DisplayName', 'ID'
|
2011-05-12 16:15:13 -04:00
|
|
|
@object['Owner'][name] = value
|
2010-09-18 13:40:48 -04:00
|
|
|
when 'ETag'
|
2011-05-12 16:15:13 -04:00
|
|
|
@object[name] = value.gsub('"', '')
|
2010-09-18 13:40:48 -04:00
|
|
|
when 'IsTruncated'
|
2011-05-12 16:15:13 -04:00
|
|
|
if value == 'true'
|
2010-09-18 13:40:48 -04:00
|
|
|
@response['IsTruncated'] = true
|
|
|
|
else
|
|
|
|
@response['IsTruncated'] = false
|
|
|
|
end
|
|
|
|
when 'LastModified'
|
2011-05-12 16:15:13 -04:00
|
|
|
@object['LastModified'] = Time.parse(value)
|
2010-11-19 17:09:06 -05:00
|
|
|
when 'Marker', 'Name'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-09-18 13:40:48 -04:00
|
|
|
when 'MaxKeys'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['MaxKeys'] = value.to_i
|
2010-11-19 17:09:06 -05:00
|
|
|
when 'Prefix'
|
|
|
|
if @in_common_prefixes
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['CommonPrefixes'] << value
|
2010-11-19 17:09:06 -05:00
|
|
|
else
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-11-19 17:09:06 -05:00
|
|
|
end
|
2010-09-18 13:40:48 -04:00
|
|
|
when 'Size'
|
2011-05-12 16:15:13 -04:00
|
|
|
@object['Size'] = value.to_i
|
2010-11-19 17:16:03 -05:00
|
|
|
when 'Delimiter', 'Key', 'StorageClass'
|
2011-05-12 16:15:13 -04:00
|
|
|
@object[name] = value
|
2010-09-18 13:40:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|