diff --git a/bin/fog b/bin/fog index 57ab0d66b..2465e3f24 100755 --- a/bin/fog +++ b/bin/fog @@ -24,17 +24,17 @@ else @irb.context.prompt_mode = :FOG @irb.context.workspace = IRB::WorkSpace.new(binding) - services = Fog.services.map{|service| service.to_s} - available_services = if services.length > 1 - services[0...-1].join(', ') << ' and ' << services[-1] + modules = Fog.modules.map{|_module_| _module_.to_s} + modules = if modules.length > 1 + modules[0...-1].join(', ') << ' and ' << modules[-1] else - services.first + modules.first end print "Welcome to fog interactive!\n" - print "Your '#{Fog.credential.to_s}' configuration provides access to #{available_services}.\n" - Fog.services.each do |service| - if service.respond_to?(:startup_notice) - service.send(:startup_notice) + print "Your '#{Fog.credential.to_s}' configuration provides access to #{modules}.\n" + Fog.modules.each do |_module_| + if _module_.respond_to?(:startup_notice) + _module_.send(:startup_notice) end end diff --git a/lib/fog/aws/bin.rb b/lib/fog/aws/bin.rb index 2f1618bf7..ebef49560 100644 --- a/lib/fog/aws/bin.rb +++ b/lib/fog/aws/bin.rb @@ -23,6 +23,10 @@ module AWS @@connections[service] end + def services + [:ec2, :elb, :simpledb, :s3] + end + for collection in Fog::AWS::EC2.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection} diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index a3dae4913..26f5af38e 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -14,54 +14,20 @@ require 'fog/bluebox/bin' module Fog class << self - def services - services = [] - [::AWS, ::GoGrid, ::Linode, ::Local, ::NewServers, ::Rackspace, ::Slicehost, ::Terremark, ::Vcloud, ::Bluebox].each do |service| - if service.initialized? - services << service - end - end - services - end + def modules + [ + ::AWS, + ::GoGrid, + ::Linode, + ::Local, + ::NewServers, + ::Rackspace, + ::Slicehost, + ::Terremark, + ::Vcloud, + ::Bluebox + ].select {|_module_| _module_.initialized?} - def directories - directories = {} - services.each do |service| - if service.respond_to?(:directories) - directories[service] = service.directories - end - end - directories - end - - def flavors - flavors = {} - services.each do |service| - if service.respond_to?(:flavors) - flavors[service] = service.flavors - end - end - flavors - end - - def images - images = {} - services.each do |service| - if service.respond_to?(:images) - images[service] = service.images - end - end - images - end - - def servers - servers = {} - services.each do |service| - if service.respond_to?(:servers) - servers[service] = service.servers - end - end - servers end end diff --git a/lib/fog/bluebox/bin.rb b/lib/fog/bluebox/bin.rb index 13ef0aad5..fb59b122d 100644 --- a/lib/fog/bluebox/bin.rb +++ b/lib/fog/bluebox/bin.rb @@ -17,6 +17,10 @@ module Bluebox @@connections[service] end + def services + [:blocks] + end + for collection in Fog::Bluebox.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection} diff --git a/lib/fog/go_grid/bin.rb b/lib/fog/go_grid/bin.rb index fab561fd2..a0cd68005 100644 --- a/lib/fog/go_grid/bin.rb +++ b/lib/fog/go_grid/bin.rb @@ -16,6 +16,10 @@ module GoGrid @@connections[service] end + def services + [:go_grid] + end + else def initialized? diff --git a/lib/fog/linode/bin.rb b/lib/fog/linode/bin.rb index 7174d6157..506428142 100644 --- a/lib/fog/linode/bin.rb +++ b/lib/fog/linode/bin.rb @@ -16,6 +16,10 @@ module Linode @@connections[service] end + def services + [:linode] + end + else def initialized? diff --git a/lib/fog/local/bin.rb b/lib/fog/local/bin.rb index 69099be81..dca9ee963 100644 --- a/lib/fog/local/bin.rb +++ b/lib/fog/local/bin.rb @@ -16,6 +16,10 @@ module Local @@connections[service] end + def services + [:files] + end + for collection in Fog::Local.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection} diff --git a/lib/fog/new_servers/bin.rb b/lib/fog/new_servers/bin.rb index e51697260..03907c1ca 100644 --- a/lib/fog/new_servers/bin.rb +++ b/lib/fog/new_servers/bin.rb @@ -16,6 +16,10 @@ module NewServers @@connections[service] end + def services + [:new_servers] + end + else def initialized? diff --git a/lib/fog/rackspace/bin.rb b/lib/fog/rackspace/bin.rb index 9ab6aa573..69685a194 100644 --- a/lib/fog/rackspace/bin.rb +++ b/lib/fog/rackspace/bin.rb @@ -18,6 +18,10 @@ module Rackspace @@connections[service] end + def services + [:files, :servers] + end + for collection in Fog::Rackspace::Files.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection} diff --git a/lib/fog/slicehost/bin.rb b/lib/fog/slicehost/bin.rb index eb9c47182..7df93b21d 100644 --- a/lib/fog/slicehost/bin.rb +++ b/lib/fog/slicehost/bin.rb @@ -16,6 +16,10 @@ module Slicehost @@connections[service] end + def services + [:slices] + end + for collection in Fog::Slicehost.collections module_eval <<-EOS, __FILE__, __LINE__ def #{collection}