fog 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://gemcutter.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'excon', '>= 0.0.25'
4
+ gem 'excon', '>= 0.0.26'
5
5
  gem 'formatador', ">= 0.0.10"
6
6
  gem 'json', ">= 0"
7
7
  gem 'mime-types', ">= 0"
data/Gemfile.lock CHANGED
@@ -31,7 +31,7 @@ dependencies:
31
31
  excon:
32
32
  group:
33
33
  - :default
34
- version: ">= 0.0.25"
34
+ version: ">= 0.0.26"
35
35
  builder:
36
36
  group:
37
37
  - :default
@@ -50,7 +50,7 @@ specs:
50
50
  - builder:
51
51
  version: 2.1.2
52
52
  - excon:
53
- version: 0.0.25
53
+ version: 0.0.26
54
54
  - formatador:
55
55
  version: 0.0.14
56
56
  - gestalt:
@@ -69,7 +69,7 @@ specs:
69
69
  version: 0.4.0
70
70
  - shindo:
71
71
  version: 0.1.4
72
- hash: 47be4240cdce9d626cc1834c503ca8e275e76307
72
+ hash: da3f548f91388bc9e002c42ee2a4488bc8db9991
73
73
  sources:
74
74
  - Rubygems:
75
75
  uri: http://gemcutter.org
data/fog.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.1.7'
10
+ s.version = '0.1.8'
11
11
  s.date = '2010-06-07'
12
12
  s.rubyforge_project = 'fog'
13
13
 
data/lib/fog.rb CHANGED
@@ -49,7 +49,7 @@ require 'fog/vcloud'
49
49
  module Fog
50
50
 
51
51
  unless const_defined?(:VERSION)
52
- VERSION = '0.1.7'
52
+ VERSION = '0.1.8'
53
53
  end
54
54
 
55
55
  module Mock
@@ -1,96 +1,98 @@
1
- module Attributes
2
- module ClassMethods
1
+ module Fog
2
+ module Attributes
3
+ module ClassMethods
3
4
 
4
- def _load(marshalled)
5
- new(Marshal.load(marshalled))
6
- end
5
+ def _load(marshalled)
6
+ new(Marshal.load(marshalled))
7
+ end
7
8
 
8
- def aliases
9
- @aliases ||= {}
10
- end
9
+ def aliases
10
+ @aliases ||= {}
11
+ end
11
12
 
12
- def attributes
13
- @attributes ||= []
14
- end
13
+ def attributes
14
+ @attributes ||= []
15
+ end
16
+
17
+ def attribute(name, other_names = [])
18
+ class_eval <<-EOS, __FILE__, __LINE__
19
+ attr_accessor :#{name}
20
+ EOS
21
+ @attributes ||= []
22
+ @attributes |= [name]
23
+ for other_name in [*other_names]
24
+ aliases[other_name] = name
25
+ end
26
+ end
15
27
 
16
- def attribute(name, other_names = [])
17
- class_eval <<-EOS, __FILE__, __LINE__
18
- attr_accessor :#{name}
19
- EOS
20
- @attributes ||= []
21
- @attributes |= [name]
22
- for other_name in [*other_names]
23
- aliases[other_name] = name
28
+ def identity(name, other_names = [])
29
+ @identity = name
30
+ self.attribute(name, other_names)
24
31
  end
25
- end
26
32
 
27
- def identity(name, other_names = [])
28
- @identity = name
29
- self.attribute(name, other_names)
30
33
  end
31
34
 
32
- end
35
+ module InstanceMethods
33
36
 
34
- module InstanceMethods
35
-
36
- def _dump
37
- Marshal.dump(attributes)
38
- end
37
+ def _dump
38
+ Marshal.dump(attributes)
39
+ end
39
40
 
40
- def attributes
41
- attributes = {}
42
- for attribute in self.class.attributes
43
- attributes[attribute] = send("#{attribute}")
41
+ def attributes
42
+ attributes = {}
43
+ for attribute in self.class.attributes
44
+ attributes[attribute] = send("#{attribute}")
45
+ end
46
+ attributes
44
47
  end
45
- attributes
46
- end
47
48
 
48
- def identity
49
- send(self.class.instance_variable_get('@identity'))
50
- end
49
+ def identity
50
+ send(self.class.instance_variable_get('@identity'))
51
+ end
51
52
 
52
- def identity=(new_identity)
53
- send("#{self.class.instance_variable_get('@identity')}=", new_identity)
54
- end
53
+ def identity=(new_identity)
54
+ send("#{self.class.instance_variable_get('@identity')}=", new_identity)
55
+ end
55
56
 
56
- def merge_attributes(new_attributes = {})
57
- for key, value in new_attributes
58
- if aliased_key = self.class.aliases[key]
59
- send("#{aliased_key}=", value)
60
- else
61
- send("#{key}=", value)
57
+ def merge_attributes(new_attributes = {})
58
+ for key, value in new_attributes
59
+ if aliased_key = self.class.aliases[key]
60
+ send("#{aliased_key}=", value)
61
+ else
62
+ send("#{key}=", value)
63
+ end
62
64
  end
65
+ self
63
66
  end
