geoloqi 0.9.23 → 0.9.24
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/config.rb +1 -3
- data/lib/geoloqi/session.rb +1 -2
- data/lib/geoloqi/version.rb +1 -1
- data/spec/geoloqi_spec.rb +12 -3
- metadata +1 -1
data/lib/geoloqi/config.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Geoloqi
|
2
2
|
class Config
|
3
|
-
attr_accessor :client_id, :client_secret, :redirect_uri, :adapter, :
|
3
|
+
attr_accessor :client_id, :client_secret, :redirect_uri, :adapter, :logger, :use_hashie_mash, :throw_exceptions
|
4
4
|
def initialize(opts={})
|
5
|
-
self.enable_logging ||= false
|
6
5
|
self.use_hashie_mash ||= false
|
7
6
|
self.throw_exceptions ||= true
|
8
7
|
opts.each {|k,v| send("#{k}=", v)}
|
@@ -11,7 +10,6 @@ module Geoloqi
|
|
11
10
|
rescue LoadError
|
12
11
|
raise Error, "You've requested Hashie::Mash, but the gem is not available. Don't set use_hashie_mash in your config, or install the hashie gem"
|
13
12
|
end
|
14
|
-
raise ArgumentError, 'enable_logging must be boolean' unless [true, false].include? self.enable_logging
|
15
13
|
end
|
16
14
|
|
17
15
|
def client_id?
|
data/lib/geoloqi/session.rb
CHANGED
@@ -10,7 +10,6 @@ module Geoloqi
|
|
10
10
|
self.auth[:access_token] = opts[:access_token] if opts[:access_token]
|
11
11
|
|
12
12
|
@connection = Faraday.new(:url => Geoloqi.api_url) do |builder|
|
13
|
-
# builder.response :logger if @config.enable_logging
|
14
13
|
builder.adapter @config.adapter || :net_http
|
15
14
|
end
|
16
15
|
end
|
@@ -72,7 +71,7 @@ module Geoloqi
|
|
72
71
|
meth == :get ? req.params = query : req.body = query.to_json
|
73
72
|
end
|
74
73
|
end
|
75
|
-
puts "Geoloqi::Session - #{meth} #{path}?#{Rack::Utils.build_query query}
|
74
|
+
@config.logger.puts "Geoloqi::Session - #{meth.to_s.upcase} #{path}?#{Rack::Utils.build_query query}:\nStatus: #{raw.status}\nHeaders: #{raw.headers.inspect}\n#{raw.body}" if @config.logger
|
76
75
|
Response.new raw.status, raw.headers, raw.body
|
77
76
|
end
|
78
77
|
|
data/lib/geoloqi/version.rb
CHANGED
data/spec/geoloqi_spec.rb
CHANGED
@@ -90,10 +90,19 @@ describe Geoloqi::Config do
|
|
90
90
|
"redirect_uri=#{Rack::Utils.escape 'http://blah.blah/test'}" }
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
94
|
-
it '
|
95
|
-
|
93
|
+
|
94
|
+
it 'displays log information if logger is provided' do
|
95
|
+
stub_request(:get, api_url('account/username?cats=lol')).
|
96
|
+
with(:headers => {'Authorization'=>'OAuth access_token1234'}).
|
97
|
+
to_return(:body => {'username' => 'bulbasaurrulzok'}.to_json)
|
98
|
+
|
99
|
+
io = StringIO.new
|
100
|
+
Geoloqi.config :client_id => CLIENT_ID, :client_secret => CLIENT_SECRET, :logger => io
|
101
|
+
|
102
|
+
Geoloqi.get ACCESS_TOKEN, 'account/username', :cats => 'lol'
|
103
|
+
expect { io.string =~ /Geoloqi::Session/ }
|
96
104
|
end
|
105
|
+
|
97
106
|
|
98
107
|
it 'correctly checks booleans for client_id and client_secret' do
|
99
108
|
[:client_id, :client_secret].each do |k|
|