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

new mocking toggle strategy

This commit is contained in:
Wesley Beary 2009-08-10 08:30:28 -07:00
parent 78e2928cee
commit 2cf9f987b1
5 changed files with 58 additions and 12 deletions

View file

@ -1,7 +1,20 @@
module Fog
def self.mocking=(new_mocking)
old_mocking = @mocking
@mocking = new_mocking
unless old_mocking == new_mocking
self.reload
end
end
def self.mocking?
false
!!@mocking
end
def self.reload
load "#{File.dirname(__FILE__)}/fog/aws.rb"
Fog::AWS.reload
end
end

View file

@ -9,3 +9,17 @@ current_directory = File.dirname(__FILE__)
require "#{current_directory}/aws/ec2"
require "#{current_directory}/aws/simpledb"
require "#{current_directory}/aws/s3"
module Fog
module AWS
def self.reload
current_directory = File.dirname(__FILE__)
load "#{current_directory}/aws/ec2.rb"
load "#{current_directory}/aws/simpledb.rb"
load "#{current_directory}/aws/s3.rb"
Fog::AWS::S3.reload
end
end
end

View file

@ -28,6 +28,34 @@ module Fog
module AWS
class S3
def self.reload
current_directory = File.dirname(__FILE__)
load "#{current_directory}/../connection.rb"
load "#{current_directory}/../parser.rb"
load "#{current_directory}/../response.rb"
parsers_directory = "#{current_directory}/parsers/s3"
load "#{parsers_directory}/copy_object.rb"
load "#{parsers_directory}/get_bucket.rb"
load "#{parsers_directory}/get_bucket_location.rb"
load "#{parsers_directory}/get_request_payment.rb"
load "#{parsers_directory}/get_service.rb"
requests_directory = "#{current_directory}/requests/s3"
load "#{requests_directory}/copy_object.rb"
load "#{requests_directory}/delete_bucket.rb"
load "#{requests_directory}/delete_object.rb"
load "#{requests_directory}/get_bucket.rb"
load "#{requests_directory}/get_bucket_location.rb"
load "#{requests_directory}/get_object.rb"
load "#{requests_directory}/get_request_payment.rb"
load "#{requests_directory}/get_service.rb"
load "#{requests_directory}/head_object.rb"
load "#{requests_directory}/put_bucket.rb"
load "#{requests_directory}/put_object.rb"
load "#{requests_directory}/put_request_payment.rb"
end
if Fog.mocking?
attr_accessor :data
end

View file

@ -1,9 +0,0 @@
module Fog
def self.mocking?
true
end
end
require "#{File.dirname(__FILE__)}/../fog/aws"

View file

@ -1,8 +1,8 @@
require 'spec'
current_directory = File.dirname(__FILE__)
# require "#{current_directory}/../lib/fog"
require "#{current_directory}/../lib/fog/mocking"
require "#{current_directory}/../lib/fog"
# Fog.mocking = true
def credentials
@credentials ||= begin