fog 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/Gemfile.lock +1 -1
  2. data/README.rdoc +1 -0
  3. data/fog.gemspec +44 -1
  4. data/lib/fog.rb +2 -1
  5. data/lib/fog/bin.rb +2 -0
  6. data/lib/fog/google.rb +22 -0
  7. data/lib/fog/google/bin.rb +20 -0
  8. data/lib/fog/google/models/storage/directories.rb +43 -0
  9. data/lib/fog/google/models/storage/directory.rb +48 -0
  10. data/lib/fog/google/models/storage/file.rb +87 -0
  11. data/lib/fog/google/models/storage/files.rb +94 -0
  12. data/lib/fog/google/parsers/storage/access_control_list.rb +46 -0
  13. data/lib/fog/google/parsers/storage/copy_object.rb +22 -0
  14. data/lib/fog/google/parsers/storage/get_bucket.rb +46 -0
  15. data/lib/fog/google/parsers/storage/get_bucket_logging.rb +40 -0
  16. data/lib/fog/google/parsers/storage/get_bucket_object_versions.rb +88 -0
  17. data/lib/fog/google/parsers/storage/get_bucket_versioning.rb +24 -0
  18. data/lib/fog/google/parsers/storage/get_request_payment.rb +20 -0
  19. data/lib/fog/google/parsers/storage/get_service.rb +32 -0
  20. data/lib/fog/google/requests/storage/copy_object.rb +72 -0
  21. data/lib/fog/google/requests/storage/delete_bucket.rb +46 -0
  22. data/lib/fog/google/requests/storage/delete_object.rb +50 -0
  23. data/lib/fog/google/requests/storage/get_bucket.rb +110 -0
  24. data/lib/fog/google/requests/storage/get_bucket_acl.rb +55 -0
  25. data/lib/fog/google/requests/storage/get_object.rb +104 -0
  26. data/lib/fog/google/requests/storage/get_object_acl.rb +66 -0
  27. data/lib/fog/google/requests/storage/get_object_torrent.rb +55 -0
  28. data/lib/fog/google/requests/storage/get_object_url.rb +54 -0
  29. data/lib/fog/google/requests/storage/get_service.rb +53 -0
  30. data/lib/fog/google/requests/storage/head_object.rb +64 -0
  31. data/lib/fog/google/requests/storage/put_bucket.rb +68 -0
  32. data/lib/fog/google/requests/storage/put_bucket_acl.rb +80 -0
  33. data/lib/fog/google/requests/storage/put_object.rb +71 -0
  34. data/lib/fog/google/requests/storage/put_object_url.rb +54 -0
  35. data/lib/fog/google/storage.rb +192 -0
  36. data/spec/google/models/storage/directories_spec.rb +49 -0
  37. data/spec/google/models/storage/directory_spec.rb +83 -0
  38. data/spec/google/models/storage/file_spec.rb +121 -0
  39. data/spec/google/models/storage/files_spec.rb +141 -0
  40. data/spec/google/requests/storage/copy_object_spec.rb +61 -0
  41. data/spec/google/requests/storage/delete_bucket_spec.rb +35 -0
  42. data/spec/google/requests/storage/delete_object_spec.rb +38 -0
  43. data/spec/google/requests/storage/get_bucket_spec.rb +110 -0
  44. data/spec/google/requests/storage/get_object_spec.rb +58 -0
  45. data/spec/google/requests/storage/get_service_spec.rb +32 -0
  46. data/spec/google/requests/storage/head_object_spec.rb +26 -0
  47. data/spec/google/requests/storage/put_bucket_spec.rb +21 -0
  48. data/spec/google/requests/storage/put_object_spec.rb +43 -0
  49. metadata +45 -2
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.delete_bucket' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ Google[:storage].put_bucket('fogdeletebucket')
8
+ end
9
+
10
+ it 'should return proper attributes' do
11
+ actual = Google[:storage].delete_bucket('fogdeletebucket')
12
+ actual.status.should == 204
13
+ end
14
+
15
+ end
16
+ describe 'failure' do
17
+
18
+ it 'should raise a NotFound error if the bucket does not exist' do
19
+ lambda {
20
+ Google[:storage].delete_bucket('fognotabucket')
21
+ }.should raise_error(Excon::Errors::NotFound)
22
+ end
23
+
24
+ it 'should raise a Conflict error if the bucket is not empty' do
25
+ Google[:storage].put_bucket('fogdeletebucket')
26
+ Google[:storage].put_object('fogdeletebucket', 'fog_delete_object', lorem_file)
27
+ lambda {
28
+ Google[:storage].delete_bucket('fogdeletebucket')
29
+ }.should raise_error(Excon::Errors::Conflict)
30
+ Google[:storage].delete_object('fogdeletebucket', 'fog_delete_object')
31
+ Google[:storage].delete_bucket('fogdeletebucket')
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.delete_object' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ Google[:storage].put_bucket('fogdeleteobject')
8
+ Google[:storage].put_object('fogdeleteobject', 'fog_delete_object', lorem_file)
9
+ end
10
+
11
+ after(:each) do
12
+ Google[:storage].delete_bucket('fogdeleteobject')
13
+ end
14
+
15
+ it 'should return proper attributes' do
16
+ actual = Google[:storage].delete_object('fogdeleteobject', 'fog_delete_object')
17
+ actual.status.should == 204
18
+ end
19
+
20
+ end
21
+ describe 'failure' do
22
+
23
+ it 'should raise a NotFound error if the bucket does not exist' do
24
+ lambda {
25
+ Google[:storage].delete_object('fognotabucket', 'fog_delete_object')
26
+ }.should raise_error(Excon::Errors::NotFound)
27
+ end
28
+
29
+ it 'should raise an error if the object does not exist' do
30
+ Google[:storage].put_bucket('fogdeleteobject')
31
+ lambda {
32
+ Google[:storage].delete_object('fogdeleteobject', 'fog_not_an_object')
33
+ }.should raise_error(Excon::Errors::NotFound)
34
+ Google[:storage].delete_bucket('fogdeleteobject')
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,110 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.get_bucket' do
4
+ describe 'success' do
5
+
6
+ before(:all) do
7
+ Google[:storage].put_bucket('foggetbucket')
8
+ Google[:storage].put_object('foggetbucket', 'fog_object', lorem_file)
9
+ Google[:storage].put_object('foggetbucket', 'fog_other_object', lorem_file)
10
+ end
11
+
12
+ after(:all) do
13
+ Google[:storage].delete_object('foggetbucket', 'fog_object')
14
+ Google[:storage].delete_object('foggetbucket', 'fog_other_object')
15
+ Google[:storage].delete_bucket('foggetbucket')
16
+ end
17
+
18
+ it 'should return proper attributes' do
19
+ actual = Google[:storage].get_bucket('foggetbucket')
20
+ actual.body['IsTruncated'].should == false
21
+ actual.body['Marker'].should be_nil
22
+ actual.body['Name'].should be_a(String)
23
+ actual.body['Prefix'].should be_nil
24
+ actual.body['Contents'].should be_an(Array)
25
+ actual.body['Contents'].length.should == 2
26
+ object = actual.body['Contents'].first
27
+ object['ETag'].should be_a(String)
28
+ object['Key'].should == 'fog_object'
29
+ object['LastModified'].should be_a(Time)
30
+ owner = object['Owner']
31
+ owner['DisplayName'].should be_a(String)
32
+ owner['ID'].should be_a(String)
33
+ object['Size'].should be_an(Integer)
34
+ object['StorageClass'].should be_a(String)
35
+ end
36
+
37
+ it 'should accept marker option' do
38
+ actual = Google[:storage].get_bucket('foggetbucket', 'marker' => 'fog_object')
39
+ actual.body['IsTruncated'].should == false
40
+ actual.body['Marker'].should be_a(String)
41
+ actual.body['Name'].should be_a(String)
42
+ actual.body['Prefix'].should be_nil
43
+ actual.body['Contents'].should be_an(Array)
44
+ actual.body['Contents'].length.should == 1
45
+ object = actual.body['Contents'].first
46
+ object['ETag'].should be_a(String)
47
+ object['Key'].should == 'fog_other_object'
48
+ object['LastModified'].should be_a(Time)
49
+ owner = object['Owner']
50
+ owner['DisplayName'].should be_a(String)
51
+ owner['ID'].should be_a(String)
52
+ object['Size'].should be_an(Integer)
53
+ object['StorageClass'].should be_a(String)
54
+ end
55
+
56
+ it 'should accept max-keys option' do
57
+ actual = Google[:storage].get_bucket('foggetbucket', 'max-keys' => 1)
58
+ actual.body['IsTruncated'].should == true
59
+ actual.body['Marker'].should be_nil
60
+ actual.body['Name'].should be_a(String)
61
+ actual.body['Prefix'].should be_nil
62
+ actual.body['Contents'].should be_an(Array)
63
+ actual.body['Contents'].length.should == 1
64
+ object = actual.body['Contents'].first
65
+ object['ETag'].should be_a(String)
66
+ object['Key'].should == 'fog_object'
67
+ object['LastModified'].should be_a(Time)
68
+ owner = object['Owner']
69
+ owner['DisplayName'].should be_a(String)
70
+ owner['ID'].should be_a(String)
71
+ object['Size'].should be_an(Integer)
72
+ object['StorageClass'].should be_a(String)
73
+ end
74
+
75
+ it 'should accept prefix option' do
76
+ actual = Google[:storage].get_bucket('foggetbucket', 'prefix' => 'fog_ob')
77
+ actual.body['IsTruncated'].should == false
78
+ actual.body['Marker'].should be_nil
79
+ actual.body['Name'].should be_a(String)
80
+ actual.body['Prefix'].should be_a(String)
81
+ actual.body['Contents'].should be_an(Array)
82
+ actual.body['Contents'].length.should == 1
83
+ object = actual.body['Contents'].first
84
+ object['ETag'].should be_a(String)
85
+ object['Key'].should == 'fog_object'
86
+ object['LastModified'].should be_a(Time)
87
+ owner = object['Owner']
88
+ owner['DisplayName'].should be_a(String)
89
+ owner['ID'].should be_a(String)
90
+ object['Size'].should be_an(Integer)
91
+ object['StorageClass'].should be_a(String)
92
+ end
93
+
94
+ end
95
+ describe 'failure' do
96
+
97
+ it 'should raise a NotFound error if the bucket does not exist' do
98
+ lambda {
99
+ Google[:storage].get_bucket('fognotabucket')
100
+ }.should raise_error(Excon::Errors::NotFound)
101
+ end
102
+
103
+ it 'should request non-subdomain buckets and raise a NotFound error' do
104
+ lambda {
105
+ Google[:storage].get_bucket('A-invalid--name')
106
+ }.should raise_error(Excon::Errors::BadRequest)
107
+ end
108
+
109
+ end
110
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.get_object' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ Google[:storage].put_bucket('foggetobject')
8
+ Google[:storage].put_object('foggetobject', 'fog_get_object', lorem_file,{'x-goog-acl' => 'public-read'})
9
+ end
10
+
11
+ after(:each) do
12
+ Google[:storage].delete_object('foggetobject', 'fog_get_object')
13
+ Google[:storage].delete_bucket('foggetobject')
14
+ end
15
+
16
+ it 'should return proper attributes' do
17
+ actual = Google[:storage].get_object('foggetobject', 'fog_get_object')
18
+ actual.status.should == 200
19
+ data = lorem_file.read
20
+ actual.body.should == data
21
+ actual.body.length.should == data.length
22
+ actual.headers['Content-Type'].should be_a(String)
23
+ actual.headers['ETag'].should be_a(String)
24
+ actual.headers['Last-Modified'].should be_a(String)
25
+ end
26
+
27
+ it 'should return chunks with optional block' do
28
+ data = ''
29
+ Google[:storage].get_object('foggetobject', 'fog_get_object') do |chunk|
30
+ data << chunk
31
+ end
32
+ data.should == lorem_file.read
33
+ end
34
+
35
+ it 'should return a url' do
36
+ url = Google[:storage].get_object_url('foggetobject', 'fog_get_object', Time.now + 60 * 10)
37
+ unless Fog.mocking?
38
+ open(url).read.should == lorem_file.read
39
+ end
40
+ end
41
+
42
+ end
43
+ describe 'failure' do
44
+
45
+ it 'should raise a NotFound error if the bucket does not exist' do
46
+ lambda {
47
+ Google[:storage].get_object('fognotabucket', 'fog_get_object')
48
+ }.should raise_error(Excon::Errors::NotFound)
49
+ end
50
+
51
+ it 'should raise a NotFound error if the object does not exist' do
52
+ lambda {
53
+ Google[:storage].get_object('foggetobject', 'fog_not_an_object')
54
+ }.should raise_error(Excon::Errors::NotFound)
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.get_service' do
4
+ describe 'success' do
5
+
6
+ before(:all) do
7
+ Google[:storage].put_bucket('foggetservice')
8
+ Fog.wait_for { Google[:storage].directories.get('foggetservice') }
9
+ end
10
+
11
+ after(:all) do
12
+ Google[:storage].delete_bucket('foggetservice')
13
+ end
14
+
15
+ it 'should return proper_attributes' do
16
+ actual = Google[:storage].get_service
17
+ actual.body['Buckets'].should be_an(Array)
18
+ bucket = actual.body['Buckets'].select {|bucket| bucket['Name'] == 'foggetservice'}.first
19
+ bucket['CreationDate'].should be_a(Time)
20
+ bucket['Name'].should == 'foggetservice'
21
+ owner = actual.body['Owner']
22
+ owner['DisplayName'].should be_a(String)
23
+ owner['ID'].should be_a(String)
24
+ end
25
+
26
+ it 'should include foggetservice in get_service' do
27
+ actual = Google[:storage].get_service
28
+ actual.body['Buckets'].collect { |bucket| bucket['Name'] }.should include('foggetservice')
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.head_object' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ Google[:storage].put_bucket('fogheadobject')
8
+ Google[:storage].put_object('fogheadobject', 'fog_head_object', lorem_file)
9
+ end
10
+
11
+ after(:each) do
12
+ Google[:storage].delete_object('fogheadobject', 'fog_head_object')
13
+ Google[:storage].delete_bucket('fogheadobject')
14
+ end
15
+
16
+ it 'should return proper attributes' do
17
+ actual = Google[:storage].head_object('fogheadobject', 'fog_head_object')
18
+ actual.status.should == 200
19
+ data = lorem_file.read
20
+ actual.headers['Content-Length'].should == data.length.to_s
21
+ actual.headers['ETag'].should be_a(String)
22
+ actual.headers['Last-Modified'].should be_a(String)
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.put_bucket' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ @response = Google[:storage].put_bucket('fogputbucket')
8
+ end
9
+
10
+ after(:each) do
11
+ Google[:storage].delete_bucket('fogputbucket')
12
+ end
13
+
14
+ it 'should raise an error if the bucket already exists' do
15
+ lambda {
16
+ Google[:storage].put_bucket('fogputbucket')
17
+ }.should raise_error(Excon::Errors::Conflict)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Storage.put_object' do
4
+ describe 'success' do
5
+
6
+ before(:each) do
7
+ Google[:storage].put_bucket('fogputobject')
8
+ @response = Google[:storage].put_object('fogputobject', 'fog_put_object', lorem_file)
9
+ end
10
+
11
+ after(:each) do
12
+ Google[:storage].delete_object('fogputobject', 'fog_put_object')
13
+ Google[:storage].delete_bucket('fogputobject')
14
+ end
15
+
16
+ it 'should return proper attributes' do
17
+ @response.status.should == 200
18
+ end
19
+
20
+ it 'should not raise an error if the object already exists' do
21
+ actual = Google[:storage].put_object('fogputobject', 'fog_put_object', lorem_file)
22
+ actual.status.should == 200
23
+ end
24
+
25
+ end
26
+ describe 'failure' do
27
+
28
+ it 'should raise a NotFound error if the bucket does not exist' do
29
+ lambda {
30
+ Google[:storage].put_object('fognotabucket', 'fog_put_object', lorem_file)
31
+ }.should raise_error(Excon::Errors::NotFound)
32
+ end
33
+
34
+ it 'should not raise an error if the object already exists' do
35
+ Google[:storage].put_bucket('fogputobject')
36
+ Google[:storage].put_object('fogputobject', 'fog_put_object', lorem_file)
37
+ Google[:storage].put_object('fogputobject', 'fog_put_object', lorem_file)
38
+ Google[:storage].delete_object('fogputobject', 'fog_put_object')
39
+ Google[:storage].delete_bucket('fogputobject')
40
+ end
41
+
42
+ end
43
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -370,6 +370,36 @@ files:
370
370
  - lib/fog/go_grid/requests/compute/grid_server_get.rb
