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,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2015 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,3 +1,4 @@
1
+ #--
1
2
  # Copyright 2014 Google Inc. All rights reserved.
2
3
  #
3
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,14 +22,21 @@ require "gcloud/storage/file"
21
22
  module Gcloud
22
23
  module Storage
23
24
  ##
24
- # Represents the Project that the Buckets and Files belong to.
25
+ # = Project
26
+ #
27
+ # Represents the project that storage buckets and files belong to.
28
+ # All data in Google Cloud Storage belongs inside a project.
29
+ # A project consists of a set of users, a set of APIs, billing,
30
+ # authentication, and monitoring settings for those APIs.
25
31
  #
26
32
  # Gcloud::Storage::Project is the main object for interacting with
27
33
  # Google Storage. Gcloud::Storage::Bucket objects are created,
28
34
  # read, updated, and deleted by Gcloud::Storage::Project.
29
35
  #
30
- # storage = Gcloud.storage "my-todo-project",
31
- # "/path/to/keyfile.json"
36
+ # require "gcloud/datastore"
37
+ #
38
+ # storage = Gcloud.storage
39
+ #
32
40
  # bucket = storage.find_bucket "my-bucket"
33
41
  # file = bucket.find_file "path/to/my-file.ext"
34
42
  #
@@ -47,21 +55,86 @@ module Gcloud
47
55
  end
48
56
 
49
57
  ##
50
- # The project identifier.
58
+ # The Storage project connected to.
59
+ #
60
+ # === Example
61
+ #
62
+ # require "gcloud/datastore"
63
+ #
64
+ # storage = Gcloud.storage "my-todo-project",
65
+ # "/path/to/keyfile.json"
66
+ #
67
+ # storage.project #=> "my-todo-project"
68
+ #
51
69
  def project
52
70
  connection.project
53
71
  end
54
72
 
73
+ ##
74
+ # Default project.
75
+ def self.default_project #:nodoc:
76
+ ENV["STORAGE_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"]
77
+ end
78
+
55
79
  ##
56
80
  # Retrieves a list of buckets for the given project.
57
81
  #
82
+ # === Parameters
83
+ #
84
+ # +options+::
85
+ # An optional Hash for controlling additional behavor. (+Hash+)
86
+ # +options [:prefix]+::
87
+ # Filter results to buckets whose names begin with this prefix.
88
+ # (+String+)
89
+ # +options [:token]+::
90
+ # A previously-returned page token representing part of the larger set
91
+ # of results to view. (+String+)
92
+ # +options [:max]+::
93
+ # Maximum number of buckets to return. (+Integer+)
94
+ #
95
+ # === Returns
96
+ #
97
+ # Array of Gcloud::Datastore::Bucket (Gcloud::Datastore::Bucket::List)
98
+ #
99
+ # === Examples
100
+ #
101
+ # require "gcloud/datastore"
102
+ #
58
103
  # storage = Gcloud.storage
104
+ #
59
105
  # buckets = storage.buckets
60
106
  # buckets.each do |bucket|
61
107
  # puts bucket.name
62
108
  # end
63
109
  #
64
- # See Gcloud::Storage::Bucket
110
+ # You can also retrieve all buckets whose names begin with a prefix using
111
+ # the +:prefix+ option:
112
+ #
113
+ # require "gcloud/storage"
114
+ #
115
+ # storage = Gcloud.storage
116
+ #
117
+ # user_buckets = storage.buckets prefix: "user-"
118
+ #
119
+ # If you have a significant number of buckets, you may need to paginate
120
+ # through them: (See Bucket::List#token)
121
+ #
122
+ # require "gcloud/storage"
123
+ #
124
+ # storage = Gcloud.storage
125
+ #
126
+ # all_buckets = []
127
+ # tmp_buckets = storage.buckets
128
+ # while tmp_buckets.any? do
129
+ # tmp_buckets.each do |bucket|
130
+ # all_buckets << bucket
131
+ # end
132
+ # # break loop if no more buckets available
133
+ # break if tmp_buckets.token.nil?
134
+ # # get the next group of buckets
135
+ # tmp_buckets = storage.buckets token: tmp_buckets.token
136
+ # end
137
+ #
65
138
  def buckets options = {}
