gcloud 0.1.1 → 0.2.0

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.
@@ -33,14 +33,15 @@ module Gcloud
33
33
  # Google Storage. Gcloud::Storage::Bucket objects are created,
34
34
  # read, updated, and deleted by Gcloud::Storage::Project.
35
35
  #
36
- # require "gcloud/datastore"
36
+ # require "gcloud"
37
37
  #
38
- # storage = Gcloud.storage
38
+ # gcloud = Gcloud.new
39
+ # storage = gcloud.storage
39
40
  #
40
- # bucket = storage.find_bucket "my-bucket"
41
- # file = bucket.find_file "path/to/my-file.ext"
41
+ # bucket = storage.bucket "my-bucket"
42
+ # file = bucket.file "path/to/my-file.ext"
42
43
  #
43
- # See Gcloud.storage
44
+ # See Gcloud#storage
44
45
  class Project
45
46
  ##
46
47
  # The Connection object.
@@ -49,7 +50,7 @@ module Gcloud
49
50
  ##
50
51
  # Creates a new Project instance.
51
52
  #
52
- # See Gcloud.storage
53
+ # See Gcloud#storage
53
54
  def initialize project, credentials #:nodoc:
54
55
  @connection = Connection.new project, credentials
55
56
  end
@@ -59,10 +60,11 @@ module Gcloud
59
60
  #
60
61
  # === Example
61
62
  #
62
- # require "gcloud/datastore"
63
+ # require "gcloud"
63
64
  #
64
- # storage = Gcloud.storage "my-todo-project",
65
- # "/path/to/keyfile.json"
65
+ # gcloud = Gcloud.new "my-todo-project",
66
+ # "/path/to/keyfile.json"
67
+ # storage = gcloud.storage
66
68
  #
67
69
  # storage.project #=> "my-todo-project"
68
70
  #
@@ -82,25 +84,26 @@ module Gcloud
82
84
  # === Parameters
83
85
  #
84
86
  # +options+::
85
- # An optional Hash for controlling additional behavor. (+Hash+)
86
- # +options [:prefix]+::
87
+ # An optional Hash for controlling additional behavior. (+Hash+)
88
+ # <code>options[:prefix]</code>::
87
89
  # Filter results to buckets whose names begin with this prefix.
88
90
  # (+String+)
89
- # +options [:token]+::
91
+ # <code>options[:token]</code>::
90
92
  # A previously-returned page token representing part of the larger set
91
93
  # of results to view. (+String+)
92
- # +options [:max]+::
94
+ # <code>options[:max]</code>::
93
95
  # Maximum number of buckets to return. (+Integer+)
94
96
  #
95
97
  # === Returns
96
98
  #
97
- # Array of Gcloud::Datastore::Bucket (Gcloud::Datastore::Bucket::List)
99
+ # Array of Gcloud::Storage::Bucket (Gcloud::Storage::Bucket::List)
98
100
  #
99
101
  # === Examples
100
102
  #
101
- # require "gcloud/datastore"
103
+ # require "gcloud"
102
104
  #
103
- # storage = Gcloud.storage
105
+ # gcloud = Gcloud.new
106
+ # storage = gcloud.storage
104
107
  #
105
108
  # buckets = storage.buckets
106
109
  # buckets.each do |bucket|
@@ -110,18 +113,20 @@ module Gcloud
110
113
  # You can also retrieve all buckets whose names begin with a prefix using
111
114
  # the +:prefix+ option:
112
115
  #
113
- # require "gcloud/storage"
116
+ # require "gcloud"
114
117
  #
115
- # storage = Gcloud.storage
118
+ # gcloud = Gcloud.new
119
+ # storage = gcloud.storage
116
120
  #
117
121
  # user_buckets = storage.buckets prefix: "user-"
118
122
  #
119
123
  # If you have a significant number of buckets, you may need to paginate
120
124
  # through them: (See Bucket::List#token)
121
125
  #
122
- # require "gcloud/storage"
126
+ # require "gcloud"
123
127
  #
124
- # storage = Gcloud.storage
128
+ # gcloud = Gcloud.new
129
+ # storage = gcloud.storage
125
130
  #
126
131
  # all_buckets = []
127
132
  # tmp_buckets = storage.buckets
@@ -143,6 +148,7 @@ module Gcloud
143
148
  fail ApiError.from_response(resp)
144
149
  end
145
150
  end
151
+ alias_method :find_buckets, :buckets
146
152
 
147
153
  ##
148
154
  # Retrieves bucket by name.
