1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

add a provider module, working toward conistency and discoverability from top down

This commit is contained in:
geemus 2010-09-07 12:21:16 -07:00
parent 6d6eafbb2b
commit e400c50860
4 changed files with 33 additions and 8 deletions

View file

@ -24,6 +24,7 @@ require 'fog/errors'
require 'fog/hmac' require 'fog/hmac'
require 'fog/model' require 'fog/model'
require 'fog/parser' require 'fog/parser'
require 'fog/provider'
require 'fog/service' require 'fog/service'
require 'fog/ssh' require 'fog/ssh'

View file

@ -1,11 +1,14 @@
require 'fog/aws/ec2.rb'
require 'fog/aws/elb.rb'
require 'fog/aws/s3'
require 'fog/aws/simpledb'
module Fog module Fog
module AWS module AWS
extend Fog::Provider
service_path 'fog/aws'
service 'ec2'
service 'elb'
service 's3'
service 'simpledb'
def self.indexed_param(key, values, offset = 0) def self.indexed_param(key, values, offset = 0)
params = {} params = {}
unless key.include?('%d') unless key.include?('%d')

18
lib/fog/provider.rb Normal file
View file

@ -0,0 +1,18 @@
module Fog
module Provider
def service_path(new_path)
@service_path = new_path
end
def service(new_service)
services << new_service
require File.join(@service_path, new_service.to_s)
end
def services
@services ||= []
end
end
end

View file

@ -1,9 +1,12 @@
require 'fog/rackspace/files'
require 'fog/rackspace/servers'
module Fog module Fog
module Rackspace module Rackspace
extend Fog::Provider
service_path 'fog/rackspace'
service 'files'
service 'servers'
def self.authenticate(options) def self.authenticate(options)
rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com" rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com"
connection = Fog::Connection.new("https://" + rackspace_auth_url) connection = Fog::Connection.new("https://" + rackspace_auth_url)