371
371
  - lib/fog/go_grid/requests/compute/grid_server_list.rb
372
372
  - lib/fog/go_grid/requests/compute/grid_server_power.rb
373
+ - lib/fog/google.rb
374
+ - lib/fog/google/bin.rb
375
+ - lib/fog/google/models/storage/directories.rb
376
+ - lib/fog/google/models/storage/directory.rb
377
+ - lib/fog/google/models/storage/file.rb
378
+ - lib/fog/google/models/storage/files.rb
379
+ - lib/fog/google/parsers/storage/access_control_list.rb
380
+ - lib/fog/google/parsers/storage/copy_object.rb
381
+ - lib/fog/google/parsers/storage/get_bucket.rb
382
+ - lib/fog/google/parsers/storage/get_bucket_logging.rb
383
+ - lib/fog/google/parsers/storage/get_bucket_object_versions.rb
384
+ - lib/fog/google/parsers/storage/get_bucket_versioning.rb
385
+ - lib/fog/google/parsers/storage/get_request_payment.rb
386
+ - lib/fog/google/parsers/storage/get_service.rb
387
+ - lib/fog/google/requests/storage/copy_object.rb
388
+ - lib/fog/google/requests/storage/delete_bucket.rb
389
+ - lib/fog/google/requests/storage/delete_object.rb
390
+ - lib/fog/google/requests/storage/get_bucket.rb
391
+ - lib/fog/google/requests/storage/get_bucket_acl.rb
392
+ - lib/fog/google/requests/storage/get_object.rb
393
+ - lib/fog/google/requests/storage/get_object_acl.rb
394
+ - lib/fog/google/requests/storage/get_object_torrent.rb
395
+ - lib/fog/google/requests/storage/get_object_url.rb
396
+ - lib/fog/google/requests/storage/get_service.rb
397
+ - lib/fog/google/requests/storage/head_object.rb
398
+ - lib/fog/google/requests/storage/put_bucket.rb
399
+ - lib/fog/google/requests/storage/put_bucket_acl.rb
400
+ - lib/fog/google/requests/storage/put_object.rb
401
+ - lib/fog/google/requests/storage/put_object_url.rb
402
+ - lib/fog/google/storage.rb
373
403
  - lib/fog/hmac.rb
