google-apis 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +6 -0
- data/README.md +21 -8
- data/VERSION +1 -1
- data/lib/google_apis.rb +6 -1
- data/lib/google_apis/api/base/class_methods.rb +9 -1
- data/lib/google_apis/api/base/instance_methods.rb +5 -4
- data/lib/google_apis/api/big_query.rb +1 -0
- data/lib/google_apis/api/storage.rb +1 -0
- data/lib/google_apis/version.rb +1 -1
- data/test/unit/api/test_big_query.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40cf27a2e19679987b6aa02d3419450df91b0cf8
|
4
|
+
data.tar.gz: c1a8dbb160c470f63784633e8a41516ccb81c51f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b70082d8f1a07f02c13b26ee88de8314c67862d5370cfdf1b9dabc650c311bc1055251d883d3a6e66fde309a616f7fcacc307daabb0cb5799b39413af0c767a
|
7
|
+
data.tar.gz: 8019e1af722bdce66e749725a7dbec8a02555e50c1c86891cf5728c6c2b80e728c0b67366d18b745820eb01740a98293c96adabe6cfce92efd2fa4943b764b95
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= Google APIs CHANGELOG
|
2
2
|
|
3
|
+
== Version 0.1.4 (April 21, 2015)
|
4
|
+
|
5
|
+
* Introduced GoogleApis.config
|
6
|
+
* Improved handling default API parameters
|
7
|
+
* Auto-connecting to API when having a GoogleApis.connection available
|
8
|
+
|
3
9
|
== Version 0.1.3 (April 20, 2015)
|
4
10
|
|
5
11
|
* Camelizing underscored default param keys
|
data/README.md
CHANGED
@@ -99,7 +99,7 @@ Please note that `Google::BigQuery.connection` is provided with several methods
|
|
99
99
|
|
100
100
|
##### Google::Storage.connection
|
101
101
|
|
102
|
-
The following example demonstrates how to download a file from Google Storage:
|
102
|
+
The following example demonstrates how to download and upload a file from Google Storage:
|
103
103
|
|
104
104
|
```ruby
|
105
105
|
[1] pry(main)> Google::Storage.connect :email_address => "lorem@developer.gserviceaccount.com", :private_key => "/path/to/private/key.p12"
|
@@ -170,19 +170,30 @@ Please make sure that you also have created a "Public API access" server key and
|
|
170
170
|
|
171
171
|
If it isn't already clear, you can specify a global Google API connection and use different APIs:
|
172
172
|
|
173
|
+
```yaml
|
174
|
+
---
|
175
|
+
email_address: lorem@developer.gserviceaccount.com
|
176
|
+
private_key: "/path/to/private/key.p12"
|
177
|
+
project_id: your_project_id
|
178
|
+
dataset_id: your_dataset_id
|
179
|
+
bucket: your_bucket
|
180
|
+
```
|
181
|
+
|
173
182
|
```ruby
|
174
|
-
[1] pry(main)>
|
183
|
+
[1] pry(main)> require "yaml"
|
184
|
+
=> true
|
185
|
+
[2] pry(main)> GoogleApis.connect YAML.load_file("config/google-apis.yml")
|
175
186
|
=> #<GoogleApis::Connection:0x007ffe0aa95d70 [lorem@developer.gserviceaccount.com]>
|
176
|
-
[2] pry(main)> Google::Drive.connect
|
177
|
-
=> #<Google::Drive:0x007fcfec1265b0 v2:[about,apps,changes,channels,children,comments,files,parents,permissions,properties,realtime,replies,revisions] {}>
|
178
187
|
[3] pry(main)> Google::Drive.files.list
|
179
188
|
=> {"kind"=>"drive#fileList",
|
180
189
|
...
|
181
|
-
[4] pry(main)> Google::BigQuery.
|
190
|
+
[4] pry(main)> Google::BigQuery.connection
|
182
191
|
=> #<Google::BigQuery:0x007ffe0b1fb240 v2:[datasets,jobs,projects,tabledata,tables] {projectId:"your_project_id",datasetId:"your_dataset_id"}>
|
183
192
|
[5] pry(main)> Google::BigQuery.tables.list
|
184
193
|
=> {"kind"=>"bigquery#tableList",
|
185
194
|
...
|
195
|
+
[6] pry(main)> Google::Storage.objects.list :prefix => "path/to/your/file/awesome.txt"
|
196
|
+
=> {"kind"=>"storage#objects",
|
186
197
|
```
|
187
198
|
|
188
199
|
### Using the console
|
@@ -193,7 +204,7 @@ Run the following command in your console:
|
|
193
204
|
|
194
205
|
```ruby
|
195
206
|
$ script/console
|
196
|
-
Loading Google APIs development environment (0.1.
|
207
|
+
Loading Google APIs development environment (0.1.4)
|
197
208
|
[1] pry(main)> GoogleApis.connect :email_address => "", :private_key => "/path/to/private/key.p12"
|
198
209
|
=> #<GoogleApis::Connection:0x007ff3d356cbf0 [lorem@developer.gserviceaccount.com]>
|
199
210
|
[2] pry(main)> bq = Google::BigQuery.new :project_id => "your_project_id", :dataset_id => "your_dataset_id"
|
@@ -206,14 +217,16 @@ You can also define `script/config.yml` containing the connection config:
|
|
206
217
|
---
|
207
218
|
email_address: lorem@developer.gserviceaccount.com
|
208
219
|
private_key: "/path/to/private/key.p12"
|
220
|
+
project_id: your_project_id
|
221
|
+
dataset_id: your_dataset_id
|
209
222
|
```
|
210
223
|
|
211
224
|
And immediately start instantiating a Google API:
|
212
225
|
|
213
226
|
```ruby
|
214
227
|
$ script/console
|
215
|
-
Loading Google APIs development environment (0.1.
|
216
|
-
[1] pry(main)>
|
228
|
+
Loading Google APIs development environment (0.1.4)
|
229
|
+
[1] pry(main)> Google::BigQuery.connection
|
217
230
|
=> #<Google::BigQuery:0x007fa6c9cc3450 v2:[datasets,jobs,projects,tabledata,tables] {projectId:"your_project_id",datasetId:"your_dataset_id"}>
|
218
231
|
```
|
219
232
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/google_apis.rb
CHANGED
@@ -10,7 +10,12 @@ module GoogleApis
|
|
10
10
|
class Error < StandardError; end
|
11
11
|
|
12
12
|
def self.connect(options)
|
13
|
-
@
|
13
|
+
@config = options.symbolize_keys
|
14
|
+
@connection = Connection.new config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.config
|
18
|
+
@config || {}
|
14
19
|
end
|
15
20
|
|
16
21
|
def self.connection
|
@@ -27,12 +27,20 @@ module GoogleApis
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def default_parameters(*keys)
|
31
|
+
if keys.any?
|
32
|
+
@default_parameters = keys
|
33
|
+
else
|
34
|
+
@default_parameters || []
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
def connect(options = {})
|
31
39
|
@instance = new(options)
|
32
40
|
end
|
33
41
|
|
34
42
|
def instance
|
35
|
-
@instance
|
43
|
+
@instance || (connect if GoogleApis.connection)
|
36
44
|
end
|
37
45
|
|
38
46
|
def connection
|
@@ -6,14 +6,15 @@ module GoogleApis
|
|
6
6
|
attr_accessor :connection, :discovered_api
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
|
-
|
9
|
+
config, params = options.symbolize_keys.partition{|(k, v)| [:email_address, :private_key].include?(k)}.collect{|x| Hash[x]}
|
10
10
|
|
11
|
-
|
12
|
-
@connection = config ? GoogleApis::Connection.new(config) : GoogleApis.connection
|
11
|
+
@connection = config.empty? ? GoogleApis.connection : GoogleApis::Connection.new(config)
|
13
12
|
raise Error, "Please ensure a Google API connection" unless @connection
|
14
13
|
|
14
|
+
params = GoogleApis.config.merge(params).inject({}){|h, (k, v)| h[k.to_s.gsub(/_(.)/){$1.upcase}.to_sym] = v if v; h}
|
15
|
+
|
15
16
|
@discovered_api = connection.discover_api self.class.api, self.class.version
|
16
|
-
@default_params =
|
17
|
+
@default_params = params.select{|k, v| self.class.default_parameters.include?(k)}
|
17
18
|
end
|
18
19
|
|
19
20
|
def execute(api_method, *params)
|
data/lib/google_apis/version.rb
CHANGED
@@ -22,6 +22,12 @@ module Unit
|
|
22
22
|
assert_equal "https://www.googleapis.com/auth/bigquery", GoogleApis::Api::BigQuery.auth_scope
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe ".default_parameters" do
|
27
|
+
it "returns the default API parameters" do
|
28
|
+
assert_equal [:projectId, :datasetId], GoogleApis::Api::BigQuery.default_parameters
|
29
|
+
end
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-apis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Engel
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.2.2
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: A thin layer on top of Google::APIClient (google-api-client) for a more intuitive
|