-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec_helper.rb
More file actions
118 lines (109 loc) · 2.47 KB
/
Copy pathspec_helper.rb
File metadata and controls
118 lines (109 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
require 'spec'
require 'open-uri'
require 'fog'
require 'fog/bin'
require 'fog/vcloud/bin'
if ENV["FOG_MOCK"] == "true"
Fog.mock!
end
module AWS
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k, v|
![:aws_access_key_id, :aws_secret_access_key].include?(k)
end
hash[key] = case key
when :ec2
Fog::AWS::EC2.new(credentials)
when :eu_s3
Fog::AWS::S3.new(credentials.merge!(:host => 's3-external-3.amazonaws.com'))
when :sdb
Fog::AWS::SimpleDB.new(credentials)
when :s3
Fog::AWS::S3.new(credentials)
end
end
@@connections[service]
end
end
end
module Rackspace
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k, v|
![:rackspace_api_key, :rackspace_username].include?(k)
end
hash[key] = case key
when :files
Fog::Rackspace::Files.new(credentials)
when :servers
Fog::Rackspace::Servers.new(credentials)
end
end
@@connections[service]
end
end
end
module Slicehost
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k, v|
![:slicehost_password].include?(k)
end
hash[key] = case key
when :slices
Fog::Slicehost.new(credentials)
end
end
@@connections[service]
end
end
end
module Bluebox
class << self
def [](service)
@@connections ||= Hash.new do |hash, key|
credentials = Fog.credentials.reject do |k,v|
![:bluebox_api_key, :bluebox_customer_id].include?(k)
end
hash[key] = case key
when :blocks
Fog::Bluebox.new(credentials)
end
end
@@connections[service]
end
end
end
def eventually(max_delay = 16, &block)
delays = [0]
delay_step = 1
total = 0
while true
delay = 1
delay_step.times do
delay *= 2
end
delays << delay
delay_step += 1
break if delay >= max_delay
end
delays.each do |delay|
begin
sleep(delay)
yield
break
rescue => error
raise error if delay >= max_delay
end
end
end
unless defined?(GENTOO_AMI)
GENTOO_AMI = 'ami-5ee70037'
end
def lorem_file
File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
end