fog 0.0.38 → 0.0.39

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/Rakefile CHANGED
@@ -7,7 +7,7 @@ require "#{current_directory}/lib/fog"
7
7
  begin
8
8
  require 'jeweler'
9
9
  Jeweler::Tasks.new do |gem|
10
- gem.add_dependency('excon', '>=0.0.13')
10
+ gem.add_dependency('excon', '>=0.0.14')
11
11
  gem.add_dependency('mime-types')
12
12
  gem.add_dependency('nokogiri')
13
13
  gem.add_dependency('ruby-hmac')
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.38
1
+ 0.0.39
data/fog.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.38"
8
+ s.version = "0.0.39"
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)"]
12
- s.date = %q{2009-12-24}
12
+ s.date = %q{2010-01-04}
13
13
  s.default_executable = %q{fog}
14
14
  s.description = %q{brings clouds to you}
15
15
  s.email = %q{me@geemus.com}
@@ -194,7 +194,6 @@ Gem::Specification.new do |s|
194
194
  "spec/aws/models/s3/buckets_spec.rb",
195
195
  "spec/aws/models/s3/object_spec.rb",
196
196
  "spec/aws/models/s3/objects_spec.rb",
197
- "spec/aws/models/s3/owner_spec.rb",
198
197
  "spec/aws/requests/ec2/allocate_address_spec.rb",
199
198
  "spec/aws/requests/ec2/associate_address_spec.rb",
200
199
  "spec/aws/requests/ec2/attach_volume_spec.rb",
@@ -303,7 +302,6 @@ Gem::Specification.new do |s|
303
302
  "spec/aws/models/s3/buckets_spec.rb",
304
303
  "spec/aws/models/s3/object_spec.rb",
305
304
  "spec/aws/models/s3/objects_spec.rb",
306
- "spec/aws/models/s3/owner_spec.rb",
307
305
  "spec/aws/requests/ec2/allocate_address_spec.rb",
308
306
  "spec/aws/requests/ec2/associate_address_spec.rb",
309
307
  "spec/aws/requests/ec2/attach_volume_spec.rb",
@@ -393,18 +391,18 @@ Gem::Specification.new do |s|
393
391
  s.specification_version = 3
394
392
 
395
393
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
396
- s.add_runtime_dependency(%q<excon>, [">= 0.0.13"])
394
+ s.add_runtime_dependency(%q<excon>, [">= 0.0.14"])
397
395
  s.add_runtime_dependency(%q<mime-types>, [">= 0"])
398
396
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
399
397
  s.add_runtime_dependency(%q<ruby-hmac>, [">= 0"])
400
398
  else
401
- s.add_dependency(%q<excon>, [">= 0.0.13"])
399
+ s.add_dependency(%q<excon>, [">= 0.0.14"])
402
400
  s.add_dependency(%q<mime-types>, [">= 0"])
403
401
  s.add_dependency(%q<nokogiri>, [">= 0"])
404
402
  s.add_dependency(%q<ruby-hmac>, [">= 0"])
405
403
  end
406
404
  else
407
- s.add_dependency(%q<excon>, [">= 0.0.13"])
405
+ s.add_dependency(%q<excon>, [">= 0.0.14"])
408
406
  s.add_dependency(%q<mime-types>, [">= 0"])
409
407
  s.add_dependency(%q<nokogiri>, [">= 0"])
410
408
  s.add_dependency(%q<ruby-hmac>, [">= 0"])
@@ -21,18 +21,20 @@ module Fog
21
21
  end
22
22
 
23
23
  def all(public_ip = @public_ip)
24
+ @public_ip = public_ip
25
+ if @loaded
26
+ clear
27
+ end
28
+ @loaded = true
24
29
  data = connection.describe_addresses(public_ip).body
25
- addresses = Fog::AWS::EC2::Addresses.new({
26
- :connection => connection,
27
- :public_ip => public_ip
28
- }.merge!(attributes))
30
+ addresses = []
29
31
  data['addressesSet'].each do |address|
30
32
  addresses << new(address.reject {|key, value| value.nil? || value.empty? })
31
33
  end
32
34
  if instance
33
35
  addresses = addresses.select {|address| address.instance_id == instance.id}
34
36
  end
35
- addresses
37
+ self.replace(addresses)
36
38
  end
37
39
 
38
40
  def get(public_ip)
@@ -18,20 +18,18 @@ module Fog
18
18
  end
19
19
 
20
20
  def all(instance_id = @instance_id)
21
+ @instance_id = instance_id
22
+ if @loaded
23
+ clear
24
+ end
25
+ @loaded = true
21
26
  data = connection.describe_instances(instance_id).body
22
- instances = Fog::AWS::EC2::Instances.new({
23
- :connection => connection,
24
- :instance_id => instance_id
25
- }.merge!(attributes))
26
27
  data['reservationSet'].each do |reservation|
