google-directory 0.0.2 → 0.0.3

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: d9417c85363cbdc8ced42e39d32e8e49f3845e03
4
- data.tar.gz: 8b56b71c57f1d9a93d5399012ee70297e8135fd2
3
+ metadata.gz: 31dd3d1b04d40d4b86f41f51811ff1b04b5ce090
4
+ data.tar.gz: a96170d567eb79df73a110431dc92a9cd490b341
5
5
  SHA512:
6
- metadata.gz: b419f61c90f0c1ea03e6629eeeedcf9b04ba0d43a3142dc86a3115670cc3d5e74194d030aa474fea82ffdd0bb7e684e9a2aea1d2809491efeec7b16df0e626ba
7
- data.tar.gz: 1293a889bf8c3fc5ef28acea9d66f8f7403bf6729d0f9b021561dacf8716f8fef133a7e5dd32ca134ec5d0a1848e91be567e85f12254858540494c5b7a994b5b
6
+ metadata.gz: 0e40b022c65cfd68efe99c77539eeb74e1a8a6a9228de041628884154a2dd6e5c02f25d0995cd604f1d322967f6cd93f618b49aacaadb10770dc1cea2349f446
7
+ data.tar.gz: 4cd5d284c3cf4eb2065a1a02c60ca900c2a2e9c83353c78297e8ae941e630cf84054739d5097a9d1f58fe80957ec6c458b4e8dbcfc330f64928078216b5dc1a9
@@ -0,0 +1,10 @@
1
+ ._*
2
+ .DS_Store
3
+ .bundle
4
+ .rvmrc
5
+ *.log
6
+
7
+ test/*
8
+ pkg/*
9
+
10
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in google_directory.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem 'byebug', group: [:development, :test]
@@ -0,0 +1,101 @@
1
+ # Google Directory API
2
+
3
+ ## Description
4
+
5
+ Simple Google Directory API wrapper for Ruby on Rails.
6
+ This relies on the [Google API Ruby Client](https://github.com/Omac/google-directory.git).
7
+
8
+ ## Install
9
+
10
+ Add the gem to the Gemfile
11
+
12
+ ```ruby
13
+ gem 'google-directory'
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ First configure your API in `initializers/google_directory.rb`
19
+
20
+ ``` ruby
21
+ GoogleDirectory.configure do
22
+
23
+ use_yaml Rails.root.join('config', 'google_directory.yaml')
24
+
25
+ admin_email 'admin@domain.com'
26
+
27
+ key_file Rails.root.join('config', 'keys', 'private_key.p12')
28
+
29
+ key_passphrase 'notasecret'
30
+
31
+ issuer 'xxxxxxx@developer.gserviceaccount.com'
32
+
33
+ end
34
+ ```
35
+
36
+ Using YAML as the Token Store will create a file with the access tokens. The gem will refresh the token automatically when after they expire and it will rewrite the new access token to the YAML file. Producing something like this:
37
+
38
+ ``` yaml
39
+ development:
40
+ scope:
41
+ token_type: Bearer
42
+ issued_at: ISSUED_DATE
43
+ access_token: ACCESS_TOKEN
44
+ expires_in: 3600
45
+ ```
46
+
47
+ ### Multiple Google API access tokens using scopes
48
+
49
+ Specify a scope in the configuration `initializers/google_directory.rb`.
50
+
51
+ ``` ruby
52
+ GoogleDirectory.configure do
53
+
54
+ use_yaml Rails.root.join('config', 'google_directory.yaml')
55
+
56
+ scope :domain_one do
57
+ admin_email 'admin@domain_one.com'
58
+ # [...]
59
+ end
60
+
61
+ scope :domain_two do
62
+ admin_email 'admin@domain_two.com'
63
+ # [...]
64
+ end
65
+
66
+ end
67
+ ```
68
+ Keep in mind that the Token Store will be the same for all the scopes configured.
69
+
70
+ ## Usage
71
+ ``` ruby
72
+ google = GoogleDirectory::Client.new
73
+
74
+ google.find_users
75
+
76
+ google.create_user(email, "given_name", "family_name", "password")
77
+
78
+ google.update_user(email, update_data)
79
+
80
+ google.delete_user(email)
81
+
82
+ google.update_user_password(email, new_password)
83
+
84
+ ```
85
+
86
+ ### Multiple Scopes
87
+
88
+ ``` ruby
89
+ domain_one = GoogleDirectory::Client.new(:domain_one)
90
+ domain_one.find_users
91
+
92
+ domain_two = GoogleDirectory::Client.new(:domain_two)
93
+ domain_two.find_users
94
+ ```
95
+
96
+ ## TO DO
97
+
98
+ * `use_active_model` for database token store.
99
+ * Build the configuration generator.
100
+ * Implement more parameters from the Google API.
101
+ * Testing.
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "google-directory/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "google-directory"
9
+ s.version = GoogleDirectory::VERSION
10
+ s.authors = ["Omar Osorio"]
11
+ s.email = ["omar@kioru.com"]
12
+ s.homepage = "https://github.com/Omac/google-directory"
13
+ s.summary = "Simple Google Directory API client wrapper for Rails"
14
+ s.description = "Relying on the Google Ruby API gem you are able to set up a Rails project for consuming the Directory API (or the Admin SDK). Even multiple domain access is allowed using scopes."
15
+ s.license = "MIT"
16
+
17
+ s.files = `git ls-files`.split("\n") # Dir["{app,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
18
+ s.test_files = Dir["test/**/*"]
19
+ s.require_paths = ['lib']
20
+
21
+ s.add_dependency 'google-api-client', '~> 0.8'
22
+
23
+ s.add_development_dependency 'rails', '~> 4.2'
24
+ s.add_development_dependency "sqlite3"
25
+ end
@@ -26,7 +26,7 @@ module GoogleDirectory
26
26
 
