geoloqi 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/geoloqi.gemspec +2 -2
- data/lib/geoloqi.rb +3 -3
- data/lib/geoloqi/config.rb +2 -2
- data/lib/geoloqi/session.rb +3 -3
- data/lib/geoloqi/version.rb +3 -1
- data/spec/geoloqi_spec.rb +11 -0
- metadata +36 -2
data/geoloqi.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require './lib/geoloqi/version.rb'
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'geoloqi'
|
4
|
-
s.version = Geoloqi
|
4
|
+
s.version = Geoloqi.version
|
5
5
|
s.authors = ['Kyle Drake', 'Aaron Parecki']
|
6
6
|
s.email = ['kyledrake@gmail.com', 'aaron@parecki.com']
|
7
7
|
s.homepage = 'https://github.com/kyledrake/geoloqi-ruby'
|
@@ -20,4 +20,4 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency 'wrong', '= 0.5.0'
|
21
21
|
s.add_development_dependency 'minitest', '= 2.2.2'
|
22
22
|
s.add_development_dependency 'webmock', '= 1.6.4'
|
23
|
-
end
|
23
|
+
end
|
data/lib/geoloqi.rb
CHANGED
@@ -14,15 +14,15 @@ module Geoloqi
|
|
14
14
|
OAUTH_URL = 'https://beta.geoloqi.com/oauth/authorize'
|
15
15
|
@@adapter = :net_http
|
16
16
|
@@enable_logging = false
|
17
|
-
@@config =
|
17
|
+
@@config = Config.new
|
18
18
|
|
19
19
|
def self.config(opts=nil)
|
20
20
|
return @@config if opts.nil?
|
21
21
|
@@config = Config.new opts
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.authorize_url(client_id=nil, redirect_uri
|
24
|
+
def self.authorize_url(client_id=nil, redirect_uri=@@config.redirect_uri)
|
25
25
|
raise "client_id required to authorize url. Pass with Geoloqi.config" unless client_id
|
26
26
|
"#{OAUTH_URL}?response_type=code&client_id=#{Rack::Utils.escape client_id}&redirect_uri=#{Rack::Utils.escape redirect_uri}"
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
data/lib/geoloqi/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Geoloqi
|
2
2
|
class Config
|
3
|
-
attr_accessor :client_id, :client_secret, :adapter, :enable_logging
|
3
|
+
attr_accessor :client_id, :client_secret, :adapter, :enable_logging, :redirect_uri
|
4
4
|
def initialize(opts={})
|
5
5
|
opts.each {|k,v| send("#{k}=", v)}
|
6
6
|
self.enable_logging ||= false
|
@@ -15,4 +15,4 @@ module Geoloqi
|
|
15
15
|
!client_secret.nil? && !client_secret.empty?
|
16
16
|
end
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
data/lib/geoloqi/session.rb
CHANGED
@@ -27,7 +27,7 @@ module Geoloqi
|
|
27
27
|
!access_token.nil?
|
28
28
|
end
|
29
29
|
|
30
|
-
def authorize_url(redirect_uri)
|
30
|
+
def authorize_url(redirect_uri=@config.redirect_uri)
|
31
31
|
Geoloqi.authorize_url @config.client_id, redirect_uri
|
32
32
|
end
|
33
33
|
|
@@ -91,7 +91,7 @@ module Geoloqi
|
|
91
91
|
self.auth
|
92
92
|
end
|
93
93
|
|
94
|
-
def get_auth(code, redirect_uri)
|
94
|
+
def get_auth(code, redirect_uri=@config.redirect_uri)
|
95
95
|
require 'client_id and client_secret are required to get access token' unless @config.client_id? && @config.client_secret?
|
96
96
|
args = {:client_id => @config.client_id,
|
97
97
|
:client_secret => @config.client_secret,
|
@@ -116,7 +116,7 @@ module Geoloqi
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def headers(with_oauth=true)
|
119
|
-
headers = {'Content-Type' => 'application/json', 'User-Agent' => "geoloqi-ruby #{Geoloqi
|
119
|
+
headers = {'Content-Type' => 'application/json', 'User-Agent' => "geoloqi-ruby #{Geoloqi.version}", 'Accept' => 'application/json'}
|
120
120
|
headers['Authorization'] = "OAuth #{access_token}" if with_oauth
|
121
121
|
headers
|
122
122
|
end
|
data/lib/geoloqi/version.rb
CHANGED
data/spec/geoloqi_spec.rb
CHANGED
@@ -27,6 +27,17 @@ describe Geoloqi do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe Geoloqi::Config do
|
30
|
+
describe 'with redirect_uri' do
|
31
|
+
it 'returns authorize url' do
|
32
|
+
Geoloqi.config :client_id => ARGV[0], :client_secret => ARGV[1], :redirect_uri => 'http://blah.blah/test'
|
33
|
+
authorize_url = Geoloqi.authorize_url 'test'
|
34
|
+
expect { authorize_url == "#{Geoloqi::OAUTH_URL}?"+
|
35
|
+
'response_type=code&'+
|
36
|
+
"client_id=#{Rack::Utils.escape 'test'}&"+
|
37
|
+
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}" }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
30
41
|
it 'throws exception if non-boolean value is fed to logging' do
|
31
42
|
expect { rescuing { Geoloqi.config(:client_id => '', :client_secret => '', :enable_logging => :cats )}.class == ArgumentError }
|
32
43
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoloqi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 51
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Kyle Drake
|
@@ -11,7 +16,7 @@ autorequire:
|
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
18
|
|
14
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-15 00:00:00 -07:00
|
15
20
|
default_executable:
|
16
21
|
dependencies:
|
17
22
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +27,9 @@ dependencies:
|
|
22
27
|
requirements:
|
23
28
|
- - ">="
|
24
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
25
33
|
version: "0"
|
26
34
|
type: :runtime
|
27
35
|
version_requirements: *id001
|
@@ -33,6 +41,9 @@ dependencies:
|
|
33
41
|
requirements:
|
34
42
|
- - ">="
|
35
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
36
47
|
version: "0"
|
37
48
|
type: :runtime
|
38
49
|
version_requirements: *id002
|
@@ -44,6 +55,11 @@ dependencies:
|
|
44
55
|
requirements:
|
45
56
|
- - "="
|
46
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 11
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
- 5
|
62
|
+
- 0
|
47
63
|
version: 0.5.0
|
48
64
|
type: :development
|
49
65
|
version_requirements: *id003
|
@@ -55,6 +71,11 @@ dependencies:
|
|
55
71
|
requirements:
|
56
72
|
- - "="
|
57
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 2
|
77
|
+
- 2
|
78
|
+
- 2
|
58
79
|
version: 2.2.2
|
59
80
|
type: :development
|
60
81
|
version_requirements: *id004
|
@@ -66,6 +87,11 @@ dependencies:
|
|
66
87
|
requirements:
|
67
88
|
- - "="
|
68
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 7
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 6
|
94
|
+
- 4
|
69
95
|
version: 1.6.4
|
70
96
|
type: :development
|
71
97
|
version_requirements: *id005
|
@@ -108,12 +134,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
134
|
requirements:
|
109
135
|
- - ">="
|
110
136
|
- !ruby/object:Gem::Version
|
137
|
+
hash: 3
|
138
|
+
segments:
|
139
|
+
- 0
|
111
140
|
version: "0"
|
112
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
142
|
none: false
|
114
143
|
requirements:
|
115
144
|
- - ">="
|
116
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 19
|
147
|
+
segments:
|
148
|
+
- 1
|
149
|
+
- 3
|
150
|
+
- 4
|
117
151
|
version: 1.3.4
|
118
152
|
requirements: []
|
119
153
|
|