gcloud 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +13 -5
  2. data/AUTHENTICATION.md +71 -0
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +10 -15
  5. data/lib/gcloud.rb +30 -0
  6. data/lib/gcloud/backoff.rb +3 -0
  7. data/lib/gcloud/credentials.rb +47 -30
  8. data/lib/gcloud/datastore.rb +246 -15
  9. data/lib/gcloud/datastore/connection.rb +4 -2
  10. data/lib/gcloud/datastore/credentials.rb +3 -1
  11. data/lib/gcloud/datastore/dataset.rb +130 -25
  12. data/lib/gcloud/datastore/dataset/lookup_results.rb +1 -0
  13. data/lib/gcloud/datastore/dataset/query_results.rb +7 -5
  14. data/lib/gcloud/datastore/entity.rb +99 -17
  15. data/lib/gcloud/datastore/errors.rb +13 -2
  16. data/lib/gcloud/datastore/key.rb +133 -2
  17. data/lib/gcloud/datastore/properties.rb +6 -1
  18. data/lib/gcloud/datastore/proto.rb +2 -1
  19. data/lib/gcloud/datastore/query.rb +4 -4
  20. data/lib/gcloud/datastore/transaction.rb +3 -0
  21. data/lib/gcloud/storage.rb +280 -13
  22. data/lib/gcloud/storage/bucket.rb +248 -11
  23. data/lib/gcloud/storage/bucket/acl.rb +631 -4
  24. data/lib/gcloud/storage/bucket/list.rb +1 -0
  25. data/lib/gcloud/storage/connection.rb +1 -0
  26. data/lib/gcloud/storage/credentials.rb +3 -1
  27. data/lib/gcloud/storage/errors.rb +9 -1
  28. data/lib/gcloud/storage/file.rb +231 -6
  29. data/lib/gcloud/storage/file/acl.rb +365 -2
  30. data/lib/gcloud/storage/file/list.rb +1 -0
  31. data/lib/gcloud/storage/file/verifier.rb +1 -0
  32. data/lib/gcloud/storage/project.rb +119 -10
  33. data/lib/gcloud/version.rb +18 -3
  34. metadata +33 -80
  35. data/.gemtest +0 -0
  36. data/.rubocop.yml +0 -17
  37. data/Manifest.txt +0 -66
  38. data/Rakefile +0 -35
  39. data/gcloud.gemspec +0 -63
  40. data/rakelib/console.rake +0 -28
  41. data/rakelib/manifest.rake +0 -24
  42. data/rakelib/proto.rake +0 -17
  43. data/rakelib/rubocop.rake +0 -17
  44. data/rakelib/test.rake +0 -144
  45. data/test/gcloud/datastore/proto/test_cursor.rb +0 -36
  46. data/test/gcloud/datastore/proto/test_direction.rb +0 -60
  47. data/test/gcloud/datastore/proto/test_operator.rb +0 -76
  48. data/test/gcloud/datastore/proto/test_value.rb +0 -231
  49. data/test/gcloud/datastore/test_connection.rb +0 -93
  50. data/test/gcloud/datastore/test_credentials.rb +0 -38
  51. data/test/gcloud/datastore/test_dataset.rb +0 -413
  52. data/test/gcloud/datastore/test_entity.rb +0 -161
  53. data/test/gcloud/datastore/test_entity_exclude.rb +0 -225
  54. data/test/gcloud/datastore/test_key.rb +0 -189
  55. data/test/gcloud/datastore/test_query.rb +0 -271
  56. data/test/gcloud/datastore/test_transaction.rb +0 -121
  57. data/test/gcloud/storage/test_backoff.rb +0 -127
  58. data/test/gcloud/storage/test_bucket.rb +0 -270
  59. data/test/gcloud/storage/test_bucket_acl.rb +0 -253
  60. data/test/gcloud/storage/test_default_acl.rb +0 -256
  61. data/test/gcloud/storage/test_file.rb +0 -221
  62. data/test/gcloud/storage/test_file_acl.rb +0 -367
  63. data/test/gcloud/storage/test_project.rb +0 -180
  64. data/test/gcloud/storage/test_storage.rb +0 -29
  65. data/test/gcloud/storage/test_verifier.rb +0 -62
  66. data/test/gcloud/test_version.rb +0 -8
  67. data/test/helper.rb +0 -91