27
28
  reservation['instancesSet'].each do |instance|
28
- instances << Fog::AWS::EC2::Instance.new({
29
- :collection => instances,
30
- :connection => connection
31
- }.merge!(instance))
29
+ self << new(instance)
32
30
  end
33
31
  end
34
- instances
32
+ self
35
33
  end
36
34
 
37
35
  def get(instance_id)
@@ -18,18 +18,16 @@ module Fog
18
18
  end
19
19
 
20
20
  def all(key_name = @key_name)
21
+ @key_name = key_name
22
+ if @loaded
23
+ clear
24
+ end
25
+ @loaded = true
21
26
  data = connection.describe_key_pairs(key_name).body
22
- key_pairs = Fog::AWS::EC2::KeyPairs.new({
23
- :connection => connection,
24
- :key_name => key_name
25
- }.merge!(attributes))
26
27
  data['keySet'].each do |key|
27
- key_pairs << Fog::AWS::EC2::KeyPair.new({
28
- :collection => key_pairs,
29
- :connection => connection
30
- }.merge!(key))
28
+ self << new(key)
31
29
  end
32
- key_pairs
30
+ self
33
31
  end
34
32
 
35
33
  def get(key_name)
@@ -18,18 +18,16 @@ module Fog
18
18
  end
19
19
 
20
20
  def all(group_name = @group_name)
21
+ @group_name = group_name
22
+ if @loaded
23
+ clear
24
+ end
25
+ @loaded = true
21
26
  data = connection.describe_security_groups(group_name).body
22
- security_groups = Fog::AWS::EC2::SecurityGroups.new({
23
- :connection => connection,
24
- :group_name => group_name
25
- }.merge!(attributes))
26
27
  data['securityGroupInfo'].each do |security_group|
27
- security_groups << Fog::AWS::EC2::SecurityGroup.new({
28
- :collection => security_groups,
29
- :connection => connection
30
- }.merge!(security_group))
28
+ self << new(security_group)
31
29
  end
32
- security_groups
30
+ self
33
31
  end
34
32
 
35
33
  def get(group_name)
@@ -21,21 +21,20 @@ module Fog
21
21
  end
22
22
 
23
23
  def all(snapshot_id = @snapshot_id)
24
+ @snapshot_id = snapshot_id
25
+ if @loaded
26
+ clear
27
+ end
28
+ @loaded = true
24
29
  data = connection.describe_snapshots(snapshot_id).body
25
- snapshots = Fog::AWS::EC2::Snapshots.new({
26
- :connection => connection,
27
- :snapshot_id => snapshot_id
28
- }.merge!(attributes))
30
+ snapshots = []
29
31
  data['snapshotSet'].each do |snapshot|
30
- snapshots << Fog::AWS::EC2::Snapshot.new({
31
- :collection => snapshots,
32
- :connection => connection
33
- }.merge!(snapshot))
32
+ snapshots << new(snapshot)
34
33
  end
35
34
  if volume
36
35
  snapshots = snapshots.select {|snapshot| snapshot.volume_id == volume.id}
37
36
  end
38
- snapshots
37
+ self.replace(snapshots)
39
38
  end
40
39
 
41
40
  def get(snapshot_id)
@@ -21,21 +21,20 @@ module Fog
21
21
  end
22
22
 
23
23
  def all(volume_id = @volume_id)
24
+ @volume_id = volume_id
25
+ if @loaded
26
+ clear
27
+ end
28
+ @loaded = true
24
29
  data = connection.describe_volumes(volume_id).body
25
- volumes = Fog::AWS::EC2::Volumes.new({
26
- :connection => connection,
27
- :volume_id => volume_id
28
- }.merge!(attributes))
30
+ volumes = []
29
31
  data['volumeSet'].each do |volume|
30
- volumes << Fog::AWS::EC2::Volume.new({
31
- :collection => volumes,
32
- :connection => connection
33
- }.merge!(volume))
32
+ volumes << new(volume)
34
33
  end
35
34
  if instance
36
35
  volumes = volumes.select {|volume| volume.instance_id == instance.id}
37
36
  end
38
- volumes
37
+ self.replace(volumes)
39
38
  end
40
39
 
41
40
  def get(volume_id)
@@ -11,15 +11,15 @@ module Fog
11
11
  model Fog::AWS::S3::Bucket
12
12
 
13
13
  def all
14
+ if @loaded
15
+ clear
16
+ end
17
+ @loaded = true
14
18
  data = connection.get_service.body
15
- buckets = Fog::AWS::S3::Buckets.new(:connection => connection)
16
19
  data['Buckets'].each do |bucket|
17
- buckets << Fog::AWS::S3::Bucket.new({
18
- :collection => buckets,
19
- :connection => connection
20
- }.merge!(bucket))
20
+ self << new(bucket)
21
21
  end
