1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/parsers/storage/get_bucket_lifecycle.rb
Josh Lane d48d376e9c initial import
* take the liberty of correcting Aws naming
2014-12-31 09:17:51 -08:00

64 lines
1.7 KiB
Ruby

module Fog
module Parsers
module Storage
module AWS
class GetBucketLifecycle < Fog::Parsers::Base
def reset
@expiration = {}
@transition = {}
@rule = {}
@response = { 'Rules' => [] }
end
def start_element(name, attrs=[])
super
case name
when 'Expiration'
@in_expiration = true
when 'Transition'
@in_transition = true
end
end
def end_element(name)
if @in_expiration
case name
when 'Days'
@expiration[name] = value.to_i
when 'Date'
@expiration[name] = value
when 'Expiration'
@rule['Expiration'] = @expiration
@in_expiration = false
@expiration = {}
end
elsif @in_transition
case name
when 'StorageClass',
@transition['StorageClass'] = value
when 'Date'
@transition[name] = value
when 'Days'
@transition[name] = value.to_i
when 'Transition'
@rule['Transition'] = @transition
@in_transition = false
@transition = {}
end
else
case name
when 'ID', 'Prefix'
@rule[name] = value
when 'Status'
@rule['Enabled'] = value == 'Enabled'
when 'Rule'
@response['Rules'] << @rule
@rule = {}
end
end
end
end
end
end
end
end