@@ -1,29 +0,0 @@
1
- # Copyright 2014 Google Inc. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require "helper"
16
- require "gcloud/storage"
17
-
18
- describe Gcloud::Storage do
19
- it "has resumable_threshold" do
20
- Gcloud::Storage.resumable_threshold.must_equal 5_000_000
21
- end
22
-
23
- it "can update resumable_threshold" do
24
- old_threshold = Gcloud::Storage.resumable_threshold
25
- Gcloud::Storage.resumable_threshold = 10_000_000
26
- Gcloud::Storage.resumable_threshold.must_equal 10_000_000
27
- Gcloud::Storage.resumable_threshold = old_threshold
28
- end
29
- end
@@ -1,62 +0,0 @@
1
- # Copyright 2014 Google Inc. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require "helper"
16
-
17
- describe Gcloud::Storage::File::Verifier, :mock_storage do
18
- let(:file_contents) { "The quick brown fox jumps over the lazy dog." }
19
- let(:md5_digest) { "1B2M2Y8AsgTpgAmY7PhCfg==" }
20
- let(:crc32c_digest) { "AAAAAA==" }
21
- let :file do
22
- Gcloud::Storage::File.from_gapi corrected_file_hash,
23
- OpenStruct.new
24
- end
25
-
26
- it "verifies md5 digest" do
27
- Tempfile.open "gcloud-ruby" do |tmpfile|
28
- tmpfile.write file_contents
29
- assert Gcloud::Storage::File::Verifier.verify_md5(file, tmpfile)
30
- end
31
- end
32
-
33
- it "verifies crc32c digest" do
34
- Tempfile.open "gcloud-ruby" do |tmpfile|
35
- tmpfile.write file_contents
36
- assert Gcloud::Storage::File::Verifier.verify_crc32c(file, tmpfile)
37
- end
38
- end
39
-
40
- it "calculates md5 digest" do
41
- Tempfile.open "gcloud-ruby" do |tmpfile|
42
- tmpfile.write file_contents
43
- digest = Gcloud::Storage::File::Verifier.md5_for tmpfile
44
- digest.must_equal md5_digest
45
- end
46
- end
47
-
48
- it "calculates crc32c digest" do
49
- Tempfile.open "gcloud-ruby" do |tmpfile|
50
- tmpfile.write file_contents
51
- digest = Gcloud::Storage::File::Verifier.crc32c_for tmpfile
52
- digest.must_equal crc32c_digest
53
- end
54
- end
55
-
56
- def corrected_file_hash
57
- hash = random_file_hash("bucket", "file.ext")
58
- hash["md5Hash"] = md5_digest
59
- hash["crc32c"] = crc32c_digest
60
- hash
61
- end
62
- end
@@ -1,8 +0,0 @@
1
- require "helper"
2
- require "gcloud"
3
-
4
- describe Gcloud do
5
- it "has a version" do
6
- Gcloud::VERSION.wont_be :nil?
7
- end
8
- end
data/test/helper.rb DELETED
@@ -1,91 +0,0 @@
1
- # Copyright 2014 Google Inc. All rights reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- gem "minitest"
16
- require "minitest/autorun"
17
- require "ostruct"
18
- require "gcloud/storage"
19
-
20
- class MockStorage < Minitest::Spec
21
- let(:project) { "test" }
22
- let(:credentials) { OpenStruct.new }
23
- let(:storage) { Gcloud::Storage::Project.new project, credentials }
24
-
25
- def setup
26
- @connection = Faraday::Adapter::Test::Stubs.new
27
- connection = storage.instance_variable_get "@connection"
28
- client = connection.instance_variable_get "@client"
29
- client.connection = Faraday.new do |builder|
30
- # builder.options.params_encoder = Faraday::FlatParamsEncoder
31
- builder.adapter :test, @connection
32
- end
33
- end
34
-
35
- def teardown
36
- @connection.verify_stubbed_calls
37
- end
38
-
39
- def mock_connection
40
- @connection
41
- end
42
-
43
-
44
- def random_bucket_hash name=random_bucket_name
45
- {"kind"=>"storage#bucket",
46
- "id"=>name,
47
- "selfLink"=>"https://www.googleapis.com/storage/v1/b/#{name}",
48
- "projectNumber"=>"1234567890",
49
- "name"=>name,
50
- "timeCreated"=>Time.now,
51
- "metageneration"=>"1",
52
- "owner"=>{"entity"=>"project-owners-1234567890"},
53
- "location"=>"US",
54
- "storageClass"=>"STANDARD",
55
- "etag"=>"CAE="}
56
- end
57
-
58
- def random_file_hash bucket=random_bucket_name, name=random_file_path
59
- {"kind"=>"storage#object",
60
- "id"=>"#{bucket}/#{name}/1234567890",
61
- "selfLink"=>"https://www.googleapis.com/storage/v1/b/#{bucket}/o/#{name}",
62
- "name"=>"#{name}",
63
- "bucket"=>"#{bucket}",
64
- "generation"=>"1234567890",
65
- "metageneration"=>"1",
66
- "contentType"=>"text/plain",
67
- "updated"=>Time.now,
68
- "storageClass"=>"STANDARD",
69
- "size"=>rand(10_000),
70
- "md5Hash"=>"HXB937GQDFxDFqUGi//weQ==",
71
- "mediaLink"=>"https://www.googleapis.com/download/storage/v1/b/#{bucket}/o/#{name}?generation=1234567890&alt=media",
72
- "owner"=>{"entity"=>"user-1234567890", "entityId"=>"abc123"},
73
- "crc32c"=>"Lm1F3g==",
74
- "etag"=>"CKih16GjycICEAE="}
75
- end
76
-
77
- def random_bucket_name
78
- (0...50).map { ("a".."z").to_a[rand(26)] }.join
79
- end
80
-
81
- def random_file_path
82
- [(0...10).map { ("a".."z").to_a[rand(26)] }.join,
83
- (0...10).map { ("a".."z").to_a[rand(26)] }.join,
84
- (0...10).map { ("a".."z").to_a[rand(26)] }.join + ".txt"].join "/"
85
- end
86
-
87
- # Register this spec type for when :storage is used.
88
- register_spec_type(self) do |desc, *addl|
89
- addl.include? :mock_storage
90
- end
91
- end