g_simple_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -0
- data/README.md +11 -9
- data/g_simple_api.gemspec +1 -1
- data/lib/g_simple_api/version.rb +1 -1
- data/spec/g_simple_api/manager_spec.rb +3 -3
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7d125c0b9596779526c7719855fa608ce3067d
|
4
|
+
data.tar.gz: c59717c4b174e277c22227975ea72bb7872cef17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5c6a6e2d78f143f3ece59e037b4b9abea0d51de4ac66054de4ffdc43d783686cd8303ba979ec9d8ec2a0defb46be67d736b13c261a7f7dd166bdf0da606e492
|
7
|
+
data.tar.gz: 3c968c4e8ad024746dad0a0042cdee0904f9b84f3ef08aefd4802261bc607cdc7ae1971fc118c8c0afac51f0d17c4173eaa45b20479b83faefc9518830611827
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/g_simple_api.svg)](http://badge.fury.io/rb/g_simple_api)
|
2
|
+
[![Build Status](https://travis-ci.org/brunomeira/g_simple_api.svg)](https://travis-ci.org/brunomeira/g_simple_api)
|
2
3
|
|
3
4
|
# GSimpleApi
|
4
5
|
|
5
|
-
This gem wraps the calls executed by [
|
6
|
+
This gem wraps the calls executed by [google-api-ruby-client](https://github.com/google/google-api-ruby-client)
|
6
7
|
and makes it simple for you to be authorized and access the data provided by Google's apis.
|
7
8
|
|
8
9
|
## Getting Started
|
@@ -23,7 +24,7 @@ Or install it yourself as:
|
|
23
24
|
|
24
25
|
To use the gem you will need to firstly create a project on [https://console.developers.google.com](https://console.developers.google.com), then allow access to the required apis and for last create a new Client ID.
|
25
26
|
|
26
|
-
After completed the
|
27
|
+
After completed the pre-setting process, you can go back to your app and work on the following steps:
|
27
28
|
|
28
29
|
#### First time use
|
29
30
|
1. Create a *g_simple_api.rb* in /initializers
|
@@ -31,11 +32,11 @@ After completed the presetting process, you can go back to your app and work on
|
|
31
32
|
GSimpleApi.setup do |config|
|
32
33
|
config.name = "test" #The name of your application
|
33
34
|
config.version = "1" #The current version of your application
|
34
|
-
config.api = "
|
35
|
-
config.api_version = "
|
35
|
+
config.api = "drive" #The api that will be used.
|
36
|
+
config.api_version = "v2" #If not specified, it will defaults to v1
|
36
37
|
config.client_id = "XXXXXXXXXXXXXXXX" #Value provided in the Credentials Section.
|
37
38
|
config.client_secret = "XXXXXXXXXXXXXX" #Value provided in the Credentials Section.
|
38
|
-
config.scope = "
|
39
|
+
config.scope = "drive" # The scope(s) required to use the api, it can be an Array.
|
39
40
|
end
|
40
41
|
|
41
42
|
2. You now have to send the user to Google's authorization page. Use:
|
@@ -52,7 +53,7 @@ For further use, You should store the values returned from this call.
|
|
52
53
|
|
53
54
|
4. To make any call to the api, you have to invoke:
|
54
55
|
|
55
|
-
manager.execute("method.name", {key1: "value", key2:"value2"})
|
56
|
+
manager.execute("method.name", {key1: "value", key2:"value2"}) # Example: manager.execute("files.list")
|
56
57
|
where the first parameter is the action that will be executed and the second is any required or optional parameter.
|
57
58
|
|
58
59
|
5. I hope you enjoy it.
|
@@ -61,22 +62,23 @@ where the first parameter is the action that will be executed and the second is
|
|
61
62
|
|
62
63
|
Tokens may expire due a variety of different reasons. If you have stored the user's refresh token then you won't need to ask
|
63
64
|
the users to go through all the acceptance process again (This is true for cases where the users didn't remove access to the app, you didn't change the scope of the app, or etc...). In order to do it so, you only need to call:
|
65
|
+
|
64
66
|
manager = GSimpleApi.process
|
65
67
|
manager.get_token("refresh_token", true) # The second parameter tells the function you are passing a refresh_token
|
66
68
|
|
67
69
|
## Further Reading
|
68
70
|
If you are having trouble to understand the gem or want something more customizable, check the links below:
|
69
71
|
|
70
|
-
1. [
|
72
|
+
1. [google-api-ruby-client](https://github.com/google/google-api-ruby-client) - GSimpleApi is based on this gem. If you need something more complex than get a token and access the api, you should check it out.
|
71
73
|
|
72
74
|
2. [Google OAUTH process](https://developers.google.com/accounts/docs/OAuth2WebServer) If you need more background on how the authorization process works.
|
73
75
|
|
74
|
-
3. [APIs services](https://developers.google.com/
|
76
|
+
3. [APIs services](https://developers.google.com/apis-explorer) - Interesting resource, If you need to know which apis,services and scopes are available.
|
75
77
|
|
76
78
|
## Contributing
|
77
79
|
|
78
80
|
1. Fork it ( https://github.com/brunomeira/g_simple_api/fork )
|
79
81
|
2. Create your feature branch (`git checkout b my-new-feature`)
|
80
82
|
3. Commit your changes (`git commit am 'Add some feature'`)
|
81
|
-
4. Push to the branch (`git push origin
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
84
|
5. Create a new Pull Request
|
data/g_simple_api.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "GSimpleApi makes it easy to access and receive data from google's apis "
|
13
13
|
spec.homepage = "https://github.com/brunomeira/g_simple_api"
|
14
14
|
spec.license = "Apache 2.0"
|
15
|
+
spec.required_ruby_version = '>= 1.9.3'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -26,5 +27,4 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.add_development_dependency "guard"
|
27
28
|
spec.add_development_dependency "guard-rspec"
|
28
29
|
spec.add_development_dependency "pry"
|
29
|
-
spec.add_development_dependency "byebug"
|
30
30
|
end
|
data/lib/g_simple_api/version.rb
CHANGED
@@ -101,11 +101,11 @@ describe GSimpleApi::Manager do
|
|
101
101
|
describe "#execute" do
|
102
102
|
let(:method) { "activities.list" }
|
103
103
|
before do
|
104
|
-
|
104
|
+
double_execute = double("Test", :data => "result")
|
105
105
|
subject.stub(:split_method => ["activities", "list"])
|
106
106
|
subject.stub(:chained_method_calls => "")
|
107
107
|
subject.stub_chain(:settings, :discovered_api).and_return({})
|
108
|
-
subject.stub_chain(:settings, :api_client, :execute).and_return(
|
108
|
+
subject.stub_chain(:settings, :api_client, :execute).and_return(double_execute)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "calls #split_method once" do
|
@@ -126,4 +126,4 @@ describe GSimpleApi::Manager do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
end
|
129
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g_simple_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Meira
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: byebug
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
description: 'GSimpleApi makes it easy to access and receive data from google''s apis '
|
126
112
|
email:
|
127
113
|
- goesmeira@gmail.com
|
@@ -131,6 +117,7 @@ extra_rdoc_files: []
|
|
131
117
|
files:
|
132
118
|
- ".gitignore"
|
133
119
|
- ".rspec"
|
120
|
+
- ".travis.yml"
|
134
121
|
- Gemfile
|
135
122
|
- Guardfile
|
136
123
|
- LICENSE.txt
|
@@ -159,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
146
|
requirements:
|
160
147
|
- - ">="
|
161
148
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
149
|
+
version: 1.9.3
|
163
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
151
|
requirements:
|
165
152
|
- - ">="
|