@@ -154,18 +160,19 @@ module Gcloud
154
160
  #
155
161
  # === Returns
156
162
  #
157
- # Gcloud::Datastore::Bucket or nil if bucket does not exist
163
+ # Gcloud::Storage::Bucket or nil if bucket does not exist
158
164
  #
159
165
  # === Example
160
166
  #
161
- # require "gcloud/storage"
167
+ # require "gcloud"
162
168
  #
163
- # storage = Gcloud.storage
169
+ # gcloud = Gcloud.new
170
+ # storage = gcloud.storage
164
171
  #
165
- # bucket = storage.find_bucket "my-bucket"
172
+ # bucket = storage.bucket "my-bucket"
166
173
  # puts bucket.name
167
174
  #
168
- def find_bucket bucket_name
175
+ def bucket bucket_name
169
176
  resp = connection.get_bucket bucket_name
170
177
  if resp.success?
171
178
  Bucket.from_gapi resp.data, connection
@@ -174,6 +181,7 @@ module Gcloud
174
181
  fail ApiError.from_response(resp)
175
182
  end
176
183
  end
184
+ alias_method :find_bucket, :bucket
177
185
 
178
186
  ##
179
187
  # Creates a new bucket.
@@ -183,20 +191,21 @@ module Gcloud
183
191
  # +bucket_name+::
184
192
  # Name of a bucket. (+String+)
185
193
  # +options+::
186
- # An optional Hash for controlling additional behavor. (+Hash+)
187
- # +options [:retries]+::
194
+ # An optional Hash for controlling additional behavior. (+Hash+)
195
+ # <code>options[:retries]</code>::
188
196
  # The number of times the API call should be retried.
189
197
  # Default is Gcloud::Backoff.retries. (+Integer+)
190
198
  #
191
199
  # === Returns
192
200
  #
193
- # Gcloud::Datastore::Bucket
201
+ # Gcloud::Storage::Bucket
194
202
  #
195
203
  # === Examples
196
204
  #
197
- # require "gcloud/storage"
205
+ # require "gcloud"
198
206
  #
199
- # storage = Gcloud.storage
207
+ # gcloud = Gcloud.new
208
+ # storage = gcloud.storage
200
209
  #
201
210
  # bucket = storage.create_bucket "my-bucket"
202
211
  #
@@ -204,9 +213,10 @@ module Gcloud
204
213
  # conditions. See Gcloud::Backoff to control this behavior, or
205
214
  # specify the wanted behavior in the call with the +:retries:+ option:
206
215
  #
207
- # require "gcloud/storage"
216
+ # require "gcloud"
208
217
  #
209
- # storage = Gcloud.storage
218
+ # gcloud = Gcloud.new
219
+ # storage = gcloud.storage
210
220
  #
211
221
  # bucket = storage.create_bucket "my-bucket", retries: 5
212
222
  #
@@ -16,5 +16,5 @@
16
16
  #--
17
17
  # Google Cloud Version
18
18
  module Gcloud
19
- VERSION = "0.1.1"
19
+ VERSION = "0.2.0"
20
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.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Silvano Luciani
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-17 00:00:00.000000000 Z
12
+ date: 2015-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beefcake
@@ -158,17 +158,13 @@ email:
158
158
  executables: []
159
159
  extensions: []
160
160
  extra_rdoc_files:
161
+ - OVERVIEW.md
161
162
  - AUTHENTICATION.md
162
163
  - CHANGELOG.md
163
- - CONTRIBUTING.md
164
- - LICENSE
165
- - README.md
166
164
  files:
167
165
  - AUTHENTICATION.md
168
166
  - CHANGELOG.md
169
- - CONTRIBUTING.md
170
- - LICENSE
171
- - README.md
167
+ - OVERVIEW.md
172
168
  - lib/gcloud.rb
173
169
  - lib/gcloud/backoff.rb
174
170
  - lib/gcloud/credentials.rb
@@ -186,6 +182,17 @@ files:
186
182
  - lib/gcloud/datastore/query.rb
187
183
  - lib/gcloud/datastore/transaction.rb
188
184
  - lib/gcloud/proto/datastore_v1.pb.rb
185
+ - lib/gcloud/pubsub.rb
186
+ - lib/gcloud/pubsub/connection.rb
187
+ - lib/gcloud/pubsub/credentials.rb
188
+ - lib/gcloud/pubsub/errors.rb
189
+ - lib/gcloud/pubsub/message.rb
190
+ - lib/gcloud/pubsub/project.rb
191
+ - lib/gcloud/pubsub/received_message.rb
192
+ - lib/gcloud/pubsub/subscription.rb
193
+ - lib/gcloud/pubsub/subscription/list.rb
194
+ - lib/gcloud/pubsub/topic.rb
195
+ - lib/gcloud/pubsub/topic/list.rb
189
196
  - lib/gcloud/storage.rb
