sinatra-geoloqi 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +10 -53
- data/{README.markdown → README.md} +0 -0
- data/lib/sinatra/geoloqi.rb +5 -0
- data/spec/sinatra_geoloqi_spec.rb +13 -13
- metadata +110 -98
data/Gemfile.lock
CHANGED
@@ -1,83 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sinatra-geoloqi (0.9.
|
4
|
+
sinatra-geoloqi (0.9.1)
|
5
5
|
geoloqi (>= 0.9.33)
|
6
6
|
sinatra (>= 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ParseTree (3.0.8)
|
12
|
-
RubyInline (>= 3.7.0)
|
13
|
-
sexp_processor (>= 3.0.0)
|
14
|
-
RubyInline (3.11.0)
|
15
|
-
ZenTest (~> 4.3)
|
16
|
-
ZenTest (4.6.2)
|
17
11
|
addressable (2.2.6)
|
18
|
-
bouncy-castle-java (1.5.0146.1)
|
19
12
|
crack (0.3.1)
|
20
|
-
diff-lcs (1.1.3)
|
21
13
|
faraday (0.7.5)
|
22
14
|
addressable (~> 2.2.6)
|
23
15
|
multipart-post (~> 1.1.3)
|
24
16
|
rack (>= 1.1.0, < 2)
|
25
|
-
|
26
|
-
tins (~> 0.3)
|
27
|
-
geoloqi (0.9.33)
|
17
|
+
geoloqi (0.9.35)
|
28
18
|
faraday (>= 0.6.1)
|
29
19
|
json
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
multipart-post (1.1.3)
|
36
|
-
predicated (0.2.6)
|
37
|
-
rack (1.3.5)
|
38
|
-
rack-protection (1.1.4)
|
20
|
+
json (1.6.4)
|
21
|
+
minitest (2.10.0)
|
22
|
+
multipart-post (1.1.4)
|
23
|
+
rack (1.4.0)
|
24
|
+
rack-protection (1.2.0)
|
39
25
|
rack
|
40
26
|
rack-test (0.5.7)
|
41
27
|
rack (>= 1.0)
|
42
28
|
rake (0.9.2.2)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
ruby_parser (2.0.6)
|
47
|
-
sexp_processor (~> 3.0)
|
48
|
-
sexp_processor (3.0.8)
|
49
|
-
sinatra (1.3.1)
|
50
|
-
rack (~> 1.3, >= 1.3.4)
|
51
|
-
rack-protection (~> 1.1, >= 1.1.2)
|
29
|
+
sinatra (1.3.2)
|
30
|
+
rack (~> 1.3, >= 1.3.6)
|
31
|
+
rack-protection (~> 1.2)
|
52
32
|
tilt (~> 1.3, >= 1.3.3)
|
53
|
-
sourcify (0.5.0)
|
54
|
-
file-tail (>= 1.0.5)
|
55
|
-
ruby2ruby (>= 1.2.5)
|
56
|
-
ruby_parser (>= 2.0.5)
|
57
|
-
sexp_processor (>= 3.0.5)
|
58
33
|
tilt (1.3.3)
|
59
|
-
tins (0.3.2)
|
60
34
|
webmock (1.7.7)
|
61
35
|
addressable (~> 2.2, > 2.2.5)
|
62
36
|
crack (>= 0.1.7)
|
63
|
-
wrong (0.5.0)
|
64
|
-
ParseTree (~> 3.0)
|
65
|
-
diff-lcs (~> 1.1.2)
|
66
|
-
file-tail (~> 1.0)
|
67
|
-
predicated (>= 0.2.2)
|
68
|
-
ruby2ruby (~> 1.2)
|
69
|
-
ruby_parser (~> 2.0.4)
|
70
|
-
sexp_processor (~> 3.0)
|
71
|
-
sourcify (>= 0.3.0)
|
72
|
-
wrong (0.5.0-java)
|
73
|
-
diff-lcs (~> 1.1.2)
|
74
|
-
predicated (>= 0.2.2)
|
75
|
-
ruby2ruby (~> 1.2)
|
76
|
-
ruby_parser (~> 2.0.4)
|
77
|
-
sexp_processor (~> 3.0)
|
78
37
|
|
79
38
|
PLATFORMS
|
80
|
-
java
|
81
39
|
ruby
|
82
40
|
|
83
41
|
DEPENDENCIES
|
@@ -87,4 +45,3 @@ DEPENDENCIES
|
|
87
45
|
rake
|
88
46
|
sinatra-geoloqi!
|
89
47
|
webmock (= 1.7.7)
|
90
|
-
wrong (= 0.5.0)
|
File without changes
|
data/lib/sinatra/geoloqi.rb
CHANGED
@@ -3,6 +3,7 @@ require 'geoloqi'
|
|
3
3
|
|
4
4
|
module Sinatra
|
5
5
|
module Geoloqi
|
6
|
+
# Registers the Geoloqi plugin. This call is required for classy apps which inherit Sinatra::Base, and not required for classic apps.
|
6
7
|
def self.registered(app)
|
7
8
|
app.enable :sessions unless app.test?
|
8
9
|
|
@@ -11,12 +12,16 @@ module Sinatra
|
|
11
12
|
end
|
12
13
|
|
13
14
|
app.helpers do
|
15
|
+
# Instantiate (or retrieve) the current Geoloqi session.
|
16
|
+
#
|
17
|
+
# @return [Geoloqi::Session]
|
14
18
|
def geoloqi
|
15
19
|
@_geoloqi ||= ::Geoloqi::Session.new :auth => session[:_geoloqi_auth],
|
16
20
|
:config => {:client_id => settings.geoloqi_client_id,
|
17
21
|
:client_secret => settings.geoloqi_client_secret}
|
18
22
|
end
|
19
23
|
|
24
|
+
# Redirects to Geoloqi OAuth2 authentication if the user is not logged in. Use this to force login for routes.
|
20
25
|
def require_geoloqi_login
|
21
26
|
geoloqi.get_auth(params[:code], settings.geoloqi_redirect_uri) if params[:code] && !geoloqi.access_token?
|
22
27
|
redirect geoloqi.authorize_url(settings.geoloqi_redirect_uri) unless geoloqi.access_token?
|
@@ -2,9 +2,7 @@ ENV['RACK_ENV'] = 'test'
|
|
2
2
|
require File.join(File.join(File.expand_path(File.dirname(__FILE__))), '..', 'lib', 'sinatra', 'geoloqi')
|
3
3
|
require 'rack/test'
|
4
4
|
require 'minitest/autorun'
|
5
|
-
require 'wrong/adapters/minitest'
|
6
5
|
require 'webmock'
|
7
|
-
Wrong.config.alias_assert :expect_that
|
8
6
|
|
9
7
|
include WebMock::API
|
10
8
|
|
@@ -42,7 +40,7 @@ def app
|
|
42
40
|
|
43
41
|
get '/calltest' do
|
44
42
|
require_geoloqi_login
|
45
|
-
geoloqi.get('account/profile')[
|
43
|
+
geoloqi.get('account/profile')[:result]
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
@@ -52,25 +50,27 @@ describe 'A mock app' do
|
|
52
50
|
|
53
51
|
it 'returns geoloqi object' do
|
54
52
|
get '/'
|
55
|
-
|
56
|
-
|
53
|
+
last_response.ok?.must_equal true
|
54
|
+
last_response.body.must_equal 'Geoloqi::Session'
|
57
55
|
end
|
58
56
|
|
59
57
|
it 'returns a geoloqi object on request' do
|
60
58
|
get '/redirect'
|
61
|
-
|
62
|
-
|
59
|
+
last_response.redirect?.must_equal true
|
60
|
+
last_response.headers['Location'].must_equal 'https://geoloqi.com/oauth/authorize?response_type=code&client_id=ABCD&'+
|
61
|
+
'redirect_uri=http%3A%2F%2Fexample.org%2Ftest'
|
63
62
|
end
|
64
63
|
|
65
64
|
it 'processes the geoloqi return' do
|
66
65
|
stub_request(:post, "https://api.geoloqi.com/1/oauth/token").
|
67
|
-
with(:body => "{\"client_id\":\"ABCD\",\"client_secret\":\"EFGH\",\"grant_type\":\"authorization_code\",\"code\":\"code1234\"
|
66
|
+
with(:body => "{\"client_id\":\"ABCD\",\"client_secret\":\"EFGH\",\"grant_type\":\"authorization_code\",\"code\":\"code1234\","+
|
67
|
+
"\"redirect_uri\":\"http://example.org/test\"}").
|
68
68
|
to_return(:status => 200,
|
69
69
|
:body => auth.to_json)
|
70
|
-
|
70
|
+
|
71
71
|
get '/test?state=&code=code1234'
|
72
|
-
|
73
|
-
|
72
|
+
last_response.ok?.must_equal true
|
73
|
+
last_response.body.must_equal 'access_token1234'
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'calls successfully' do
|
@@ -80,7 +80,7 @@ describe 'A mock app' do
|
|
80
80
|
|
81
81
|
get '/calltest', {}, 'rack.session' => {:'_geoloqi_auth' => auth}
|
82
82
|
|
83
|
-
|
84
|
-
|
83
|
+
last_response.status.must_equal 200
|
84
|
+
last_response.body.must_equal 'ok'
|
85
85
|
end
|
86
86
|
end
|
metadata
CHANGED
@@ -1,97 +1,104 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-geoloqi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 2
|
9
|
+
version: 0.9.2
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
|
-
|
12
|
+
- Kyle Drake
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date:
|
17
|
+
date: 2012-01-08 00:00:00 -08:00
|
18
|
+
default_executable:
|
14
19
|
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: sinatra
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
version: "1.0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: geoloqi
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
- 9
|
43
|
+
- 33
|
44
|
+
version: 0.9.33
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rack-test
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
- 5
|
69
|
+
- 7
|
70
|
+
version: 0.5.7
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id004
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: webmock
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 1
|
82
|
+
- 7
|
83
|
+
- 7
|
84
|
+
version: 1.7.7
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id005
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: minitest
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
version: "0"
|
97
|
+
type: :development
|
98
|
+
version_requirements: *id006
|
92
99
|
description: Geoloqi adapter for Sinatra, quickly allows you to make applications
|
93
100
|
email:
|
94
|
-
|
101
|
+
- kyledrake@gmail.com
|
95
102
|
executables: []
|
96
103
|
|
97
104
|
extensions: []
|
@@ -99,12 +106,13 @@ extensions: []
|
|
99
106
|
extra_rdoc_files: []
|
100
107
|
|
101
108
|
files:
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
109
|
+
- lib/sinatra/geoloqi.rb
|
110
|
+
- spec/sinatra_geoloqi_spec.rb
|
111
|
+
- Gemfile
|
112
|
+
- Gemfile.lock
|
113
|
+
- Rakefile
|
114
|
+
- README.md
|
115
|
+
has_rdoc: true
|
108
116
|
homepage: https://github.com/geoloqi/sinatra-geoloqi
|
109
117
|
licenses: []
|
110
118
|
|
@@ -112,23 +120,27 @@ post_install_message:
|
|
112
120
|
rdoc_options: []
|
113
121
|
|
114
122
|
require_paths:
|
115
|
-
|
123
|
+
- lib
|
116
124
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
125
|
requirements:
|
119
|
-
|
120
|
-
|
121
|
-
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
122
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
132
|
requirements:
|
125
|
-
|
126
|
-
|
127
|
-
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
segments:
|
136
|
+
- 1
|
137
|
+
- 3
|
138
|
+
- 4
|
139
|
+
version: 1.3.4
|
128
140
|
requirements: []
|
129
141
|
|
130
142
|
rubyforge_project: sinatra-geoloqi
|
131
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.3.6
|
132
144
|
signing_key:
|
133
145
|
specification_version: 3
|
134
146
|
summary: Geoloqi adapter for Sinatra
|