geoloqi 0.9.21 → 0.9.22
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.
- data/lib/geoloqi.rb +13 -4
- data/lib/geoloqi/session.rb +2 -2
- data/lib/geoloqi/version.rb +1 -1
- data/spec/geoloqi_spec.rb +6 -6
- metadata +2 -2
data/lib/geoloqi.rb
CHANGED
@@ -10,14 +10,23 @@ require 'geoloqi/session'
|
|
10
10
|
require 'geoloqi/version'
|
11
11
|
|
12
12
|
module Geoloqi
|
13
|
-
API_VERSION = 1
|
14
|
-
API_URL = 'https://api.geoloqi.com'
|
15
|
-
OAUTH_URL = 'https://beta.geoloqi.com/oauth/authorize'
|
16
13
|
@@adapter = :net_http
|
17
14
|
@@enable_logging = false
|
18
15
|
@@config = Config.new
|
19
16
|
|
20
17
|
class << self
|
18
|
+
def api_version
|
19
|
+
1
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_url
|
23
|
+
'https://api.geoloqi.com'
|
24
|
+
end
|
25
|
+
|
26
|
+
def oauth_url
|
27
|
+
'https://beta.geoloqi.com/oauth/authorize'
|
28
|
+
end
|
29
|
+
|
21
30
|
def config(opts=nil)
|
22
31
|
return @@config if opts.nil?
|
23
32
|
@@config = Config.new opts
|
@@ -37,7 +46,7 @@ module Geoloqi
|
|
37
46
|
|
38
47
|
def authorize_url(client_id=nil, redirect_uri=@@config.redirect_uri, opts={})
|
39
48
|
raise "client_id required to authorize url. Pass with Geoloqi.config" unless client_id
|
40
|
-
url = "#{
|
49
|
+
url = "#{oauth_url}?response_type=code&client_id=#{Rack::Utils.escape client_id}&redirect_uri=#{Rack::Utils.escape redirect_uri}"
|
41
50
|
url += "&#{Rack::Utils.build_query opts}" unless opts.empty?
|
42
51
|
url
|
43
52
|
end
|
data/lib/geoloqi/session.rb
CHANGED
@@ -9,7 +9,7 @@ module Geoloqi
|
|
9
9
|
self.auth = opts[:auth] || {}
|
10
10
|
self.auth[:access_token] = opts[:access_token] if opts[:access_token]
|
11
11
|
|
12
|
-
@connection = Faraday.new(:url =>
|
12
|
+
@connection = Faraday.new(:url => Geoloqi.api_url) do |builder|
|
13
13
|
builder.response :logger if @config.enable_logging
|
14
14
|
builder.adapter @config.adapter || :net_http
|
15
15
|
end
|
@@ -65,7 +65,7 @@ module Geoloqi
|
|
65
65
|
def execute(meth, path, query=nil)
|
66
66
|
query = Rack::Utils.parse_query query if query.is_a?(String)
|
67
67
|
raw = @connection.send(meth) do |req|
|
68
|
-
req.url "/#{
|
68
|
+
req.url "/#{Geoloqi.api_version.to_s}/#{path.gsub(/^\//, '')}"
|
69
69
|
req.headers = headers
|
70
70
|
|
71
71
|
if query
|
data/lib/geoloqi/version.rb
CHANGED
data/spec/geoloqi_spec.rb
CHANGED
@@ -17,7 +17,7 @@ def auth_headers(access_token='access_token1234')
|
|
17
17
|
'Authorization' => "OAuth #{access_token}"}
|
18
18
|
end
|
19
19
|
|
20
|
-
def api_url(path); "#{Geoloqi
|
20
|
+
def api_url(path); "#{Geoloqi.api_url}/#{Geoloqi.api_version}/#{path}" end
|
21
21
|
|
22
22
|
Wrong.config.alias_assert :expect
|
23
23
|
include WebMock::API
|
@@ -33,7 +33,7 @@ describe Geoloqi do
|
|
33
33
|
describe 'authorize_url' do
|
34
34
|
it 'is valid' do
|
35
35
|
authorize_url = Geoloqi.authorize_url 'test', 'http://blah.blah/test'
|
36
|
-
expect { authorize_url == "#{Geoloqi
|
36
|
+
expect { authorize_url == "#{Geoloqi.oauth_url}?"+
|
37
37
|
'response_type=code&'+
|
38
38
|
"client_id=#{Rack::Utils.escape 'test'}&"+
|
39
39
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}" }
|
@@ -41,7 +41,7 @@ describe Geoloqi do
|
|
41
41
|
|
42
42
|
it 'is valid with scope' do
|
43
43
|
authorize_url = Geoloqi.authorize_url 'test', 'http://blah.blah/test', :scope => 'can_party_hard'
|
44
|
-
expect { authorize_url == "#{Geoloqi
|
44
|
+
expect { authorize_url == "#{Geoloqi.oauth_url}?"+
|
45
45
|
'response_type=code&'+
|
46
46
|
"client_id=#{Rack::Utils.escape 'test'}&"+
|
47
47
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}&"+
|
@@ -84,7 +84,7 @@ describe Geoloqi::Config do
|
|
84
84
|
it 'returns authorize url' do
|
85
85
|
Geoloqi.config :client_id => CLIENT_ID, :client_secret => CLIENT_SECRET, :redirect_uri => 'http://blah.blah/test'
|
86
86
|
authorize_url = Geoloqi.authorize_url 'test'
|
87
|
-
expect { authorize_url == "#{Geoloqi
|
87
|
+
expect { authorize_url == "#{Geoloqi.oauth_url}?"+
|
88
88
|
'response_type=code&'+
|
89
89
|
"client_id=#{Rack::Utils.escape 'test'}&"+
|
90
90
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}" }
|
@@ -269,7 +269,7 @@ describe Geoloqi::Session do
|
|
269
269
|
|
270
270
|
it 'gets authorize url' do
|
271
271
|
authorize_url = @session.authorize_url 'http://blah.blah/test'
|
272
|
-
expect { authorize_url == "#{Geoloqi
|
272
|
+
expect { authorize_url == "#{Geoloqi.oauth_url}?"+
|
273
273
|
"response_type=code&"+
|
274
274
|
"client_id=#{Rack::Utils.escape CLIENT_ID}&"+
|
275
275
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}" }
|
@@ -277,7 +277,7 @@ describe Geoloqi::Session do
|
|
277
277
|
|
278
278
|
it 'gets authorize url with scope' do
|
279
279
|
authorize_url = @session.authorize_url 'http://blah.blah/test', :scope => 'party_hard'
|
280
|
-
expect { authorize_url == "#{Geoloqi
|
280
|
+
expect { authorize_url == "#{Geoloqi.oauth_url}?"+
|
281
281
|
"response_type=code&"+
|
282
282
|
"client_id=#{Rack::Utils.escape CLIENT_ID}&"+
|
283
283
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}&"+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: geoloqi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.22
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kyle Drake
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-08-
|
14
|
+
date: 2011-08-24 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|