From eb550831652eecca4c6736faa3905414ed1e4306 Mon Sep 17 00:00:00 2001 From: geemus Date: Mon, 11 Jul 2011 17:12:15 -0500 Subject: [PATCH] [storage|rackspace] cleanup formatting/style --- lib/fog/cdn/rackspace.rb | 16 ++++++++-------- lib/fog/storage/models/rackspace/directory.rb | 16 ++++++---------- lib/fog/storage/rackspace.rb | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/fog/cdn/rackspace.rb b/lib/fog/cdn/rackspace.rb index 40ee4fe5c..1d6197422 100644 --- a/lib/fog/cdn/rackspace.rb +++ b/lib/fog/cdn/rackspace.rb @@ -48,18 +48,18 @@ module Fog @enabled = false if credentials['X-CDN-Management-Url'] - uri = URI.parse(credentials['X-CDN-Management-Url']) - @host = uri.host - @path = uri.path - @port = uri.port - @scheme = uri.scheme - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) - @enabled = true + uri = URI.parse(credentials['X-CDN-Management-Url']) + @host = uri.host + @path = uri.path + @port = uri.port + @scheme = uri.scheme + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + @enabled = true end end def enabled? - @enabled + @enabled end def reload diff --git a/lib/fog/storage/models/rackspace/directory.rb b/lib/fog/storage/models/rackspace/directory.rb index ea3e44f13..df0dd3468 100644 --- a/lib/fog/storage/models/rackspace/directory.rb +++ b/lib/fog/storage/models/rackspace/directory.rb @@ -56,19 +56,15 @@ module Fog requires :key connection.put_container(key) - # if user set cont as public but wed don't have a CDN connnection - # then error out. - if @public and !@connection.cdn - raise(Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided")) - # if we set as public then set it and we sure we have connection.cdn - # or it would have error out. - elsif @public + if @connection.cdn && @public + # if public and CDN connection then update cdn to public @public_url = connection.cdn.put_container(key, 'X-CDN-Enabled' => 'True').headers['X-CDN-URI'] - # if we have cdn connectio but cont has not been public then let the - # CDN knows about it - elsif @connection.cdn + elsif @connection.cdn && !@public connection.cdn.put_container(key, 'X-CDN-Enabled' => 'False') @public_url = nil + elsif !@connection.cdn && @public + # if public but no CDN connection then error + raise(Fog::Storage::Rackspace::Error.new("Directory can not be set as :public without a CDN provided")) end true end diff --git a/lib/fog/storage/rackspace.rb b/lib/fog/storage/rackspace.rb index a7be00114..49203b6b5 100644 --- a/lib/fog/storage/rackspace.rb +++ b/lib/fog/storage/rackspace.rb @@ -30,11 +30,11 @@ module Fog @cdn ||= Fog::CDN.new( :provider => 'Rackspace', :rackspace_api_key => @rackspace_api_key, - :rackspace_auth_url => @rackspace_auth_url, + :rackspace_auth_url => @rackspace_auth_url, :rackspace_username => @rackspace_username ) if @cdn.enabled? - return @cdn + @cdn end end