66
139
  resp = connection.list_buckets options
67
140
  if resp.success?
@@ -74,11 +147,24 @@ module Gcloud
74
147
  ##
75
148
  # Retrieves bucket by name.
76
149
  #
150
+ # === Parameters
151
+ #
152
+ # +bucket_name+::
153
+ # Name of a bucket. (+String+)
154
+ #
155
+ # === Returns
156
+ #
157
+ # Gcloud::Datastore::Bucket or nil if bucket does not exist
158
+ #
159
+ # === Example
160
+ #
161
+ # require "gcloud/storage"
162
+ #
77
163
  # storage = Gcloud.storage
164
+ #
78
165
  # bucket = storage.find_bucket "my-bucket"
79
166
  # puts bucket.name
80
167
  #
81
- # See Gcloud::Storage::Bucket
82
168
  def find_bucket bucket_name
83
169
  resp = connection.get_bucket bucket_name
84
170
  if resp.success?
@@ -92,15 +178,38 @@ module Gcloud
92
178
  ##
93
179
  # Creates a new bucket.
94
180
  #
95
- # bucket = project.create_bucket "my-bucket"
181
+ # === Parameters
182
+ #
183
+ # +bucket_name+::
184
+ # Name of a bucket. (+String+)
185
+ # +options+::
186
+ # An optional Hash for controlling additional behavor. (+Hash+)
187
+ # +options [:retries]+::
188
+ # The number of times the API call should be retried.
189
+ # Default is Gcloud::Backoff.retries. (+Integer+)
190
+ #
191
+ # === Returns
192
+ #
193
+ # Gcloud::Datastore::Bucket
194
+ #
195
+ # === Examples
196
+ #
197
+ # require "gcloud/storage"
198
+ #
199
+ # storage = Gcloud.storage
200
+ #
201
+ # bucket = storage.create_bucket "my-bucket"
96
202
  #
97
203
  # The API call to create the bucket may be retried under certain
98
204
  # conditions. See Gcloud::Backoff to control this behavior, or
99
- # specify the wanted behavior in the call:
205
+ # specify the wanted behavior in the call with the +:retries:+ option:
206
+ #
207
+ # require "gcloud/storage"
208
+ #
209
+ # storage = Gcloud.storage
100
210
  #
101
- # bucket = project.create_bucket "my-bucket", retries: 5
211
+ # bucket = storage.create_bucket "my-bucket", retries: 5
102
212
  #
103
- # See Gcloud::Storage::Bucket
104
213
  def create_bucket bucket_name, options = {}
105
214
  options[:acl] = Bucket::Acl.predefined_rule_for options[:acl]
106
215
  default_acl = options[:default_acl]
@@ -1,5 +1,20 @@
1
- ##
2
- # Google Cloud
1
+ #--
2
+ # Copyright 2015 Google Inc. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ #--
17
+ # Google Cloud Version
3
18
  module Gcloud
4
- VERSION = "0.1.0"
19
+ VERSION = "0.1.1"
5
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silvano Luciani
@@ -9,162 +9,148 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
12
+ date: 2015-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: google-api-client
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.8.3
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.8.3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: mime-types
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '2.4'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '2.4'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: digest-crc
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0.4'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0.4'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: minitest
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: '5.5'
76
+ version: '5.7'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
- version: '5.5'
83
+ version: '5.7'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rdoc
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: '4.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ~>
96
96
  - !ruby/object:Gem::Version
97
97
  version: '4.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ~>
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0.27'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ~>
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0.27'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: httpclient
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "~>"
116
+ - - ~>
117
117
  - !ruby/object:Gem::Version
118
118
  version: '2.5'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "~>"
123
+ - - ~>
124
124
  - !ruby/object:Gem::Version
125
125
  version: '2.5'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: simplecov
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0.9'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - ~>
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0.9'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: coveralls
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - "~>"
144
+ - - ~>
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0.7'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - "~>"
151
+ - - ~>
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0.7'
154
- - !ruby/object:Gem::Dependency
155
- name: hoe
156
- requirement: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - "~>"
159
- - !ruby/object:Gem::Version
160
- version: '3.13'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - "~>"
166
- - !ruby/object:Gem::Version
167
- version: '3.13'
168
154
  description: Gcloud is the official library for interacting with Google Cloud.