22
- buckets
22
+ self
23
23
  end
24
24
 
25
25
  def get(name, options = {})
@@ -27,11 +27,7 @@ module Fog
27
27
  :max_keys => 'max-keys',
28
28
  })
29
29
  data = connection.get_bucket(name, options).body
30
- bucket = Fog::AWS::S3::Bucket.new({
31
- :collection => self,
32
- :connection => connection,
33
- :name => data['Name']
34
- })
30
+ bucket = new(:name => data['Name'])
35
31
  options = {}
36
32
  for key, value in data
37
33
  if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
@@ -39,12 +35,9 @@ module Fog
39
35
  end
40
36
  end
41
37
  bucket.objects.merge_attributes(options)
38
+ bucket.objects.instance_variable_set(:@loaded, true)
42
39
  data['Contents'].each do |object|
43
- bucket.objects << Fog::AWS::S3::Object.new({
44
- :bucket => bucket,
45
- :connection => connection,
46
- :collection => bucket.objects
47
- }.merge!(object))
40
+ bucket.objects << bucket.objects.new(object)
48
41
  end
49
42
  bucket
50
43
  rescue Excon::Errors::NotFound
@@ -13,11 +13,20 @@ module Fog
13
13
  model Fog::AWS::S3::Object
14
14
 
15
15
  def all(options = {})
16
+ merge_attributes(options)
17
+ if @loaded
18
+ clear
19
+ end
20
+ @loaded = true
16
21
  collection = bucket.collection.get(
17
22
  bucket.name,
18
23
  options
19
24
  )
20
- collection && collection.objects
25
+ if collection
26
+ self.replace(collection.objects)
27
+ else
28
+ nil
29
+ end
21
30
  end
22
31
 
23
32
  def bucket
@@ -41,12 +50,7 @@ module Fog
41
50
  object_data[key] = value
42
51
  end
43
52
  end
44
- object = Fog::AWS::S3::Object.new({
45
- :bucket => bucket,
46
- :collection => self,
47
- :connection => connection
48
- }.merge!(object_data))
49
- object
53
+ new(object_data)
50
54
  rescue Excon::Errors::NotFound
51
55
  nil
52
56
  end
@@ -65,12 +69,7 @@ module Fog
65
69
  object_data[key] = value
66
70
  end
67
71
  end
68
- object = Fog::AWS::S3::Object.new({
69
- :bucket => bucket,
70
- :collection => self,
71
- :connection => connection
72
- }.merge!(object_data))
73
- object
72
+ new(object_data)
74
73
  rescue Excon::Errors::NotFound
75
74
  nil
76
75
  end
@@ -39,7 +39,7 @@ unless Fog.mocking?
39
39
  end
40
40
  query = ''
41
41
  for key, value in options
42
- query << "#{key}=#{CGI.escape(value).gsub(/\+/, '%20')};"
42
+ query << "#{key}=#{CGI.escape(value.to_s).gsub(/\+/, '%20')};"
43
43
  end
44
44
  query.chop!
