activeresource-google_spreadsheets 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b995e5457991666c29e03f231f6380215ecf66ed
4
- data.tar.gz: 47788f07574dd25d260d70a085358d3ac5ae324b
3
+ metadata.gz: f0cf560b7e1ad86a01a4da5fa90b21a87be23345
4
+ data.tar.gz: a263c4f30a55a6ae8998f36fa7eea38dc2e82ce1
5
5
  SHA512:
6
- metadata.gz: 199f57e9fea57908b1f0bdbbcdb3aeb91577dc008b478cb52c1e28c97003fdc5cace92dfab95a4704b50fccfb4d2c9d87baef1969e0f5ff6627808de49a8ee6a
7
- data.tar.gz: 51cdfbdb99e66806b4952556538e384cd98c5d4107fa55e7d32680d44f11708852367e989aecd8d09793d70cad9ca230635087ae7b7ba43e49cb62dc38c449a4
6
+ metadata.gz: c31d3c6496c981452ce5de604c884ff6d4df5698db719bf448a8aac70e700a58495ad7e940b01f1ef361a2b245942941a74a46a932d7ea764051095bc45009aa
7
+ data.tar.gz: 7b1bf3cb53c7beb94d49b73abf841dbf3ad9b93b8773b134d645c6a604e60918b171c24e114b31d72c4bd12d8b431cf4a639482aaa5f661a35d20537ddb4e954
data/README.md CHANGED
@@ -22,6 +22,32 @@ Or install it yourself as:
22
22
 
23
23
  http://webos-goodies.jp/archives/active_resource_google_spreadsheets_data_api.html
24
24
 
25
+ ### Authorization example (Service Account)
26
+
27
+ #### 1. Using JSON key file
28
+
29
+ in `config/initializers/google_spreadsheet.rb`
30
+
31
+ ```ruby
32
+ GoogleSpreadsheets::Base.auth_type = :bearer
33
+ GoogleSpreadsheets::Base.access_token =
34
+ GoogleSpreadsheets::Auth::ServiceAccountsAccessToken.new(
35
+ json_key_io: File.open('/path/to/service_account_json_key.json')
36
+ )
37
+ ```
38
+
39
+ #### 2. Using client email & private key
40
+
41
+ in `config/initializers/google_spreadsheet.rb`
42
+
43
+ ```ruby
44
+ GoogleSpreadsheets::Base.auth_type = :bearer
45
+ GoogleSpreadsheets::Base.access_token =
46
+ GoogleSpreadsheets::Auth::ServiceAccountsAccessToken.new
47
+ ```
48
+ and set the values to `ENV['GOOGLE_CLIENT_EMAIL']` & `ENV['GOOGLE_PRIVATE_KEY']`
49
+
50
+
25
51
  ### ActiveRecord Syncing Feature (Experimental)
26
52
 
27
53
  http://qiita.com/tkawa/items/04fc6f0574122d4a3fd2
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'activeresource', '~> 4.1.0'
21
+ spec.add_dependency 'activeresource', '>= 4.1.0'
22
22
  spec.add_dependency 'activesupport'
23
- spec.add_dependency 'google-api-client', '~> 0.8.6'
23
+ spec.add_dependency 'googleauth'
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "rake"
@@ -1,34 +1,17 @@
1
- require 'google/api_client'
2
- require 'openssl'
1
+ require 'googleauth'
3
2
 
4
3
  module GoogleSpreadsheets
5
4
  module Auth
6
5
  class ServiceAccountsAccessToken
7
6
  def initialize(options = {})
8
- @options = options.reverse_merge(
9
- application_name: 'Ruby',
10
- token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
11
- audience: 'https://accounts.google.com/o/oauth2/token',
12
- scope: 'https://spreadsheets.google.com/feeds/'
13
- )
7
+ @options = options
8
+ @options[:scope] ||= 'https://spreadsheets.google.com/feeds/'
14
9
  end
15
10
 
16
11
  def call(connection)
17
- # cf. http://d.hatena.ne.jp/sugyan/20130112/1357996092
18
- @client ||= Google::APIClient.new(application_name: @options[:application_name]).tap do |c|
19
- c.authorization = Signet::OAuth2::Client.new(
20
- token_credential_uri: @options[:token_credential_uri],
21
- audience: @options[:audience],
22
- scope: @options[:scope],
23
- issuer: @options[:client_email],
24
- signing_key: OpenSSL::PKey::RSA.new(@options[:private_key_pem])
25
- )
26
- c.authorization.fetch_access_token!
27
- end
28
- if @client.authorization.expired?
29
- @client.authorization.refresh!
30
- end
31
- @client.authorization.access_token
12
+ @authorizer ||= Google::Auth::ServiceAccountCredentials.make_creds(@options)
13
+ @authorizer.refresh! if @authorizer.expires_at.nil? || @authorizer.expired?
14
+ @authorizer.access_token
32
15
  end
33
16
  end
34
17
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleSpreadsheets
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource-google_spreadsheets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chihiro Ito
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-02 00:00:00.000000000 Z
12
+ date: 2017-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: 4.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: 4.1.0
28
28
  - !ruby/object:Gem::Dependency
@@ -40,19 +40,19 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: google-api-client
43
+ name: googleauth
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 0.8.6
48
+ version: '0'
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
- version: 0.8.6
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -135,8 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.5.1
138
+ rubygems_version: 2.6.14
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Google Spreadsheets accessor with ActiveResource
142
142
  test_files: []
143
+ has_rdoc: