google-directory 0.0.3 → 0.0.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/.gitignore +1 -0
- data/README.md +8 -5
- data/lib/google-directory.rb +2 -2
- data/lib/google-directory/config.rb +11 -1
- data/lib/google-directory/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 318472d19433eeb4cc36a64d59d6f64af06f3d25
|
4
|
+
data.tar.gz: 8839b1d534940f0ab3c479259651674d3a8a917a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c5f9a0ad231267f607737a36a8c2a7528f28f1307060b4400a0e9ba4fcec53db40988c3ba3ccd3d5ec1bc158cb10675a2980e22951d9e6d6ab144eac54c91cd
|
7
|
+
data.tar.gz: 9de6daf97deb0bd429873efac799bf5d0ad9a894f024d1a564a467eec5403255652d6d2c2cebeede9b585dd46e10f91e54e4f7e31ea92ee85f7c5fafd82b0df8
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -19,17 +19,20 @@ First configure your API in `initializers/google_directory.rb`
|
|
19
19
|
|
20
20
|
``` ruby
|
21
21
|
GoogleDirectory.configure do
|
22
|
-
|
22
|
+
|
23
|
+
# Optional Token Store
|
23
24
|
use_yaml Rails.root.join('config', 'google_directory.yaml')
|
24
25
|
|
26
|
+
# Required
|
25
27
|
admin_email 'admin@domain.com'
|
26
|
-
|
27
28
|
key_file Rails.root.join('config', 'keys', 'private_key.p12')
|
28
|
-
|
29
29
|
key_passphrase 'notasecret'
|
30
|
-
|
31
30
|
issuer 'xxxxxxx@developer.gserviceaccount.com'
|
32
31
|
|
32
|
+
# Optional attributes
|
33
|
+
application_name 'My Application'
|
34
|
+
application_version '1.0.0'
|
35
|
+
|
33
36
|
end
|
34
37
|
```
|
35
38
|
|
@@ -50,7 +53,7 @@ Specify a scope in the configuration `initializers/google_directory.rb`.
|
|
50
53
|
|
51
54
|
``` ruby
|
52
55
|
GoogleDirectory.configure do
|
53
|
-
|
56
|
+
|
54
57
|
use_yaml Rails.root.join('config', 'google_directory.yaml')
|
55
58
|
|
56
59
|
scope :domain_one do
|
data/lib/google-directory.rb
CHANGED
@@ -13,7 +13,7 @@ module GoogleDirectory
|
|
13
13
|
|
14
14
|
|
15
15
|
@key = Google::APIClient::KeyUtils.load_from_pkcs12(@config.key_file, @config.key_passphrase)
|
16
|
-
@client = Google::APIClient.new(:application_name =>
|
16
|
+
@client = Google::APIClient.new(:application_name => @config.application_name, :application_version => @config.application_version )
|
17
17
|
|
18
18
|
@client.authorization = Signet::OAuth2::Client.new(
|
19
19
|
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
|
@@ -26,7 +26,7 @@ module GoogleDirectory
|
|
26
26
|
|
27
27
|
if token = @config.load_token
|
28
28
|
|
29
|
-
token['issued_at'] =
|
29
|
+
token['issued_at'] = Time.parse( token['issued_at'] )
|
30
30
|
@client.authorization.update_token!(token)
|
31
31
|
|
32
32
|
else
|
@@ -26,10 +26,12 @@ module GoogleDirectory
|
|
26
26
|
|
27
27
|
class Config
|
28
28
|
|
29
|
-
attr_reader :admin_email, :key_passphrase, :issuer, :key_file, :scope_name
|
29
|
+
attr_reader :admin_email, :key_passphrase, :issuer, :key_file, :scope_name, :application_version, :application_name
|
30
30
|
|
31
31
|
def initialize(scope_name = :main)
|
32
32
|
@scope_name = scope_name
|
33
|
+
@application_name = 'Google Directory API'
|
34
|
+
@application_version = GoogleDirectory::VERSION
|
33
35
|
end
|
34
36
|
|
35
37
|
def using(scope)
|
@@ -92,6 +94,14 @@ module GoogleDirectory
|
|
92
94
|
@current_config.instance_variable_set('@issuer', issuer)
|
93
95
|
end
|
94
96
|
|
97
|
+
def application_name( application_name )
|
98
|
+
@current_config.instance_variable_set('@application_name', application_name)
|
99
|
+
end
|
100
|
+
|
101
|
+
def application_version( application_version )
|
102
|
+
@current_config.instance_variable_set('@application_version', application_version)
|
103
|
+
end
|
104
|
+
|
95
105
|
def scope( scope_name, &block )
|
96
106
|
scopes = @config.instance_variable_get('@scopes')
|
97
107
|
scopes[scope_name] = @current_config = Config.new(scope_name)
|