1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/bin.rb
2010-09-08 14:40:57 -07:00

67 lines
1.7 KiB
Ruby

module AWS
class << self
if Fog.credentials[:aws_access_key_id] && Fog.credentials[:aws_secret_access_key]
def initialized?
true
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::AWS::Compute.new
when :ec2
location = caller.first
warning = "[yellow][WARN] AWS[:ec2] is deprecated, use AWS[:compute] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::AWS::Compute.new
when :elb
Fog::AWS::ELB.new
when :simpledb
Fog::AWS::SimpleDB.new
when :s3
location = caller.first
warning = "[yellow][WARN] AWS[:s3] is deprecated, use AWS[:storage] instead[/]"
warning << " [light_black](" << location << ")[/] "
Formatador.display_line(warning)
Fog::AWS::Storage.new
when :storage
Fog::AWS::Storage.new
end
end
@@connections[service]
end
def services
[:compute, :elb, :simpledb, :storage]
end
for collection in Fog::AWS::Compute.collections
module_eval <<-EOS, __FILE__, __LINE__
def #{collection}
self[:compute].#{collection}
end
EOS
end
for collection in Fog::AWS::Storage.collections
module_eval <<-EOS, __FILE__, __LINE__
def #{collection}
self[:storage].#{collection}
end
EOS
end
else
def initialized?
false
end
end
end
end