google_sdk 0.1.3 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5878baa157ce846d9a368811c503b8b9900aacc1
4
- data.tar.gz: 5bbe17ecb755e0a4550bbc9910b1e83e60a703cb
3
+ metadata.gz: f28ba694753c24d2853b48463c5b04f910b1b16e
4
+ data.tar.gz: 5fc791d4a738e21106b339a5937209032ed85aca
5
5
  SHA512:
6
- metadata.gz: acc90340067f93a4121a64d3ddb585dc0a9a425d3267ecf42a52dbb64e9a1dabbc88c45e87cd857e6be8252ab21d517a6ff540e50d2f3f95fa1a511709ffb3f3
7
- data.tar.gz: bf00e1e3fe0b2dc1e49beb07604654000111a5ed4f0494b88469d109ec7dadc7ddf0f0dd958740f0d412b0469821877b44caf27ae9367fc2684fd194b8f55718
6
+ metadata.gz: 42443627ad5e833c755b5476d806c049e3d3c325a2c8d7ccb46ed6d395aa9a2c36a1edc3614cc12c036cda431d3bd47019500239d908ca1c12de6450ce8143bf
7
+ data.tar.gz: 76209c398058a8219e8e488e55b604273318f58bc308273f7de396cfffde25322c9aaa0a52471e13de0219adf99568e6f517437520eb335972c6fe49d2f0cab5
@@ -0,0 +1,59 @@
1
+ # coding: utf-8
2
+
3
+ module GoogleSdk
4
+ module API
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ base.instance_variable_set "@default_options", {}
8
+ base.send :google_uri, "https://www.googleapis.com"
9
+ base.send :attr_accessor, :default_options
10
+ end
11
+
12
+ module ClassMethods
13
+ def default_options
14
+ @default_options
15
+ end
16
+
17
+ def google_uri(value)
18
+ default_options[:google_uri] = value
19
+ end
20
+
21
+ def base_uri(value)
22
+ default_options[:base_uri] = value
23
+ end
24
+
25
+ def request_url(id=nil)
26
+ if id.nil?
27
+ default_options[:google_uri] + default_options[:base_uri]
28
+ else
29
+ default_options[:google_uri] + default_options[:base_uri] + "/" + id
30
+ end
31
+ end
32
+
33
+ def index(headers={}, &block)
34
+ RestClient.get(request_url, headers, &block)
35
+ end
36
+
37
+ def show(id=nil, headers={}, &block)
38
+ RestClient.get(request_url(id), headers, &block)
39
+ end
40
+
41
+ def post(payload, headers={}, &block)
42
+ RestClient.post(request_url, payload, headers, &block)
43
+ end
44
+
45
+ def put(id, payload, headers={}, &block)
46
+ RestClient.put(request_url(id), payload, headers, &block)
47
+ end
48
+
49
+ def patch(id, payload, headers={}, &block)
50
+ RestClient.put(request_url(id), payload, headers, &block)
51
+ end
52
+
53
+ def delete(id, headers={}, &block)
54
+ RestClient.delete(request_url(id), headers, &block)
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,66 @@
1
+ # coding: utf-8
2
+
3
+ ##
4
+ # google glass api 基础类
5
+ module GoogleSdk
6
+
7
+ # 用户认证基类
8
+ module OAuth
9
+
10
+ def self.included(base)
11
+ base.extend ClassMethods
12
+ base.instance_variable_set "@default_options", {}
13
+ base.send :google_uri, "https://accounts.google.com"
14
+ base.send :attr_accessor, :default_options
15
+ end
16
+
17
+ class ClassMethods
18
+
19
+ def default_options
20
+ @default_options
21
+ end
22
+
23
+ def client_id(value)
24
+ default_options[:params][:client_id] = value
25
+ end
26
+
27
+ def client_secret(value)
28
+ default_options[:params][:client_secret] = value
29
+ end
30
+
31
+ def scope(value)
32
+ default_options[:params][:scope] = value.join('+')
33
+ end
34
+
35
+ def access_type(value)
36
+ default_options[:params][:access_type] = value
37
+ end
38
+
39
+ def approval_prompt(value)
40
+ default_options[:params][:approval_prompt] = value
41
+ end
42
+
43
+ def redirect_uri(value)
44
+ default_options[:params][:redirect_uri] = value
45
+ end
46
+
47
+ def login_url
48
+ params = []
49
+ default_options[:params].each {|key, value| params << "#{key}=#{value}"}
50
+ return "#{default_options[:google_uri]}/o/oauth2/auth?#{params.join("&")}"
51
+ end
52
+
53
+ def user_token(code)
54
+ RestClient.post "#{default_options[:google_uri]}/o/oauth2/token", {
55
+ code: code,
56
+ client_id: default_options[:params][:client_id],
57
+ client_secret: default_options[:params][:client_secret],
58
+ redirect_uri: default_options[:params][:redirect_uri],
59
+ grant_type: 'authorization_code'
60
+ }
61
+ end
62
+
63
+
64
+ end
65
+ end
66
+ end
@@ -1,3 +1,3 @@
1
1
  module GoogleSdk
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mj
@@ -45,14 +45,11 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
49
- - Gemfile
50
- - LICENSE.txt
51
- - README.md
52
- - Rakefile
53
- - google_sdk.gemspec
54
- - lib/google_sdk.rb
48
+ - lib/google_sdk/base.rb
49
+ - lib/google_sdk/oauth.rb
55
50
  - lib/google_sdk/version.rb
51
+ - lib/google_sdk.rb
52
+ - Rakefile
56
53
  homepage: ''
57
54
  licenses:
58
55
  - MIT
@@ -61,7 +58,6 @@ post_install_message:
61
58
  rdoc_options: []
62
59
  require_paths:
63
60
  - lib
64
- - '{app,config,db,lib}/**/*'
65
61
  required_ruby_version: !ruby/object:Gem::Requirement
66
62
  requirements:
67
63
  - - '>='
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in google_sdk.gemspec
4
- gemspec
5
-
6
- gem 'rest-client'
7
-
8
- group :development do
9
- gem 'pry'
10
- end
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 mj
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 DELETED
@@ -1,29 +0,0 @@
1
- # GoogleSdk
2
-
3
- 一个简答的google api sdk
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'google_sdk'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install google_sdk
18
-
19
- ## Usage
20
-
21
-
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
data/google_sdk.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'google_sdk/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "google_sdk"
8
- spec.version = GoogleSdk::VERSION
9
- spec.authors = ["mj"]
10
- spec.email = ["tywf91@gmail.com"]
11
- spec.description = %q{google api sdk}
12
- spec.summary = %q{google api sdk}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
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", "{app,config,db,lib}/**/*"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- end