google-api-rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +37 -0
- data/Rakefile +9 -0
- data/lib/google-api-rails.rb +34 -0
- data/lib/google_api/rails/exception.rb +13 -0
- data/lib/google_api/rails/exception/bad_application_name.rb +9 -0
- data/lib/google_api/rails/exception/bad_application_version.rb +9 -0
- data/lib/google_api/rails/exception/bad_client_id.rb +9 -0
- data/lib/google_api/rails/exception/bad_client_secret.rb +9 -0
- data/lib/google_api/rails/version.rb +5 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e09053f9b1aecf97a23956ce59092a10a7f9c71
|
4
|
+
data.tar.gz: 3b2ae977add541f3d0f7aa883ab43ee7e5fa9318
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d616ffe5853c9e8299e632e01d6839e1d60dddb0ef3adc364bcc692191e63a90b3ef2b5feac87fc3fa1bd023ffb71636789a5e6f12ba140ecee1a37f71adf7d3
|
7
|
+
data.tar.gz: c22759a282f0241b4064634927a553257229efee3c1557496e1c65487d46f75d9c134f4c699c1308ea1c25c547da44dbd512ff34dfe41bca6b8c60d650a64c8f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Drew Butler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Google API Wrapper for Ruby on Rails [![](https://travis-ci.org/dbtlr/google-api-rails.png)](https://travis-ci.org/dbtlr/google-api-rails)
|
2
|
+
|
3
|
+
This wraps the official [Google Ruby API client](https://github.com/google/google-api-ruby-client). All documentation for interacting with the actual client can be found there.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem install google-api-rails
|
11
|
+
```
|
12
|
+
|
13
|
+
Create an initializer, for instance google-api-rails.rb with the following:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
GoogleApi.config do |config|
|
17
|
+
config.client_id = "<Your Google API Client Id"
|
18
|
+
config.client_secret = "<Your Application Secret>"
|
19
|
+
config.application_name = "<Your Application Name>"
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
## Getting Started
|
24
|
+
|
25
|
+
To use the Ruby API client, simple access it through the wrapper like so:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Make an API call
|
29
|
+
result = client.execute(
|
30
|
+
:api_method => plus.activities.list,
|
31
|
+
:parameters => {'collection' => 'public', 'userId' => 'me'}
|
32
|
+
)
|
33
|
+
```
|
34
|
+
|
35
|
+
## About This Gem
|
36
|
+
|
37
|
+
I wrote this simply to have the convenience of keeping my Google API config in an initializer, instead of all over my apps. If you know of a better way or see something I missed, feel free to submit an issue or pull request.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support/all'
|
3
|
+
require 'google/api_client'
|
4
|
+
require 'google_api/rails/exception'
|
5
|
+
|
6
|
+
module GoogleApi
|
7
|
+
mattr_accessor :client
|
8
|
+
@@client = ""
|
9
|
+
mattr_accessor :client_id
|
10
|
+
@@client_id = ""
|
11
|
+
mattr_accessor :client_secret
|
12
|
+
@@client_secret = ""
|
13
|
+
mattr_accessor :application_name
|
14
|
+
@@application_name = ""
|
15
|
+
mattr_accessor :application_version
|
16
|
+
@@application_version = ""
|
17
|
+
mattr_accessor :redirect_uri
|
18
|
+
@@redirect_uri = ""
|
19
|
+
mattr_accessor :scope
|
20
|
+
@@scope = ""
|
21
|
+
|
22
|
+
def self.config
|
23
|
+
yield self
|
24
|
+
raise Rails::Exception::BadClientId.new if @@client_id.nil? || @@client_id.empty?
|
25
|
+
raise Rails::Exception::BadClientSecret.new if @@client_secret.nil? || @@client_secret.empty?
|
26
|
+
raise Rails::Exception::BadApplicationName.new if @@application_name.nil? || @@application_name.empty?
|
27
|
+
|
28
|
+
@@client = Google::APIClient.new(:application_name => @@application_name, :application_version => @@application_version)
|
29
|
+
@@client.authorization.client_id = @@client_id
|
30
|
+
@@client.authorization.client_secret = @@client_secret
|
31
|
+
@@client.authorization.redirect_uri = @@redirect_uri unless @@redirect_uri.empty? || @@redirect_uri.empty?
|
32
|
+
@@client.authorization.scope = @@scope unless @@scope.empty? || @@scope.nil?
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module GoogleApi
|
2
|
+
module Rails
|
3
|
+
module Exception
|
4
|
+
class Base < ::Exception
|
5
|
+
def initialize query = nil, message = ""
|
6
|
+
message = "[query=#{query.inspect}] #{message}" if !query.nil?
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
Dir[File.expand_path('../exception/', __FILE__)+'/*.rb'].each {|file| require(file) }
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-api-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dbtlr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n
|
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: google-api-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.0.0
|
83
|
+
description: This gem is a Rails interface for the official Google API gem.
|
84
|
+
email:
|
85
|
+
- hi@dbtlr.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/google-api-rails.rb
|
91
|
+
- lib/google_api/rails/exception/bad_application_name.rb
|
92
|
+
- lib/google_api/rails/exception/bad_application_version.rb
|
93
|
+
- lib/google_api/rails/exception/bad_client_id.rb
|
94
|
+
- lib/google_api/rails/exception/bad_client_secret.rb
|
95
|
+
- lib/google_api/rails/exception.rb
|
96
|
+
- lib/google_api/rails/version.rb
|
97
|
+
- MIT-LICENSE
|
98
|
+
- Rakefile
|
99
|
+
- README.md
|
100
|
+
homepage: http://dbtlr.com
|
101
|
+
licenses: []
|
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.0
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: This gem is a Rails interface for the official Google API gem.
|
123
|
+
test_files: []
|