kura 0.2.13 → 0.2.14
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.md +6 -0
- data/README.md +5 -0
- data/bin/console +1 -2
- data/lib/kura/version.rb +1 -1
- data/lib/kura.rb +21 -1
- 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: 9b64ff84a51c177c7078f13079919a2bec0d8464
|
4
|
+
data.tar.gz: 88b2d75fdb959d40df5b15a1eb73da354b52dda5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6834749b6739a47912c0c5eccbafcda5bb99ae12236795f136c73a1ffdd31c927b0c108a1548f30461f43a815842ccc7b05d28ee40a0dc54827b4ff7dded258d
|
7
|
+
data.tar.gz: 2ec1fd38e3a700092c551f6f32e5b1a9fc822081e889b05567ed8d90c3c06a3a9a03e632bdd9a4a40d765a34c93e7acad7d7d7bff8a6021fb3c80cccadcc75d1
|
data/ChangeLog.md
CHANGED
data/README.md
CHANGED
@@ -25,8 +25,13 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
```
|
27
27
|
# a. With Service Account Private Key
|
28
|
+
## 1. project ID + email + private key (filepath or contents of .pem format file, or OpenSSL::PKey object)
|
28
29
|
client = Kura.client(project_id, email, private_key)
|
29
30
|
|
31
|
+
## 2. JSON key file downloaded from Google Developers Console.
|
32
|
+
client = Kura.client(json_file_path)
|
33
|
+
client = Kura.client(JSON.parse(File.read(json_file_path)))
|
34
|
+
|
30
35
|
# b. With GCE bigquery scope (Only available on Google Compute Engine instance)
|
31
36
|
client = Kura.client
|
32
37
|
```
|
data/bin/console
CHANGED
@@ -5,8 +5,7 @@ require "kura"
|
|
5
5
|
|
6
6
|
service_account_json = File.expand_path("../../test/data/service_account.json", __FILE__)
|
7
7
|
if File.readable?(service_account_json)
|
8
|
-
|
9
|
-
@client = Kura.client(obj["project_id"], obj["client_email"], obj["private_key"])
|
8
|
+
@client = Kura.client(service_account_json)
|
10
9
|
end
|
11
10
|
|
12
11
|
require "pry"
|
data/lib/kura/version.rb
CHANGED
data/lib/kura.rb
CHANGED
@@ -34,8 +34,28 @@ module Kura
|
|
34
34
|
private_key
|
35
35
|
end
|
36
36
|
|
37
|
+
# == Kura.client
|
38
|
+
# Create Kura::Client object with GCP credential.
|
39
|
+
#
|
40
|
+
# Kura.client(json_key_file)
|
41
|
+
# Kura.client(json_key_hash)
|
42
|
+
# Kura.client(gcp_project_id, email_address, prm_file)
|
43
|
+
# Kura.client(gcp_project_id, email_address, prm_file_contents)
|
44
|
+
# Kura.client(gcp_project_id, email_address, private_key_object)
|
45
|
+
#
|
37
46
|
def self.client(project_id=nil, email_address=nil, private_key=nil, http_options: {timeout: 60})
|
38
|
-
if private_key
|
47
|
+
if email_address.nil? and private_key.nil?
|
48
|
+
if project_id.is_a?(String)
|
49
|
+
credential = JSON.parse(File.binread(project_id))
|
50
|
+
elsif project_id.is_a?(Hash)
|
51
|
+
credential = project_id
|
52
|
+
else
|
53
|
+
raise ArgumentError, "#{self.class.name}.client accept JSON credential file path or decoded Hash object."
|
54
|
+
end
|
55
|
+
project_id = credential["project_id"]
|
56
|
+
email_address = credential["client_email"]
|
57
|
+
private_key = get_private_key(credential["private_key"])
|
58
|
+
elsif private_key
|
39
59
|
private_key = get_private_key(private_key)
|
40
60
|
end
|
41
61
|
self::Client.new(default_project_id: project_id, email_address: email_address, private_key: private_key, http_options: http_options)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chikanaga Tomoyuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|