190
197
  - lib/gcloud/storage/bucket.rb
191
198
  - lib/gcloud/storage/bucket/acl.rb
@@ -206,7 +213,7 @@ metadata: {}
206
213
  post_install_message:
207
214
  rdoc_options:
208
215
  - --main
209
- - README.md
216
+ - OVERVIEW.md
210
217
  - --exclude
211
218
  - lib/gcloud/proto/
212
219
  require_paths:
@@ -1,93 +0,0 @@
1
- # Contributing to Gcloud
2
-
3
- 1. **Sign one of the contributor license agreements below.**
4
- 2. Fork the repo, develop and test your code changes.
5
- 3. Send a pull request.
6
-
7
- ## Contributor License Agreements
8
-
9
- Before we can accept your pull requests you'll need to sign a Contributor License Agreement (CLA):
10
-
11
- - **If you are an individual writing original source code** and **you own the intellectual property**, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual).
12
- - **If you work for a company that wants to allow you to contribute your work**, then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate).
13
-
14
- You can sign these electronically (just scroll to the bottom). After that, we'll be able to accept your pull requests.
15
-
16
- ## Tests
17
-
18
- Tests are very important part of gcloud-ruby. All contributions should include tests that ensure the contributed code behaves as expected.
19
-
20
- ### Unit Tests
21
-
22
- To run the unit tests, simply run:
23
-
24
- ``` sh
25
- $ rake test
26
- ```
27
-
28
- ### Regression Tests
29
-
30
- To run the regression tests, first create and configure a project in the Google Developers Console. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and the KEYFILE location on your system.
31
-
32
- Then Install the [gcloud command-line tool](https://developers.google.com/cloud/sdk/gcloud/) and use it to create the indexes used in the datastore regression tests.
33
-
34
- From the project's root directory:
35
-
36
- ``` sh
37
- # Install the app component
38
- $ gcloud components update app
39
-
40
- # Set the default project in your env
41
- $ gcloud config set project PROJECT_ID
42
-
43
- # Authenticate the gcloud tool with your account
44
- $ gcloud auth login
45
-
46
- # Create the indexes
47
- $ gcloud preview datastore create-indexes regression/data/
48
- ```
49
-
50
- As soon as the indexes are prepared you can run the regression tests:
51
-
52
- ``` sh
53
- $ rake test:regression[PROJECT_ID,KEYFILE_PATH]
54
- ```
55
-
56
- Or, if you prefer you can store the values in the `GCLOUD_TEST_PROJECT` and `GCLOUD_TEST_KEYFILE` environment variables:
57
-
58
- ``` sh
59
- $ export GCLOUD_TEST_PROJECT=my-project-id
60
- $ export GCLOUD_TEST_KEYFILE=/path/to/keyfile.json
61
- $ rake test:regression
62
- ```
63
-
64
- If you want to use different values for Datastore vs. Storage regression tests, you can use the `DATASTORE_TEST_` and `STORAGE_TEST_` environment variables:
65
-
66
- ``` sh
67
- $ export DATASTORE_TEST_PROJECT=my-project-id
68
- $ export DATASTORE_TEST_KEYFILE=/path/to/keyfile.json
69
- $ export STORAGE_TEST_PROJECT=my-other-project-id
70
- $ export STORAGE_TEST_KEYFILE=/path/to/other/keyfile.json
71
- $ rake test:regression
72
- ```
73
-
74
- ### Local Datastore Devserver
75
-
76
- You can run the Datstore regression tests against a devserver running locally. To switch to the devserver set the `DATASTORE_HOST` environment variable with the location of the local devserver.
77
-
78
- ``` sh
79
- $ DATASTORE_HOST=http://127.0.0.1:8080 rake test:regression:datastore
80
- ```
81
-
82
- ## Coding Style
83
-
84
- Please follow the established coding style in the library. The style is is largely based on [The Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based on seattle-style:
85
-
86
- * Avoid parenthesis when possible, including in method definitions.
87
- * Always use double quotes strings. ([Option B](https://github.com/bbatsov/ruby-style-guide#strings))
88
-
89
- You can check your code against these rules by running Rubocop like so:
90
-
91
- ```sh
92
- $ rake rubocop
93
- ```
data/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.