64
- self
65
- end
66
67
 
67
- def new_record?
68
- !identity
69
- end
70
-
71
- def requires(*args)
72
- missing = []
73
- for arg in [:connection] | args
74
- missing << arg unless send("#{arg}")
68
+ def new_record?
69
+ !identity
75
70
  end
76
- unless missing.empty?
77
- if missing.length == 1
78
- raise(ArgumentError, "#{missing.first} is required for this operation")
79
- else
80
- raise(ArgumentError, "#{missing[0...-1].join(", ")} and #{missing[-1]} are required for this operation")
71
+
72
+ def requires(*args)
73
+ missing = []
74
+ for arg in [:connection] | args
75
+ missing << arg unless send("#{arg}")
76
+ end
77
+ unless missing.empty?
78
+ if missing.length == 1
79
+ raise(ArgumentError, "#{missing.first} is required for this operation")
80
+ else
81
+ raise(ArgumentError, "#{missing[0...-1].join(", ")} and #{missing[-1]} are required for this operation")
82
+ end
81
83
  end
82
84
  end
83
- end
84
85
 
85
- private
86
+ private
86
87
 
87
- def remap_attributes(attributes, mapping)
88
- for key, value in mapping
89
- if attributes.key?(key)
90
- attributes[value] = attributes.delete(key)
88
+ def remap_attributes(attributes, mapping)
89
+ for key, value in mapping
90
+ if attributes.key?(key)
91
+ attributes[value] = attributes.delete(key)
92
+ end
91
93
  end
92
94
  end
93
- end
94
95
 
96
+ end
95
97
  end
96
- end
98
+ end
@@ -51,7 +51,7 @@ module Fog
51
51
  end
52
52
 
53
53
  def save
54
- requires :flavor_id, :image_id, :name
54
+ requires :flavor_id, :image_id
55
55
  options = if !@password && !@ssh_key
56
56
  raise(ArgumentError, "password or ssh_key is required for this operation")
57
57
  elsif @ssh_key
@@ -22,7 +22,7 @@ module Fog
22
22
  :expects => 200,
23
23
  :method => 'POST',
24
24
  :path => '/api/blocks.json',
25
- :query => {'product' => product_id, 'template' => templated_id}.merge!(query)
25
+ :query => {'product' => product_id, 'template' => template_id}.merge!(options)
26
26
  )
27
27
  end
28
28
 
@@ -1,13 +1,15 @@
1
1
  module Fog
2
2
  class Collection < Array
3
3
 
4
- extend Attributes::ClassMethods
5
- include Attributes::InstanceMethods
4
+ extend Fog::Attributes::ClassMethods
5
+ include Fog::Attributes::InstanceMethods
6
6
 
7
7
  Array.public_instance_methods(false).each do |method|
8
8
  class_eval <<-RUBY
9
9
  def #{method}(*args)
10
- lazy_load
10
+ unless @loaded
11
+ lazy_load
12
+ end
11
13
  super
12
14
  end
13
15
  RUBY
@@ -16,9 +18,11 @@ module Fog
16
18
  %w[reject select].each do |method|
17
19
  class_eval <<-RUBY
18
20
  def #{method}(*args)
19
- lazy_load
21
+ unless @loaded
22
+ lazy_load
23
+ end
20
24
  data = super
21
- self.class.new(:connection => self.connection).load(data.map {|member| member.attributes})
25
+ result = self.clone.clear.concat(data)
22
26
  end
23
27
  RUBY
24
28
  end
@@ -33,6 +37,11 @@ module Fog
33
37
 
34
38
  attr_accessor :connection
35
39
 
40
+ def clear
41
+ @loaded = true
42
+ super
43
+ end
44
+
36
45
  def create(attributes = {})
37
46
  object = new(attributes)
38
47
  object.save
@@ -41,7 +50,6 @@ module Fog
41
50
 
42
51
  def initialize(attributes = {})
43
52
  merge_attributes(attributes)
44
- @loaded = false
45
53
  end
46
54
 
47
55
  def inspect
@@ -69,10 +77,7 @@ module Fog
69
77
  end
70
78
 
71
79
  def load(objects)
72
- if @loaded
73
- clear
74
- end
75
- @loaded = true
80
+ clear
76
81
  for object in objects
77
82
  self << new(object)
78
83
  end
@@ -93,7 +98,9 @@ module Fog
93
98
  end
94
99
 
95
100
  def reload
96
- self.clear.concat(all)
101
+ clear
102
+ lazy_load
103
+ self
97
104
  end
98
105
 
99
106
  def table(attributes = nil)
@@ -107,9 +114,7 @@ module Fog
107
114
  private
108
115
 
109
116
  def lazy_load
110
- unless @loaded
111
- self.all
112
- end
117
+ self.all
113
118
  end
114
119
 
115
120
  end
data/lib/fog/model.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Fog
2
2
  class Model
3
3
 
4
- extend Attributes::ClassMethods
5
- include Attributes::InstanceMethods
4
+ extend Fog::Attributes::ClassMethods
5
+ include Fog::Attributes::InstanceMethods
6
6
 
7
7
  attr_accessor :connection
8
8
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)