45
45
  request({
@@ -1,6 +1,15 @@
1
1
  module Fog
2
2
  class Collection < Array
3
3
 
4
+ Array.public_instance_methods(false).each do |method|
5
+ class_eval <<-RUBY
6
+ def #{method}(*args)
7
+ lazy_load
8
+ super
9
+ end
10
+ RUBY
11
+ end
12
+
4
13
  def self._load(marhsalled)
5
14
  new(Marshal.load(marshalled))
6
15
  end
@@ -56,6 +65,7 @@ module Fog
56
65
 
57
66
  def initialize(attributes = {})
58
67
  merge_attributes(attributes)
68
+ @loaded = false
59
69
  end
60
70
 
61
71
  def inspect
@@ -101,6 +111,12 @@ module Fog
101
111
 
102
112
  private
103
113
 
114
+ def lazy_load
115
+ unless @loaded
116
+ self.all
117
+ end
118
+ end
119
+
104
120
  def remap_attributes(attributes, mapping)
105
121
  for key, value in mapping
106
122
  if attributes.key?(key)
@@ -11,17 +11,15 @@ module Fog
11
11
  model Fog::Rackspace::Servers::Flavor
12
12
 
13
13
  def all
14
+ if @loaded
15
+ clear
16
+ end
17
+ @loaded = true
14
18
  data = connection.list_flavors_detail.body
15
- flavors = Fog::Rackspace::Servers::Flavors.new({
16
- :connection => connection
17
- })
18
19
  for flavor in data['flavors']
19
- flavors << Fog::Rackspace::Servers::Flavor.new({
20
- :collection => flavors,
21
- :connection => connection
22
- }.merge!(flavor))
20
+ self << new(flavor)
23
21
  end
24
- flavors
22
+ self
25
23
  end
26
24
 
27
25
  def get(flavor_id)
@@ -2,12 +2,6 @@ module Fog
2
2
  module Rackspace
3
3
  class Servers
4
4
 
5
- def addresses(attributes = {})
6
- Fog::AWS::EC2::Addresses.new({
7
- :connection => self
8
- }.merge!(attributes))
9
- end
10
-
11
5
  def images(attributes = {})
12
6
  Fog::Rackspace::Servers::Images.new({
13
7
  :connection => self
@@ -21,20 +15,19 @@ module Fog
21
15
  attribute :server
22
16
 
23
17
  def all
18
+ if @loaded
19
+ clear
20
+ end
21
+ @loaded = true
24
22
  data = connection.list_images_detail.body
25
- servers = Fog::Rackspace::Servers::Images.new({
26
- :connection => connection
27
- })
23
+ images = []
28
24
  for image in data['images']
29
- servers << Fog::Rackspace::Servers::Image.new({
30
- :collection => images,
31
- :connection => connection
32
- }.merge!(image))
25
+ images << new(image)
33
26
  end
34
27
  if server
35
28
  images = images.select {|image| image.server_id == server.id}
36
29
  end
37
- images
30
+ self.replace(images)
38
31
  end
39
32
 
40
33
  def get(image_id)
@@ -11,17 +11,15 @@ module Fog
11
11
  model Fog::Rackspace::Servers::Server
12
12
 
13
13
  def all
14
+ if @loaded
15
+ clear
16
+ end
17
+ @loaded = true
14
18
  data = connection.list_servers_detail.body
15
- servers = Fog::Rackspace::Servers::Servers.new({
16
- :connection => connection
17
- })
18
19
  for server in data['servers']
19
- servers << Fog::Rackspace::Servers::Server.new({
20
- :collection => servers,
21
- :connection => connection
22
- }.merge!(server))
20
+ self << new(server)
23
21
  end
24
- servers
22
+ self
25
23
  end
26
24
 
27
25
  def get(server_id)
@@ -11,7 +11,7 @@ describe 'Slicehost.create_slice' do
11
11
 
12
12
  it "should return proper attributes" do
13
13
  # flavor_id 1: 256 ram, image_id 3: Gentoo 2008.0
14
- actual = slicehost.create_slice(1, 3, 'fogslice').body
14
+ actual = slicehost.create_slice(1, 3, 'fog_create_slice').body
15
15
  actual['addresses'].should be_a(Array)
16
16
  # actual['backup-id'].should be_an(Integer)
17
17
  actual['bw-in'].should be_an(Float)
@@ -5,7 +5,7 @@ describe 'Slicehost.delete_slice' do
5
5
 
6
6
  before(:each) do
7
7
  # flavor_id 1: 256 ram, image_id 3: Gentoo 2008.0
8
- @slice_id = slicehost.create_slice(1, 3, 'fog_slice').body['id']
8
+ @slice_id = slicehost.create_slice(1, 3, 'fog_delete_slice').body['id']
9
9
  end
10
10
 
11
11
  it "should return proper attributes" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-24 00:00:00 -08:00
12
+ date: 2010-01-04 00:00:00 -08:00
13
13
  default_executable: fog
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.0.13
23
+ version: 0.0.14
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mime-types
@@ -237,7 +237,6 @@ files:
237
237
  - spec/aws/models/s3/buckets_spec.rb
238
238
  - spec/aws/models/s3/object_spec.rb
239
239
  - spec/aws/models/s3/objects_spec.rb
240
- - spec/aws/models/s3/owner_spec.rb
241
240
  - spec/aws/requests/ec2/allocate_address_spec.rb
242
241
  - spec/aws/requests/ec2/associate_address_spec.rb
243
242
  - spec/aws/requests/ec2/attach_volume_spec.rb
@@ -367,7 +366,6 @@ test_files:
367
366
  - spec/aws/models/s3/buckets_spec.rb
368
367
  - spec/aws/models/s3/object_spec.rb
369
368
  - spec/aws/models/s3/objects_spec.rb
370
- - spec/aws/models/s3/owner_spec.rb
371
369
  - spec/aws/requests/ec2/allocate_address_spec.rb
372
370
  - spec/aws/requests/ec2/associate_address_spec.rb
373
371
  - spec/aws/requests/ec2/attach_volume_spec.rb
@@ -1,18 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- describe 'Fog::AWS::S3::Owner' do
4
-
5
- describe "#initialize" do
6
-
7
- it "should remap attributes from parser" do
8
- owner = Fog::AWS::S3::Owner.new(
9
- 'DisplayName' => 'name',
10
- 'ID' => 'id'
11
- )
12
- owner.display_name.should == 'name'
13
- owner.id.should == 'id'
14
- end
15
-
16
- end
17
-
18
- end