google-api_client-keychain_store 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dcc4cab89e2bc6306128a244ba7c8a0bce1eae1
4
+ data.tar.gz: 2972ede2a57db2fd49d61f0b9ce0b88c9135f8dc
5
+ SHA512:
6
+ metadata.gz: c39f7a67f8175159ab601ed3b71bbf0b9def246ca7af612a98106a5ee063b8e104f9cbfde35b34c0459075902b2ee81213e14e1ecb73c57eff82409b79569c97
7
+ data.tar.gz: ade695b06280b50fd34a6f3cdd3806fc97af5ceac0ec57e6a798f41c0cd6e7040487263db2020bbfa4e9dfadead9383b62e080e515f7b7934a9ede26e5430589
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ test.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in google-api_client-keychain_store.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Genki Sugawara
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Google::APIClient::KeychainStore
2
+
3
+ KeychainStore for [Google API Client](https://github.com/google/google-api-ruby-client).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'google-api_client-keychain_store'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install google-api_client-keychain_store
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ #!/usr/bin/env ruby
25
+
26
+ # see https://github.com/winebarrel/google_drive-persistent_session
27
+ require 'google_drive/persistent_session'
28
+
29
+ require 'google/api_client/keychain_store'
30
+
31
+ GoogleDrive::CredentialStorage.store = Google::APIClient::KeychainStore.new('google_drive-oauth2.json')
32
+
33
+ session = GoogleDrive::PersistentSession.login
34
+
35
+ session.files.each do |file|
36
+ puts file.title
37
+ end
38
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'google/api_client/keychain_store/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'google-api_client-keychain_store'
8
+ spec.version = Google::APIClient::KeychainStore::VERSION
9
+ spec.authors = ['Genki Sugawara']
10
+ spec.email = ['sugawara@cookpad.com']
11
+ spec.summary = %q{KeychainStore for Google API Client.}
12
+ spec.description = %q{KeychainStore for Google API Client.}
13
+ spec.homepage = 'https://github.com/winebarrel/google-api_client-keychain_store'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'google-api-client'
22
+ spec.add_dependency 'ruby-keychain'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'google_drive-persistent_session', '~> 0.1.2'
26
+ end
@@ -0,0 +1,5 @@
1
+ require 'google/api_client'
2
+ require 'keychain'
3
+
4
+ require 'google/api_client/keychain_store/version'
5
+ require 'google/api_client/keychain_store/keychain_store'
@@ -0,0 +1,46 @@
1
+ class Google::APIClient::KeychainStore
2
+ def initialize(service = 'google-api_client-keychain_store')
3
+ @service = service
4
+ end
5
+
6
+ def load_credentials
7
+ credentials ? JSON.parse(credentials) : nil
8
+ rescue JSON::ParserError
9
+ nil
10
+ end
11
+
12
+ def write_credentials(credentials_hash)
13
+ self.credentials = credentials_hash.to_json
14
+ credentials_hash
15
+ end
16
+
17
+ def delete_credentials
18
+ items.where(:service => @service).all.each(&:delete)
19
+ nil
20
+ end
21
+
22
+ private
23
+
24
+ def credentials
25
+ item = items.where(:service => @service).first
26
+ item ? item.password : nil
27
+ end
28
+
29
+ def credentials=(json)
30
+ item = items.where(:service => @service).first
31
+
32
+ if item
33
+ item.password = json
34
+ item.save!
35
+ else
36
+ item = items.create(:service => @service, :account => @service, :password => json)
37
+ end
38
+
39
+ json
40
+ end
41
+
42
+
43
+ def items
44
+ Keychain.default.generic_passwords
45
+ end
46
+ end
@@ -0,0 +1,7 @@
1
+ module Google
2
+ class APIClient
3
+ class KeychainStore
4
+ VERSION = '0.1.0'
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google-api_client-keychain_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Genki Sugawara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-api-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-keychain
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: google_drive-persistent_session
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.1.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.1.2
83
+ description: KeychainStore for Google API Client.
84
+ email:
85
+ - sugawara@cookpad.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - google-api_client-keychain_store.gemspec
96
+ - lib/google/api_client/keychain_store.rb
97
+ - lib/google/api_client/keychain_store/keychain_store.rb
98
+ - lib/google/api_client/keychain_store/version.rb
99
+ homepage: https://github.com/winebarrel/google-api_client-keychain_store
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.0.14
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: KeychainStore for Google API Client.
123
+ test_files: []