169
155
  email:
170
156
  - silvano@google.com
@@ -172,20 +158,17 @@ email:
172
158
  executables: []
173
159
  extensions: []
174
160
  extra_rdoc_files:
161
+ - AUTHENTICATION.md
175
162
  - CHANGELOG.md
176
163
  - CONTRIBUTING.md
177
- - Manifest.txt
164
+ - LICENSE
178
165
  - README.md
179
166
  files:
180
- - ".gemtest"
181
- - ".rubocop.yml"
167
+ - AUTHENTICATION.md
182
168
  - CHANGELOG.md
183
169
  - CONTRIBUTING.md
184
170
  - LICENSE
185
- - Manifest.txt
186
171
  - README.md
187
- - Rakefile
188
- - gcloud.gemspec
189
172
  - lib/gcloud.rb
190
173
  - lib/gcloud/backoff.rb
191
174
  - lib/gcloud/credentials.rb
@@ -216,61 +199,31 @@ files:
216
199
  - lib/gcloud/storage/file/verifier.rb
217
200
  - lib/gcloud/storage/project.rb
218
201
  - lib/gcloud/version.rb
219
- - rakelib/console.rake
220
- - rakelib/manifest.rake
221
- - rakelib/proto.rake
222
- - rakelib/rubocop.rake
223
- - rakelib/test.rake
224
- - test/gcloud/datastore/proto/test_cursor.rb
225
- - test/gcloud/datastore/proto/test_direction.rb
226
- - test/gcloud/datastore/proto/test_operator.rb
227
- - test/gcloud/datastore/proto/test_value.rb
228
- - test/gcloud/datastore/test_connection.rb
229
- - test/gcloud/datastore/test_credentials.rb
230
- - test/gcloud/datastore/test_dataset.rb
231
- - test/gcloud/datastore/test_entity.rb
232
- - test/gcloud/datastore/test_entity_exclude.rb
233
- - test/gcloud/datastore/test_key.rb
234
- - test/gcloud/datastore/test_query.rb
235
- - test/gcloud/datastore/test_transaction.rb
236
- - test/gcloud/storage/test_backoff.rb
237
- - test/gcloud/storage/test_bucket.rb
238
- - test/gcloud/storage/test_bucket_acl.rb
239
- - test/gcloud/storage/test_default_acl.rb
240
- - test/gcloud/storage/test_file.rb
241
- - test/gcloud/storage/test_file_acl.rb
242
- - test/gcloud/storage/test_project.rb
243
- - test/gcloud/storage/test_storage.rb
244
- - test/gcloud/storage/test_verifier.rb
245
- - test/gcloud/test_version.rb
246
- - test/helper.rb
247
202
  homepage: http://googlecloudplatform.github.io/gcloud-ruby/
248
203
  licenses:
249
204
  - Apache-2.0
250
205
  metadata: {}
251
206
  post_install_message:
252
207
  rdoc_options:
253
- - "--main"
208
+ - --main
254
209
  - README.md
255
- - "--exclude"
210
+ - --exclude
256
211
  - lib/gcloud/proto/
257
- - "--exclude"
258
- - Manifest.txt
259
212
  require_paths:
260
213
  - lib
261
214
  required_ruby_version: !ruby/object:Gem::Requirement
262
215
  requirements:
263
- - - ">="
216
+ - - ! '>='
264
217
  - !ruby/object:Gem::Version
265
- version: '0'
218
+ version: 1.9.3
266
219
  required_rubygems_version: !ruby/object:Gem::Requirement
267
220
  requirements:
268
- - - ">="
221
+ - - ! '>='
269
222
  - !ruby/object:Gem::Version
270
223
  version: '0'
271
224
  requirements: []
272
225
  rubyforge_project:
273
- rubygems_version: 2.4.6
226
+ rubygems_version: 2.4.5
274
227
  signing_key:
275
228
  specification_version: 4
276
229
  summary: API Client library for Google Cloud