geoloqi 0.9.12 → 0.9.13
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 +2 -1
- data/lib/geoloqi/session.rb +1 -1
- data/lib/geoloqi/version.rb +1 -1
- data/spec/geoloqi_spec.rb +10 -0
- metadata +2 -2
data/lib/geoloqi/config.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Geoloqi
|
2
2
|
class Config
|
3
|
-
attr_accessor :client_id, :client_secret, :redirect_uri, :adapter, :enable_logging, :use_hashie_mash
|
3
|
+
attr_accessor :client_id, :client_secret, :redirect_uri, :adapter, :enable_logging, :use_hashie_mash, :throw_exceptions
|
4
4
|
def initialize(opts={})
|
5
5
|
opts.each {|k,v| send("#{k}=", v)}
|
6
6
|
self.enable_logging ||= false
|
7
7
|
self.use_hashie_mash ||= false
|
8
|
+
self.throw_exceptions ||= true
|
8
9
|
begin
|
9
10
|
require 'hashie' if self.use_hashie_mash && !defined?(Hashie::Mash)
|
10
11
|
rescue LoadError
|
data/lib/geoloqi/session.rb
CHANGED
@@ -55,7 +55,7 @@ module Geoloqi
|
|
55
55
|
end
|
56
56
|
|
57
57
|
hash = JSON.parse response.body
|
58
|
-
raise ApiError.new(response.status, hash['error'], hash['error_description']) if hash.is_a?(Hash) && hash['error']
|
58
|
+
raise ApiError.new(response.status, hash['error'], hash['error_description']) if hash.is_a?(Hash) && hash['error'] && !config.throw_exceptions
|
59
59
|
rescue Geoloqi::ApiError
|
60
60
|
raise Error.new('Unable to procure fresh access token from API on second attempt') if retry_attempt > 0
|
61
61
|
if hash['error'] == 'expired_token'
|
data/lib/geoloqi/version.rb
CHANGED
data/spec/geoloqi_spec.rb
CHANGED
@@ -76,6 +76,16 @@ describe Geoloqi::Session do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
describe 'with access token and throw exceptions false' do
|
80
|
+
before do
|
81
|
+
@session = Geoloqi::Session.new :access_token => 'access_token1234', :config => {:throw_exceptions => false}
|
82
|
+
end
|
83
|
+
it 'should not throw api error exception' do
|
84
|
+
response = @session.get 'badmethodcall'
|
85
|
+
expect {response['error'] == 'not_found'}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
79
89
|
describe 'with access token and hashie mash' do
|
80
90
|
before do
|
81
91
|
@session = Geoloqi::Session.new :access_token => 'access_token1234', :config => {:use_hashie_mash => true}
|
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.13
|
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-07-
|
14
|
+
date: 2011-07-12 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|