kura 0.2.13 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82e2481d7711b622ffa903f7f84d177bc4ef04f0
4
- data.tar.gz: e8477315ada88d49725defb1693dcca1e96f8dca
3
+ metadata.gz: 9b64ff84a51c177c7078f13079919a2bec0d8464
4
+ data.tar.gz: 88b2d75fdb959d40df5b15a1eb73da354b52dda5
5
5
  SHA512:
6
- metadata.gz: 2df39ba623737489a4ec5b56d1619b8130d7d31d59240870c32f8d79a51655df3642ef53c1c1524c0394566aae78ec9250e647a438655c615d1368c046582282
7
- data.tar.gz: 2a31ad9a0afc7b87259d673c48de48b35c543c2ff1ed514c6ecce603497fb274037653ccc6903048b7657ae584151076c1570b17c05beae55fb485b53962c409
6
+ metadata.gz: 6834749b6739a47912c0c5eccbafcda5bb99ae12236795f136c73a1ffdd31c927b0c108a1548f30461f43a815842ccc7b05d28ee40a0dc54827b4ff7dded258d
7
+ data.tar.gz: 2ec1fd38e3a700092c551f6f32e5b1a9fc822081e889b05567ed8d90c3c06a3a9a03e632bdd9a4a40d765a34c93e7acad7d7d7bff8a6021fb3c80cccadcc75d1
data/ChangeLog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.2.14
2
+
3
+ ## Enhancements
4
+
5
+ * Kura.client now accept JSON key file.
6
+
1
7
  # 0.2.13
2
8
 
3
9
  ## Enhancements
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
- obj = JSON.parse(File.binread(service_account_json))
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
@@ -1,3 +1,3 @@
1
1
  module Kura
2
- VERSION = "0.2.13"
2
+ VERSION = "0.2.14"
3
3
  end
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.13
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-13 00:00:00.000000000 Z
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