27
27
  if token = @config.load_token
28
28
 
29
- token[:issued_at] = DateTime.parse( token[:issued_at] )
29
+ token['issued_at'] = DateTime.parse( token['issued_at'] )
30
30
  @client.authorization.update_token!(token)
31
31
 
32
32
  else
@@ -43,7 +43,7 @@ module GoogleDirectory
43
43
  # access_token:
44
44
  # expires_in:
45
45
  def save_token(token_hash)
46
- token_hash = token_hash.slice(:token_type, :issued_at, :access_token, :expires_in)
46
+ token_hash = token_hash.slice('token_type', 'issued_at', 'access_token', 'expires_in')
47
47
  @token_store and @token_store.save(@scope_name, token_hash)
48
48
  end
49
49
 
@@ -118,12 +118,12 @@ module GoogleDirectory
118
118
 
119
119
  def save( scope_name, token_hash )
120
120
  data = (@yaml_data[Rails.env.to_s] ||= {})
121
- data[scope_name.to_s] = token_hash.stringify_keys
121
+ data[scope_name.to_s] = token_hash
122
122
  File.open(@yaml_file, 'w') { |file| file.write( YAML::dump(@yaml_data) ) }
123
123
  end
124
124
 
125
125
  def load( scope_name )
126
- data = @yaml_data[Rails.env.to_s] and data = data[scope_name.to_s] and data.symbolize_keys.slice(:token_type, :issued_at, :access_token, :expires_in)
126
+ data = @yaml_data[Rails.env.to_s] and data = data[scope_name.to_s] and data.slice('token_type', 'issued_at', 'access_token', 'expires_in')
127
127
  end
128
128
 
129
129
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleDirectory
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-directory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar Osorio
@@ -61,11 +61,15 @@ executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
+ - ".gitignore"
65
+ - Gemfile
64
66
  - MIT-LICENSE
67
+ - README.md
65
68
  - Rakefile
69
+ - google-directory.gemspec
70
+ - lib/google-directory.rb
66
71
  - lib/google-directory/config.rb
67
72
  - lib/google-directory/version.rb
68
- - lib/google_directory.rb
69
73
  - lib/tasks/google-directory_tasks.rake
70
74
  - test/dummy/README.rdoc
71
75
  - test/dummy/Rakefile