fog 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 57
4
+ :patch: 58
5
5
  :build:
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.57"
8
+ s.version = "0.0.58"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
@@ -50,6 +50,12 @@ module Fog
50
50
  module EC2
51
51
 
52
52
  def self.new(options={})
53
+ unless options[:aws_access_key_id]
54
+ raise ArgumentError.new('aws_access_key_id is required to access ec2')
55
+ end
56
+ unless options[:aws_secret_access_key]
57
+ raise ArgumentError.new('aws_secret_access_key is required to access ec2')
58
+ end
53
59
  if Fog.mocking?
54
60
  Fog::AWS::EC2::Mock.new(options)
55
61
  else
@@ -57,22 +63,35 @@ module Fog
57
63
  end
58
64
  end
59
65
 
66
+ def self.reset_data(keys=Mock.data.keys)
67
+ Mock.reset_data(keys)
68
+ end
69
+
60
70
  class Mock
61
71
 
62
- def reset_data
63
- @data = {
64
- :deleted_at => {},
65
- :addresses => {},
66
- :instances => {},
67
- :key_pairs => {},
68
- :security_groups => {},
69
- :snapshots => {},
70
- :volumes => {}
71
- }
72
+ def self.data
73
+ @data ||= Hash.new do |hash, key|
74
+ hash[key] = {
75
+ :deleted_at => {},
76
+ :addresses => {},
77
+ :instances => {},
78
+ :key_pairs => {},
79
+ :security_groups => {},
80
+ :snapshots => {},
81
+ :volumes => {}
82
+ }
83
+ end
84
+ end
85
+
86
+ def self.reset_data(keys=data.keys)
87
+ for key in [*keys]
88
+ data.delete(key)
89
+ end
72
90
  end
73
91
 
74
92
  def initialize(options={})
75
- reset_data
93
+ @aws_access_key_id = options[:aws_access_key_id]
94
+ @data = self.class.data[@aws_access_key_id]
76
95
  end
77
96
 
78
97
  end
@@ -98,13 +117,9 @@ module Fog
98
117
  # ==== Returns
99
118
  # * EC2 object with connection to aws.
100
119
  def initialize(options={})
101
- unless @aws_access_key_id = options[:aws_access_key_id]
102
- raise ArgumentError.new('aws_access_key_id is required to access ec2')
103
- end
104
- unless @aws_secret_access_key = options[:aws_secret_access_key]
105
- raise ArgumentError.new('aws_secret_access_key is required to access ec2')
106
- end
107
- @hmac = HMAC::SHA256.new(@aws_secret_access_key)
120
+ @aws_access_key_id = options[:aws_access_key_id]
121
+ @aws_secret_access_key = options[:aws_secret_access_key]
122
+ @hmac = HMAC::SHA256.new(@aws_secret_access_key)
108
123
  @host = options[:host] || case options[:region]
109
124
  when 'eu-west-1'
110
125
  'ec2.eu-west-1.amazonaws.com'
@@ -48,14 +48,29 @@ module Fog
48
48
  metadata
49
49
  end
50
50
 
51
+ def self.reset_data(keys=Mock.data.keys)
52
+ Mock.reset_data(keys)
53
+ end
54
+
51
55
  class Mock
52
56
 
53
- def reset_data
54
- @data = { :buckets => {} }
57
+ def self.data
58
+ @data ||= Hash.new do |hash, key|
59
+ hash[key] = {
60
+ :buckets => {}
61
+ }
62
+ end
63
+ end
64
+
65
+ def self.reset_data(keys=data.keys)
66
+ for key in [*keys]
67
+ data.delete(key)
68
+ end
55
69
  end
56
70
 
57
71
  def initialize(options={})
58
- reset_data
72
+ @aws_access_key_id = options[:aws_access_key_id]
73
+ @data = self.class.data[@aws_access_key_id]
59
74
  end
60
75
 
61
76
  end
@@ -20,14 +20,29 @@ module Fog
20
20
  end
21
21
  end
22
22
 
23
+ def self.reset_data(keys=Mock.data.keys)
24
+ Mock.reset_data(keys)
25
+ end
26
+
23
27
  class Mock
24
28
 
25
- def reset_data
26
- @data = { :domains => {} }
29
+ def self.data
30
+ @data ||= Hash.new do |hash, key|
31
+ hash[key] = {
32
+ :domains => {}
33
+ }
34
+ end
35
+ end
36
+
37
+ def self.reset_data(keys=data.keys)
38
+ for key in [*keys]
39
+ data.delete(key)
40
+ end
27
41
  end
28
42
 
29
43
  def initialize(options={})
30
- reset_data
44
+ @aws_access_key_id = options[:aws_access_key_id]
45
+ @data = self.class.data[@aws_access_key_id]
31
46
  end
32
47
 
33
48
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 57
9
- version: 0.0.57
8
+ - 58
9
+ version: 0.0.58
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)