374
404
  - lib/fog/linode.rb
375
405
  - lib/fog/linode/bin.rb
@@ -651,6 +681,19 @@ files:
651
681
  - spec/bluebox/models/compute/server_spec.rb
652
682
  - spec/bluebox/models/compute/servers_spec.rb
653
683
  - spec/compact_progress_bar_formatter.rb
684
+ - spec/google/models/storage/directories_spec.rb
685
+ - spec/google/models/storage/directory_spec.rb
686
+ - spec/google/models/storage/file_spec.rb
687
+ - spec/google/models/storage/files_spec.rb
688
+ - spec/google/requests/storage/copy_object_spec.rb
689
+ - spec/google/requests/storage/delete_bucket_spec.rb
690
+ - spec/google/requests/storage/delete_object_spec.rb
691
+ - spec/google/requests/storage/get_bucket_spec.rb
692
+ - spec/google/requests/storage/get_object_spec.rb
693
+ - spec/google/requests/storage/get_service_spec.rb
694
+ - spec/google/requests/storage/head_object_spec.rb
695
+ - spec/google/requests/storage/put_bucket_spec.rb
696
+ - spec/google/requests/storage/put_object_spec.rb
654
697
  - spec/lorem.txt
655
698
  - spec/rackspace/models/compute/flavors_spec.rb
656
699
  - spec/rackspace/models/compute/server_spec.rb