borneo 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +57 -0
- data/Rakefile +10 -0
- data/borneo.gemspec +29 -0
- data/lib/borneo/authorized_proxy.rb +37 -0
- data/lib/borneo/client.rb +21 -0
- data/lib/borneo/method_proxy.rb +55 -0
- data/lib/borneo/service.rb +27 -0
- data/lib/borneo/version.rb +3 -0
- data/lib/borneo.rb +9 -0
- data/spec/core/authorized_proxy_spec.rb +52 -0
- data/spec/core/client_spec.rb +46 -0
- data/spec/core/method_proxy_spec.rb +87 -0
- data/spec/core/service_spec.rb +66 -0
- data/spec/discovery_document.json +263 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +6 -0
- metadata +169 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d64c1413e46a3e1e5469512e43277708ec8ea5e
|
4
|
+
data.tar.gz: 1ad40d090b75e9f7db82f190278b65e711763156
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60759f17c9efa3376562ecaac6293ff58e56b2a3007cd5b51aa26424599db990fedebc420914f4065b65bf7b130d9dad0568db1781b2a3c63933472454e235d6
|
7
|
+
data.tar.gz: 01a76bdf0b4422b56d650674fcbce00883ab6182a882f241808b33fa59d0168ec21d340e8a4d875b676610cd3d774b4dfa5b82e5e25e8d7561c31e6108024e68
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Joe Geldart
|
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
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Borneo
|
2
|
+
|
3
|
+
Borneo makes working with Google's APIs as straightforward as navigating the jungle is
|
4
|
+
for an orangutan.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'borneo'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install borneo
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
The first step to using Borneo is to create a client. This client can be reused for
|
23
|
+
performance reasons. When creating the client, you should specify the client ID,
|
24
|
+
client secret and redirect URL:
|
25
|
+
|
26
|
+
client = Borneo::Client.new(client_id, client_secret, redirect_url)
|
27
|
+
|
28
|
+
This client can then be authorised using an access token and refresh token that have
|
29
|
+
previously been obtained through an OAuth 2 exchange.
|
30
|
+
|
31
|
+
api = client.for(access_token, refresh_token)
|
32
|
+
|
33
|
+
This object is the entry point to using all of Google's discoverable APIs. To access
|
34
|
+
a service, use the API's service method:
|
35
|
+
|
36
|
+
plus = api.service('plus', 'v1')
|
37
|
+
|
38
|
+
The returned service object can then have methods called upon it:
|
39
|
+
|
40
|
+
activities = plus.activities.list.call :userId => "me", :collection => "public"
|
41
|
+
|
42
|
+
The objects returned from the methods behave like normal Ruby objects:
|
43
|
+
|
44
|
+
activities.items.each do |activity|
|
45
|
+
puts activity.object.content
|
46
|
+
end
|
47
|
+
|
48
|
+
Borneo raises an error if the operation wasn't permitted. If the access token is
|
49
|
+
stale, the library will try to refresh it once before raising an error.
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
1. Fork it
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:test) do |t|
|
5
|
+
t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
|
6
|
+
t.pattern = 'spec/**/*_spec.rb'
|
7
|
+
end
|
8
|
+
|
9
|
+
task :spec => :test
|
10
|
+
task :default => :test
|
data/borneo.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'borneo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "borneo"
|
8
|
+
spec.version = Borneo::VERSION
|
9
|
+
spec.authors = ["Joe Geldart"]
|
10
|
+
spec.email = ["joe@joegeldart.com"]
|
11
|
+
spec.description = %q{Borneo hacks-and-slashes through the complexity of Google's APIs}
|
12
|
+
spec.summary = %q{If you're spending more time on Google data boilerplate than code, Borneo provides an answer.}
|
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"]
|
20
|
+
|
21
|
+
spec.add_dependency "google-api-client"
|
22
|
+
spec.add_dependency "signet"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
spec.add_development_dependency "webmock"
|
28
|
+
spec.add_development_dependency "debugger"
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'signet/oauth_2/client'
|
2
|
+
|
3
|
+
class Borneo::AuthorizedProxy
|
4
|
+
|
5
|
+
attr_reader :client, :access_token, :refresh_token
|
6
|
+
|
7
|
+
def initialize(client, access_token, refresh_token)
|
8
|
+
@client = client
|
9
|
+
@access_token = access_token
|
10
|
+
@refresh_token = refresh_token
|
11
|
+
end
|
12
|
+
|
13
|
+
def service(name, version)
|
14
|
+
Borneo::Service.new(self, name, version)
|
15
|
+
end
|
16
|
+
|
17
|
+
def authorization
|
18
|
+
new_authorization = Signet::OAuth2::Client.new
|
19
|
+
new_authorization.client_id = @client.client_id
|
20
|
+
new_authorization.client_secret = @client.client_secret
|
21
|
+
new_authorization.authorization_uri = "https://accounts.google.com/o/oauth2/auth"
|
22
|
+
new_authorization.token_credential_uri = "https://accounts.google.com/o/oauth2/token"
|
23
|
+
new_authorization.redirect_uri = @client.redirect_url
|
24
|
+
|
25
|
+
new_authorization.update_token!(
|
26
|
+
:access_token => @access_token,
|
27
|
+
:refresh_token => @refresh_token
|
28
|
+
)
|
29
|
+
|
30
|
+
new_authorization
|
31
|
+
end
|
32
|
+
|
33
|
+
def google_client
|
34
|
+
@client.google_client
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'google/api_client'
|
2
|
+
|
3
|
+
class Borneo::Client
|
4
|
+
|
5
|
+
attr_reader :client_id, :client_secret, :redirect_url
|
6
|
+
|
7
|
+
def initialize(client_id, client_secret, redirect_url)
|
8
|
+
@client_id = client_id
|
9
|
+
@client_secret = client_secret
|
10
|
+
@redirect_url = redirect_url
|
11
|
+
end
|
12
|
+
|
13
|
+
def for(access_token, refresh_token)
|
14
|
+
Borneo::AuthorizedProxy.new(self,access_token, refresh_token)
|
15
|
+
end
|
16
|
+
|
17
|
+
def google_client
|
18
|
+
Google::APIClient.new
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Borneo::ResponseStatus
|
2
|
+
STALE_ACCESS_TOKEN = 401
|
3
|
+
end
|
4
|
+
|
5
|
+
class Borneo::MethodProxy
|
6
|
+
|
7
|
+
attr :_service, :_components
|
8
|
+
|
9
|
+
def initialize(service, name, components=[])
|
10
|
+
@_service = service
|
11
|
+
@_components = components.clone
|
12
|
+
@_components << name
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(params = {})
|
16
|
+
method_call = lambda do
|
17
|
+
_client.execute(
|
18
|
+
:api_method => _method,
|
19
|
+
:authorization => _authorization,
|
20
|
+
:parameters => params
|
21
|
+
)
|
22
|
+
end
|
23
|
+
response = method_call.call()
|
24
|
+
if response.status == Borneo::ResponseStatus::STALE_ACCESS_TOKEN
|
25
|
+
_client.authorization.fetch_access_token!
|
26
|
+
response = method_call.call()
|
27
|
+
end
|
28
|
+
|
29
|
+
data = response.data
|
30
|
+
|
31
|
+
data
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def _client
|
36
|
+
@_service._client
|
37
|
+
end
|
38
|
+
|
39
|
+
def _authorization
|
40
|
+
@_service._authorization
|
41
|
+
end
|
42
|
+
|
43
|
+
def _method
|
44
|
+
m = @_service._discovered_service
|
45
|
+
@_components.each do |c|
|
46
|
+
m = m.send(c)
|
47
|
+
end
|
48
|
+
m
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing(name)
|
52
|
+
Borneo::MethodProxy.new(@_service, name, @_components)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Borneo::Service
|
2
|
+
|
3
|
+
attr :proxy, :name, :version
|
4
|
+
|
5
|
+
def initialize(proxy, name, version)
|
6
|
+
@proxy = proxy
|
7
|
+
@name = name
|
8
|
+
@version = version
|
9
|
+
end
|
10
|
+
|
11
|
+
def _client
|
12
|
+
@proxy.google_client
|
13
|
+
end
|
14
|
+
|
15
|
+
def _authorization
|
16
|
+
@proxy.authorization
|
17
|
+
end
|
18
|
+
|
19
|
+
def _discovered_service
|
20
|
+
_client.discovered_api(@name, @version)
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_missing(name)
|
24
|
+
Borneo::MethodProxy.new(self, name)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/borneo.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
describe Borneo::AuthorizedProxy do
|
4
|
+
|
5
|
+
let(:client_id) { "SOME_CLIENT_ID" }
|
6
|
+
let(:client_secret) { "SOME_CLIENT_SECRET" }
|
7
|
+
let(:redirect_url) { "http://localhost" }
|
8
|
+
let(:client) { Borneo::Client.new(client_id, client_secret, redirect_url) }
|
9
|
+
let(:access_token) { "ACCESS_TOKEN" }
|
10
|
+
let(:refresh_token) { "REFRESH_TOKEN" }
|
11
|
+
|
12
|
+
describe "initializer" do
|
13
|
+
it "should take client, access_token and refresh token parameters" do
|
14
|
+
proxy = Borneo::AuthorizedProxy.new(client, access_token, refresh_token)
|
15
|
+
proxy.client.should == client
|
16
|
+
proxy.access_token.should == access_token
|
17
|
+
proxy.refresh_token.should == refresh_token
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "service creator" do
|
22
|
+
let(:proxy) { Borneo::AuthorizedProxy.new(client, access_token, refresh_token) }
|
23
|
+
|
24
|
+
it "should take two parameters" do
|
25
|
+
proxy.should respond_to(:service).with(2).arguments
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:service_name) { "oauth2" }
|
29
|
+
let(:service_version) { "v2" }
|
30
|
+
|
31
|
+
it "should return a service object" do
|
32
|
+
proxy.service(service_name, service_version).should be_a(Borneo::Service)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "returned service" do
|
36
|
+
let(:service) { proxy.service(service_name, service_version) }
|
37
|
+
|
38
|
+
it "should use the creating authorised proxy" do
|
39
|
+
service.proxy.should == proxy
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have the right name" do
|
43
|
+
service.name.should == service_name
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should have the right version" do
|
47
|
+
service.version.should == service_version
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
describe Borneo::Client do
|
4
|
+
|
5
|
+
let(:client_id) { "SOME_CLIENT_ID" }
|
6
|
+
let(:client_secret) { "SOME_CLIENT_SECRET" }
|
7
|
+
let(:redirect_url) { "http://localhost" }
|
8
|
+
|
9
|
+
describe "initialiser" do
|
10
|
+
it "takes a client ID, client secret and redirect URL parameters" do
|
11
|
+
client = Borneo::Client.new(client_id, client_secret, redirect_url)
|
12
|
+
client.client_id.should == client_id
|
13
|
+
client.client_secret.should == client_secret
|
14
|
+
client.redirect_url.should == redirect_url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "for" do
|
19
|
+
|
20
|
+
let(:client) { Borneo::Client.new(client_id, client_secret, redirect_url) }
|
21
|
+
let(:access_token) { "ACCESS_TOKEN" }
|
22
|
+
let(:refresh_token) { "REFRESH_TOKEN" }
|
23
|
+
|
24
|
+
let(:proxy) { client.for(access_token, refresh_token) }
|
25
|
+
|
26
|
+
it "should return an authorized proxy" do
|
27
|
+
proxy.should be_a(Borneo::AuthorizedProxy)
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "returned proxy" do
|
31
|
+
it "should have the creating client as its client" do
|
32
|
+
proxy.client.should == client
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should contain the access token" do
|
36
|
+
proxy.access_token.should == access_token
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should contain the refresh token" do
|
40
|
+
proxy.refresh_token.should == refresh_token
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
describe Borneo::MethodProxy do
|
4
|
+
|
5
|
+
let(:client_id) { "SOME_CLIENT_ID" }
|
6
|
+
let(:client_secret) { "SOME_CLIENT_SECRET" }
|
7
|
+
let(:redirect_url) { "http://localhost" }
|
8
|
+
let(:client) { Borneo::Client.new(client_id, client_secret, redirect_url) }
|
9
|
+
let(:access_token) { "ACCESS_TOKEN" }
|
10
|
+
let(:refresh_token) { "REFRESH_TOKEN" }
|
11
|
+
let(:proxy) { Borneo::AuthorizedProxy.new(client, access_token, refresh_token) }
|
12
|
+
let(:service_name) { "oauth2" }
|
13
|
+
let(:service_version) { "v2" }
|
14
|
+
let(:service) { Borneo::Service.new(proxy, service_name, service_version) }
|
15
|
+
|
16
|
+
let(:method_name) { :userinfo }
|
17
|
+
|
18
|
+
describe "initializer" do
|
19
|
+
|
20
|
+
it "should take a service and name as parameters" do
|
21
|
+
method_proxy = Borneo::MethodProxy.new(service, method_name)
|
22
|
+
method_proxy._service.should == service
|
23
|
+
method_proxy._components.should == [method_name]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should take a service, name and previous components as parameters" do
|
27
|
+
method_proxy = Borneo::MethodProxy.new(service, :get, [:userinfo])
|
28
|
+
method_proxy._service.should == service
|
29
|
+
method_proxy._components.should == [:userinfo, :get]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "extension" do
|
34
|
+
let(:method_proxy) { Borneo::MethodProxy.new(service, method_name) }
|
35
|
+
|
36
|
+
it "should return a new proxy" do
|
37
|
+
method_proxy.get.should be_a(Borneo::MethodProxy)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should extend the previous one's components by the new name" do
|
41
|
+
method_proxy.get._components.should == [:userinfo, :get]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should have the right service" do
|
45
|
+
method_proxy.get._service.should == service
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "calling" do
|
51
|
+
let(:method_proxy) { Borneo::MethodProxy.new(service, :get, [:userinfo]) }
|
52
|
+
|
53
|
+
before do
|
54
|
+
stub_request(:get, "https://www.googleapis.com/discovery/v1/apis/oauth2/v2/rest")
|
55
|
+
.to_return(lambda {|request| File.new(File.dirname(__FILE__) + "/../discovery_document.json")})
|
56
|
+
|
57
|
+
stub_request(:get, "https://www.googleapis.com/oauth2/v2/userinfo").to_return(
|
58
|
+
:status => 200,
|
59
|
+
:headers => { 'Content-Type' => 'application/json' },
|
60
|
+
:body => <<-RESP
|
61
|
+
{
|
62
|
+
"id": "0000",
|
63
|
+
"email": "jsmith@example.com",
|
64
|
+
"verified_email": true,
|
65
|
+
"name": "John Smith",
|
66
|
+
"given_name": "John",
|
67
|
+
"family_name": "Smith",
|
68
|
+
"link": "https://plus.google.com/0000",
|
69
|
+
"gender": "male",
|
70
|
+
"birthday": "0000-01-01",
|
71
|
+
"locale": "en",
|
72
|
+
"hd": "example.com"
|
73
|
+
}
|
74
|
+
RESP
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should be callable with 0 arguments" do
|
79
|
+
method_proxy.should respond_to(:call).with(0).arguments
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return" do
|
83
|
+
profile = method_proxy.call
|
84
|
+
profile.name.should == "John Smith"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
2
|
+
|
3
|
+
describe Borneo::Service do
|
4
|
+
|
5
|
+
let(:client_id) { "SOME_CLIENT_ID" }
|
6
|
+
let(:client_secret) { "SOME_CLIENT_SECRET" }
|
7
|
+
let(:redirect_url) { "http://localhost" }
|
8
|
+
let(:client) { Borneo::Client.new(client_id, client_secret, redirect_url) }
|
9
|
+
let(:access_token) { "ACCESS_TOKEN" }
|
10
|
+
let(:refresh_token) { "REFRESH_TOKEN" }
|
11
|
+
let(:proxy) { Borneo::AuthorizedProxy.new(client, access_token, refresh_token) }
|
12
|
+
let(:service_name) { "oauth2" }
|
13
|
+
let(:service_version) { "v2" }
|
14
|
+
|
15
|
+
describe "initializer" do
|
16
|
+
|
17
|
+
it "should take proxy, service name and service version as parameters" do
|
18
|
+
service = Borneo::Service.new(proxy, service_name, service_version)
|
19
|
+
service.proxy.should == proxy
|
20
|
+
service.name.should == service_name
|
21
|
+
service.version.should == service_version
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "method proxy" do
|
25
|
+
|
26
|
+
let(:service) { Borneo::Service.new(proxy, service_name, service_version) }
|
27
|
+
|
28
|
+
it "should be returned for anything else" do
|
29
|
+
service.userinfo.should be_a(Borneo::MethodProxy)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have the right components" do
|
33
|
+
service.userinfo._components.should == [:userinfo]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have the right service" do
|
37
|
+
service.userinfo._service.should == service
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "utility methods" do
|
43
|
+
let(:service) { Borneo::Service.new(proxy, service_name, service_version) }
|
44
|
+
|
45
|
+
describe "discovered service" do
|
46
|
+
it "should be callable" do
|
47
|
+
service.should respond_to(:_discovered_service)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
describe "authorization" do
|
51
|
+
it "should be callable" do
|
52
|
+
service.should respond_to(:_authorization)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
describe "client" do
|
56
|
+
it "should be callable" do
|
57
|
+
service.should respond_to(:_client)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,263 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Expires: Sat, 10 Aug 2013 14:18:24 GMT
|
3
|
+
Date: Sat, 10 Aug 2013 14:13:24 GMT
|
4
|
+
ETag: "IhsO6I1JrT_5w9XRpjXK0MUWOF8/8ihdaRnLkqLI1Jh4xCqbqBWVS68"
|
5
|
+
Content-Type: application/json; charset=UTF-8
|
6
|
+
X-Content-Type-Options: nosniff
|
7
|
+
X-Frame-Options: SAMEORIGIN
|
8
|
+
X-XSS-Protection: 1; mode=block
|
9
|
+
Server: GSE
|
10
|
+
Cache-Control: public, max-age=300, must-revalidate, no-transform
|
11
|
+
Age: 63
|
12
|
+
Transfer-Encoding: chunked
|
13
|
+
|
14
|
+
{
|
15
|
+
"kind": "discovery#restDescription",
|
16
|
+
"etag": "\"IhsO6I1JrT_5w9XRpjXK0MUWOF8/8ihdaRnLkqLI1Jh4xCqbqBWVS68\"",
|
17
|
+
"discoveryVersion": "v1",
|
18
|
+
"id": "oauth2:v2",
|
19
|
+
"name": "oauth2",
|
20
|
+
"version": "v2",
|
21
|
+
"revision": "20130730",
|
22
|
+
"title": "Google OAuth2 API",
|
23
|
+
"description": "Lets you access OAuth2 protocol related APIs.",
|
24
|
+
"ownerDomain": "google.com",
|
25
|
+
"ownerName": "Google",
|
26
|
+
"icons": {
|
27
|
+
"x16": "http://www.google.com/images/icons/product/search-16.gif",
|
28
|
+
"x32": "http://www.google.com/images/icons/product/search-32.gif"
|
29
|
+
},
|
30
|
+
"documentationLink": "https://developers.google.com/accounts/docs/OAuth2",
|
31
|
+
"protocol": "rest",
|
32
|
+
"baseUrl": "https://www.googleapis.com/",
|
33
|
+
"basePath": "/",
|
34
|
+
"rootUrl": "https://www.googleapis.com/",
|
35
|
+
"servicePath": "",
|
36
|
+
"batchPath": "batch",
|
37
|
+
"parameters": {
|
38
|
+
"alt": {
|
39
|
+
"type": "string",
|
40
|
+
"description": "Data format for the response.",
|
41
|
+
"default": "json",
|
42
|
+
"enum": [
|
43
|
+
"json"
|
44
|
+
],
|
45
|
+
"enumDescriptions": [
|
46
|
+
"Responses with Content-Type of application/json"
|
47
|
+
],
|
48
|
+
"location": "query"
|
49
|
+
},
|
50
|
+
"fields": {
|
51
|
+
"type": "string",
|
52
|
+
"description": "Selector specifying which fields to include in a partial response.",
|
53
|
+
"location": "query"
|
54
|
+
},
|
55
|
+
"key": {
|
56
|
+
"type": "string",
|
57
|
+
"description": "API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.",
|
58
|
+
"location": "query"
|
59
|
+
},
|
60
|
+
"oauth_token": {
|
61
|
+
"type": "string",
|
62
|
+
"description": "OAuth 2.0 token for the current user.",
|
63
|
+
"location": "query"
|
64
|
+
},
|
65
|
+
"prettyPrint": {
|
66
|
+
"type": "boolean",
|
67
|
+
"description": "Returns response with indentations and line breaks.",
|
68
|
+
"default": "true",
|
69
|
+
"location": "query"
|
70
|
+
},
|
71
|
+
"quotaUser": {
|
72
|
+
"type": "string",
|
73
|
+
"description": "Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.",
|
74
|
+
"location": "query"
|
75
|
+
},
|
76
|
+
"userIp": {
|
77
|
+
"type": "string",
|
78
|
+
"description": "IP address of the site where the request originates. Use this if you want to enforce per-user limits.",
|
79
|
+
"location": "query"
|
80
|
+
}
|
81
|
+
},
|
82
|
+
"auth": {
|
83
|
+
"oauth2": {
|
84
|
+
"scopes": {
|
85
|
+
"https://www.googleapis.com/auth/plus.login": {
|
86
|
+
"description": "Know your name, basic info, and list of people you're connected to on Google+"
|
87
|
+
},
|
88
|
+
"https://www.googleapis.com/auth/plus.me": {
|
89
|
+
"description": "Know who you are on Google"
|
90
|
+
},
|
91
|
+
"https://www.googleapis.com/auth/userinfo.email": {
|
92
|
+
"description": "View your email address"
|
93
|
+
},
|
94
|
+
"https://www.googleapis.com/auth/userinfo.profile": {
|
95
|
+
"description": "View basic information about your account"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
},
|
100
|
+
"schemas": {
|
101
|
+
"Tokeninfo": {
|
102
|
+
"id": "Tokeninfo",
|
103
|
+
"type": "object",
|
104
|
+
"properties": {
|
105
|
+
"access_type": {
|
106
|
+
"type": "string",
|
107
|
+
"description": "The access type granted with this token. It can be offline or online."
|
108
|
+
},
|
109
|
+
"audience": {
|
110
|
+
"type": "string",
|
111
|
+
"description": "Who is the intended audience for this token. In general the same as issued_to."
|
112
|
+
},
|
113
|
+
"email": {
|
114
|
+
"type": "string",
|
115
|
+
"description": "The email address of the user. Present only if the email scope is present in the request."
|
116
|
+
},
|
117
|
+
"expires_in": {
|
118
|
+
"type": "integer",
|
119
|
+
"description": "The expiry time of the token, as number of seconds left until expiry.",
|
120
|
+
"format": "int32"
|
121
|
+
},
|
122
|
+
"issued_to": {
|
123
|
+
"type": "string",
|
124
|
+
"description": "To whom was the token issued to. In general the same as audience."
|
125
|
+
},
|
126
|
+
"scope": {
|
127
|
+
"type": "string",
|
128
|
+
"description": "The space separated list of scopes granted to this token."
|
129
|
+
},
|
130
|
+
"user_id": {
|
131
|
+
"type": "string",
|
132
|
+
"description": "The Gaia obfuscated user id."
|
133
|
+
},
|
134
|
+
"verified_email": {
|
135
|
+
"type": "boolean",
|
136
|
+
"description": "Boolean flag which is true if the email address is verified. Present only if the email scope is present in the request."
|
137
|
+
}
|
138
|
+
}
|
139
|
+
},
|
140
|
+
"Userinfo": {
|
141
|
+
"id": "Userinfo",
|
142
|
+
"type": "object",
|
143
|
+
"properties": {
|
144
|
+
"birthday": {
|
145
|
+
"type": "string",
|
146
|
+
"description": "The user's birthday. The year is not present."
|
147
|
+
},
|
148
|
+
"email": {
|
149
|
+
"type": "string",
|
150
|
+
"description": "The user's email address."
|
151
|
+
},
|
152
|
+
"family_name": {
|
153
|
+
"type": "string",
|
154
|
+
"description": "The user's last name."
|
155
|
+
},
|
156
|
+
"gender": {
|
157
|
+
"type": "string",
|
158
|
+
"description": "The user's gender."
|
159
|
+
},
|
160
|
+
"given_name": {
|
161
|
+
"type": "string",
|
162
|
+
"description": "The user's first name."
|
163
|
+
},
|
164
|
+
"hd": {
|
165
|
+
"type": "string",
|
166
|
+
"description": "The hosted domain e.g. example.com if the user is Google apps user."
|
167
|
+
},
|
168
|
+
"id": {
|
169
|
+
"type": "string",
|
170
|
+
"description": "The focus obfuscated gaia id of the user."
|
171
|
+
},
|
172
|
+
"link": {
|
173
|
+
"type": "string",
|
174
|
+
"description": "URL of the profile page."
|
175
|
+
},
|
176
|
+
"locale": {
|
177
|
+
"type": "string",
|
178
|
+
"description": "The user's default locale."
|
179
|
+
},
|
180
|
+
"name": {
|
181
|
+
"type": "string",
|
182
|
+
"description": "The user's full name."
|
183
|
+
},
|
184
|
+
"picture": {
|
185
|
+
"type": "string",
|
186
|
+
"description": "URL of the user's picture image."
|
187
|
+
},
|
188
|
+
"timezone": {
|
189
|
+
"type": "string",
|
190
|
+
"description": "The user's default timezone."
|
191
|
+
},
|
192
|
+
"verified_email": {
|
193
|
+
"type": "boolean",
|
194
|
+
"description": "Boolean flag which is true if the email address is verified."
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
},
|
199
|
+
"methods": {
|
200
|
+
"tokeninfo": {
|
201
|
+
"id": "oauth2.tokeninfo",
|
202
|
+
"path": "oauth2/v2/tokeninfo",
|
203
|
+
"httpMethod": "POST",
|
204
|
+
"parameters": {
|
205
|
+
"access_token": {
|
206
|
+
"type": "string",
|
207
|
+
"location": "query"
|
208
|
+
},
|
209
|
+
"id_token": {
|
210
|
+
"type": "string",
|
211
|
+
"location": "query"
|
212
|
+
}
|
213
|
+
},
|
214
|
+
"response": {
|
215
|
+
"$ref": "Tokeninfo"
|
216
|
+
}
|
217
|
+
}
|
218
|
+
},
|
219
|
+
"resources": {
|
220
|
+
"userinfo": {
|
221
|
+
"methods": {
|
222
|
+
"get": {
|
223
|
+
"id": "oauth2.userinfo.get",
|
224
|
+
"path": "oauth2/v2/userinfo",
|
225
|
+
"httpMethod": "GET",
|
226
|
+
"response": {
|
227
|
+
"$ref": "Userinfo"
|
228
|
+
},
|
229
|
+
"scopes": [
|
230
|
+
"https://www.googleapis.com/auth/plus.login",
|
231
|
+
"https://www.googleapis.com/auth/plus.me",
|
232
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
233
|
+
"https://www.googleapis.com/auth/userinfo.profile"
|
234
|
+
]
|
235
|
+
}
|
236
|
+
},
|
237
|
+
"resources": {
|
238
|
+
"v2": {
|
239
|
+
"resources": {
|
240
|
+
"me": {
|
241
|
+
"methods": {
|
242
|
+
"get": {
|
243
|
+
"id": "oauth2.userinfo.v2.me.get",
|
244
|
+
"path": "userinfo/v2/me",
|
245
|
+
"httpMethod": "GET",
|
246
|
+
"response": {
|
247
|
+
"$ref": "Userinfo"
|
248
|
+
},
|
249
|
+
"scopes": [
|
250
|
+
"https://www.googleapis.com/auth/plus.login",
|
251
|
+
"https://www.googleapis.com/auth/plus.me",
|
252
|
+
"https://www.googleapis.com/auth/userinfo.email",
|
253
|
+
"https://www.googleapis.com/auth/userinfo.profile"
|
254
|
+
]
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-u -c
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: borneo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Geldart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: google-api-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: signet
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
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: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: debugger
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Borneo hacks-and-slashes through the complexity of Google's APIs
|
112
|
+
email:
|
113
|
+
- joe@joegeldart.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- borneo.gemspec
|
124
|
+
- lib/borneo.rb
|
125
|
+
- lib/borneo/authorized_proxy.rb
|
126
|
+
- lib/borneo/client.rb
|
127
|
+
- lib/borneo/method_proxy.rb
|
128
|
+
- lib/borneo/service.rb
|
129
|
+
- lib/borneo/version.rb
|
130
|
+
- spec/core/authorized_proxy_spec.rb
|
131
|
+
- spec/core/client_spec.rb
|
132
|
+
- spec/core/method_proxy_spec.rb
|
133
|
+
- spec/core/service_spec.rb
|
134
|
+
- spec/discovery_document.json
|
135
|
+
- spec/spec.opts
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
homepage: ''
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.0.5
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: If you're spending more time on Google data boilerplate than code, Borneo
|
161
|
+
provides an answer.
|
162
|
+
test_files:
|
163
|
+
- spec/core/authorized_proxy_spec.rb
|
164
|
+
- spec/core/client_spec.rb
|
165
|
+
- spec/core/method_proxy_spec.rb
|
166
|
+
- spec/core/service_spec.rb
|
167
|
+
- spec/discovery_document.json
|
168
|
+
- spec/spec.opts
|
169
|
+
- spec/spec_helper.rb
|