geoloqi 0.9.12 → 0.9.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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'
@@ -1,5 +1,5 @@
1
1
  module Geoloqi
2
2
  def self.version
3
- '0.9.12'
3
+ '0.9.13'
4
4
  end
5
5
  end
@@ -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.12
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-08 00:00:00 -07:00
14
+ date: 2011-07-12 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency