ddy_remote_resource 0.4.11 → 1.0.0.rc1

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/Guardfile +3 -0
  4. data/lib/remote_resource.rb +77 -34
  5. data/lib/remote_resource/base.rb +20 -8
  6. data/lib/remote_resource/connection.rb +26 -5
  7. data/lib/remote_resource/connection_options.rb +5 -3
  8. data/lib/remote_resource/querying/finder_methods.rb +3 -3
  9. data/lib/remote_resource/querying/persistence_methods.rb +17 -12
  10. data/lib/remote_resource/request.rb +96 -62
  11. data/lib/remote_resource/response.rb +5 -1
  12. data/lib/remote_resource/rest.rb +13 -17
  13. data/lib/remote_resource/url_naming.rb +4 -10
  14. data/lib/remote_resource/url_naming_determination.rb +1 -3
  15. data/lib/remote_resource/util.rb +64 -0
  16. data/lib/remote_resource/version.rb +1 -1
  17. data/remote_resource.gemspec +2 -2
  18. data/spec/fixtures/text_file.txt +1 -0
  19. data/spec/integration/all_spec.rb +166 -0
  20. data/spec/integration/collection_prefix_spec.rb +99 -0
  21. data/spec/integration/create_spec.rb +181 -0
  22. data/spec/integration/destroy_spec.rb +252 -0
  23. data/spec/integration/find_by_spec.rb +168 -0
  24. data/spec/integration/find_spec.rb +139 -0
  25. data/spec/integration/headers_spec.rb +222 -0
  26. data/spec/integration/naming_spec.rb +138 -0
  27. data/spec/integration/save_spec.rb +320 -0
  28. data/spec/integration/update_attributes_spec.rb +221 -0
  29. data/spec/integration/where_spec.rb +152 -0
  30. data/spec/lib/extensions/ethon/easy/queryable_spec.rb +4 -4
  31. data/spec/lib/remote_resource/base_spec.rb +54 -110
  32. data/spec/lib/remote_resource/builder_spec.rb +1 -1
  33. data/spec/lib/remote_resource/collection_spec.rb +1 -1
  34. data/spec/lib/remote_resource/connection_options_spec.rb +20 -17
  35. data/spec/lib/remote_resource/connection_spec.rb +36 -27
  36. data/spec/lib/remote_resource/querying/finder_methods_spec.rb +199 -72
  37. data/spec/lib/remote_resource/querying/persistence_methods_spec.rb +228 -220
  38. data/spec/lib/remote_resource/request_spec.rb +313 -342
  39. data/spec/lib/remote_resource/response_spec.rb +9 -3
  40. data/spec/lib/remote_resource/rest_spec.rb +11 -11
  41. data/spec/lib/remote_resource/url_naming_determination_spec.rb +1 -1
  42. data/spec/lib/remote_resource/url_naming_spec.rb +7 -22
  43. data/spec/lib/remote_resource/util_spec.rb +56 -0
  44. data/spec/lib/remote_resource/version_spec.rb +2 -3
  45. data/spec/spec_helper.rb +37 -0
  46. metadata +33 -22
  47. data/lib/remote_resource/http_errors.rb +0 -33
  48. data/lib/remote_resource/response_handeling.rb +0 -48
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RemoteResource::Response do
3
+ RSpec.describe RemoteResource::Response do
4
4
 
5
5
  describe '#original_response' do
6
6
  it 'is private' do
@@ -15,7 +15,7 @@ describe RemoteResource::Response do
15
15
  end
16
16
 
17
17
  describe 'Typhoeus::Response' do
18
- let(:typhoeus_options) { { body: 'typhoeus_response_body', code: 200 } }
18
+ let(:typhoeus_options) { { body: 'typhoeus_response_body', code: 200, headers: { 'Content-Type' => 'application/json', 'Server' => 'nginx/1.4.6 (Ubuntu)' } } }
19
19
  let(:typhoeus_response) { Typhoeus::Response.new typhoeus_options }
20
20
  let(:response) { described_class.new typhoeus_response }
21
21
 
@@ -37,6 +37,12 @@ describe RemoteResource::Response do
37
37
  expect(response.response_code).to eql 200
38
38
  end
39
39
  end
40
+
41
+ describe '#response_headers' do
42
+ it 'returns the response headers of the original response' do
43
+ expect(response.response_headers).to eql({ 'Content-Type' => 'application/json', 'Server' => 'nginx/1.4.6 (Ubuntu)' })
44
+ end
45
+ end
40
46
  end
41
47
 
42
48
  describe '#unprocessable_entity?' do
@@ -246,4 +252,4 @@ describe RemoteResource::Response do
246
252
  end
247
253
  end
248
254
 
249
- end
255
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RemoteResource::REST do
3
+ RSpec.describe RemoteResource::REST do
4
4
 
5
5
  module RemoteResource
6
6
  class RESTDummy
@@ -32,7 +32,7 @@ describe RemoteResource::REST do
32
32
  before { allow_any_instance_of(RemoteResource::Request).to receive(:perform) { response } }
33
33
 
34
34
  describe '.get' do
35
- it 'performs a RemoteResource::Request with the rest_action :get' do
35
+ it 'performs a RemoteResource::Request with the http_action :get' do
36
36
  expect(RemoteResource::Request).to receive(:new).with(dummy_class, :get, params, connection_options).and_call_original
37
37
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
38
38
  dummy_class.get params, connection_options
@@ -40,7 +40,7 @@ describe RemoteResource::REST do
40
40
  end
41
41
 
42
42
  describe '.put' do
43
- it 'performs a RemoteResource::Request with the rest_action :put' do
43
+ it 'performs a RemoteResource::Request with the http_action :put' do
44
44
  expect(RemoteResource::Request).to receive(:new).with(dummy_class, :put, attributes, connection_options).and_call_original
45
45
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
46
46
  dummy_class.put attributes, connection_options
@@ -48,7 +48,7 @@ describe RemoteResource::REST do
48
48
  end
49
49
 
50
50
  describe '.patch' do
51
- it 'performs a RemoteResource::Request with the rest_action :patch' do
51
+ it 'performs a RemoteResource::Request with the http_action :patch' do
52
52
  expect(RemoteResource::Request).to receive(:new).with(dummy_class, :patch, attributes, connection_options).and_call_original
53
53
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
54
54
  dummy_class.patch attributes, connection_options
@@ -56,7 +56,7 @@ describe RemoteResource::REST do
56
56
  end
57
57
 
58
58
  describe '.post' do
59
- it 'performs a RemoteResource::Request with the rest_action :post' do
59
+ it 'performs a RemoteResource::Request with the http_action :post' do
60
60
  expect(RemoteResource::Request).to receive(:new).with(dummy_class, :post, attributes, connection_options).and_call_original
61
61
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
62
62
  dummy_class.post attributes, connection_options
@@ -64,7 +64,7 @@ describe RemoteResource::REST do
64
64
  end
65
65
 
66
66
  describe '.delete' do
67
- it 'performs a RemoteResource::Request with the rest_action :delete' do
67
+ it 'performs a RemoteResource::Request with the http_action :delete' do
68
68
  expect(RemoteResource::Request).to receive(:new).with(dummy_class, :delete, attributes, connection_options).and_call_original
69
69
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
70
70
  dummy_class.delete(attributes, connection_options)
@@ -72,7 +72,7 @@ describe RemoteResource::REST do
72
72
  end
73
73
 
74
74
  describe '#get' do
75
- it 'performs a RemoteResource::Request with the rest_action :get' do
75
+ it 'performs a RemoteResource::Request with the http_action :get' do
76
76
  expect(RemoteResource::Request).to receive(:new).with(dummy, :get, params, connection_options).and_call_original
77
77
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
78
78
  dummy.get params, connection_options
@@ -80,7 +80,7 @@ describe RemoteResource::REST do
80
80
  end
81
81
 
82
82
  describe '#put' do
83
- it 'performs a RemoteResource::Request with the rest_action :put' do
83
+ it 'performs a RemoteResource::Request with the http_action :put' do
84
84
  expect(RemoteResource::Request).to receive(:new).with(dummy, :put, attributes, connection_options).and_call_original
85
85
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
86
86
  dummy.put attributes, connection_options
@@ -88,7 +88,7 @@ describe RemoteResource::REST do
88
88
  end
89
89
 
90
90
  describe '#patch' do
91
- it 'performs a RemoteResource::Request with the rest_action :patch' do
91
+ it 'performs a RemoteResource::Request with the http_action :patch' do
92
92
  expect(RemoteResource::Request).to receive(:new).with(dummy, :patch, attributes, connection_options).and_call_original
93
93
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
94
94
  dummy.patch attributes, connection_options
@@ -96,7 +96,7 @@ describe RemoteResource::REST do
96
96
  end
97
97
 
98
98
  describe '#post' do
99
- it 'performs a RemoteResource::Request with the rest_action :post' do
99
+ it 'performs a RemoteResource::Request with the http_action :post' do
100
100
  expect(RemoteResource::Request).to receive(:new).with(dummy, :post, attributes, connection_options).and_call_original
101
101
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
102
102
  dummy.post attributes, connection_options
@@ -104,7 +104,7 @@ describe RemoteResource::REST do
104
104
  end
105
105
 
106
106
  describe '#delete' do
107
- it 'performs a RemoteResource::Request with the rest_action :delete' do
107
+ it 'performs a RemoteResource::Request with the http_action :delete' do
108
108
  expect(RemoteResource::Request).to receive(:new).with(dummy, :delete, attributes, connection_options).and_call_original
109
109
  expect_any_instance_of(RemoteResource::Request).to receive(:perform)
110
110
  dummy.delete(attributes, connection_options)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RemoteResource::UrlNamingDetermination do
3
+ RSpec.describe RemoteResource::UrlNamingDetermination do
4
4
 
5
5
  module RemoteResource
6
6
  class UrlNamingDeterminationDummy
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RemoteResource::UrlNaming do
3
+ RSpec.describe RemoteResource::UrlNaming do
4
4
 
5
5
  module RemoteResource
6
6
  class UrlNamingDummy
@@ -35,32 +35,17 @@ describe RemoteResource::UrlNaming do
35
35
  end
36
36
 
37
37
  describe '.app_host' do
38
- context 'when the env is given as an argument' do
39
- it 'uses the host specified in the CONFIG constant for the given env' do
40
- stub_const("CONFIG", { test: { apps: { dummy: 'https://foobar.test.com' } } })
41
-
42
- expect(dummy_class.app_host 'dummy', 'test').to eql 'https://foobar.test.com'
43
- end
44
- end
45
-
46
- context 'when the env is NOT given as an argument' do
47
- it 'uses the host specified in the CONFIG constant for the development env' do
48
- stub_const("CONFIG", { development: { apps: { dummy: 'https://foobar.development.com' } } })
49
-
50
- expect(dummy_class.app_host 'dummy').to eql 'https://foobar.development.com'
51
- end
38
+ it 'warns that the method is deprecated' do
39
+ expect(dummy_class).to receive(:warn).with('[DEPRECATION] `.app_host` is deprecated. Please use a different method to determine the site.')
40
+ dummy_class.app_host('dummy', 'test')
52
41
  end
53
42
  end
54
43
 
55
44
  describe '.base_url' do
56
- it 'uses the RemoteResource::UrlNamingDetermination class to determine the base_url' do
57
- expect(RemoteResource::UrlNamingDetermination).to receive(:new).with(dummy_class).and_call_original
45
+ it 'warns that the method is deprecated' do
46
+ expect(dummy_class).to receive(:warn).with('[DEPRECATION] `.base_url` is deprecated. Please use the connection_options[:base_url] when querying instead.')
58
47
  dummy_class.base_url
59
48
  end
60
-
61
- it 'returns the determined base_url' do
62
- expect(dummy_class.base_url).to eql 'https://foobar.com/url_naming_dummy'
63
- end
64
49
  end
65
50
 
66
51
  describe '.use_relative_model_naming?' do
@@ -69,4 +54,4 @@ describe RemoteResource::UrlNaming do
69
54
  end
70
55
  end
71
56
 
72
- end
57
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RemoteResource::Util do
4
+
5
+ describe '.filter_params' do
6
+ let(:scenarios) do
7
+ [
8
+ { params: '{"account_migration":{"username":"foo","password":"bar"}}', expected_params: '{"account_migration":{"username":"foo","password":[FILTERED]}}' },
9
+ { params: '{"account_migration":{"password":"bar","username":"foo"}}', expected_params: '{"account_migration":{"password":[FILTERED],"username":"foo"}}' },
10
+ { params: '?username=foo&password=bar', expected_params: '?username=foo&password=[FILTERED]' },
11
+ { params: '?password=bar&username=foo', expected_params: '?password=[FILTERED]&username=foo' },
12
+ { params: nil, expected_params: '' }
13
+ ]
14
+ end
15
+
16
+ it 'removes sensitive information of the filtered params' do
17
+ aggregate_failures do
18
+ scenarios.each do |scenario|
19
+ result = described_class.filter_params(scenario[:params], filtered_params: ['password'])
20
+
21
+ expect(result).to eql scenario[:expected_params]
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ describe '.encode_params_to_query' do
28
+ let(:scenarios) do
29
+ [
30
+ { params: nil, expected_query: '' },
31
+ { params: {}, expected_query: '' },
32
+ { params: [], expected_query: '' },
33
+ { params: 'Mies', expected_query: 'Mies' },
34
+ { params: { name: 'Mies' }, expected_query: 'name=Mies' },
35
+ { params: { name: 'Mies', age: 29, famous: true, smart: nil }, expected_query: 'name=Mies&age=29&famous=true&smart=' },
36
+ { params: { page: 5, limit: 15 }, expected_query: 'page=5&limit=15' },
37
+ { params: { labels: [1, '2', 'three'] }, expected_query: 'labels[]=1&labels[]=2&labels[]=three' },
38
+ { params: { page: 5, limit: 15, order: [:created_at, :desc] }, expected_query: 'page=5&limit=15&order[]=created_at&order[]=desc' },
39
+ { params: { page: 5, limit: 15, order: { field: :created_at, direction: :desc } }, expected_query: 'page=5&limit=15&order[field]=created_at&order[direction]=desc' },
40
+ { params: { name: 'Mies', age: 29, famous: true, labels: [1, '2', 'three'], pagination: { page: 5, limit: 15, order: { field: :created_at, direction: :desc } } }, expected_query: 'name=Mies&age=29&famous=true&labels[]=1&labels[]=2&labels[]=three&pagination[page]=5&pagination[limit]=15&pagination[order][field]=created_at&pagination[order][direction]=desc' },
41
+ ]
42
+ end
43
+
44
+ it 'encodes the params to a URL-encoded query' do
45
+ aggregate_failures do
46
+ scenarios.each do |scenario|
47
+ result = described_class.encode_params_to_query(scenario[:params])
48
+ query = CGI.unescape(result)
49
+
50
+ expect(query).to eql scenario[:expected_query]
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe RemoteResource::VERSION do
4
-
5
- it { should eql '0.4.11' }
3
+ RSpec.describe RemoteResource::VERSION do
4
+ it { is_expected.to eql '1.0.0.rc1' }
6
5
  end
7
6
 
8
7
 
@@ -3,3 +3,40 @@ require 'remote_resource'
3
3
 
4
4
  require 'webmock/rspec'
5
5
  require 'pry'
6
+
7
+ RSpec.configure do |config|
8
+ # rspec-mocks config goes here. You can use an alternate test double
9
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
10
+ config.mock_with :rspec do |mocks|
11
+ # Prevents you from mocking or stubbing a method that does not exist on
12
+ # a real object. This is generally recommended, and will default to
13
+ # `true` in RSpec 4.
14
+ mocks.verify_partial_doubles = true
15
+ end
16
+
17
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
18
+ # For more details, see:
19
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
20
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
21
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
22
+ config.disable_monkey_patching!
23
+
24
+ # These two settings work together to allow you to limit a spec run
25
+ # to individual examples or groups you care about by tagging them with
26
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
27
+ # get run.
28
+ config.filter_run :focus
29
+ config.run_all_when_everything_filtered = true
30
+
31
+ # Run specs in random order to surface order dependencies. If you find an
32
+ # order dependency and want to debug it, you can fix the order by providing
33
+ # the seed, which is printed after each run.
34
+ # --seed 1234
35
+ config.order = :random
36
+
37
+ # Seed global randomization in this process using the `--seed` CLI option.
38
+ # Setting this allows you to use `--seed` to deterministically reproduce
39
+ # test failures related to randomization by passing the same `--seed` value
40
+ # as the one that triggered the failure.
41
+ Kernel.srand config.seed
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddy_remote_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan van der Pas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2016-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.10'
69
- - !ruby/object:Gem::Dependency
70
- name: webmock
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.24'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.24'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: guard
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 1.6.1
103
+ version: '1.6'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 1.6.1
110
+ version: '1.6'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: activesupport
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -249,17 +235,28 @@ files:
249
235
  - lib/remote_resource/collection.rb
250
236
  - lib/remote_resource/connection.rb
251
237
  - lib/remote_resource/connection_options.rb
252
- - lib/remote_resource/http_errors.rb
253
238
  - lib/remote_resource/querying/finder_methods.rb
254
239
  - lib/remote_resource/querying/persistence_methods.rb
255
240
  - lib/remote_resource/request.rb
256
241
  - lib/remote_resource/response.rb
257
- - lib/remote_resource/response_handeling.rb
258
242
  - lib/remote_resource/rest.rb
259
243
  - lib/remote_resource/url_naming.rb
260
244
  - lib/remote_resource/url_naming_determination.rb
245
+ - lib/remote_resource/util.rb
261
246
  - lib/remote_resource/version.rb
262
247
  - remote_resource.gemspec
248
+ - spec/fixtures/text_file.txt
249
+ - spec/integration/all_spec.rb
250
+ - spec/integration/collection_prefix_spec.rb
251
+ - spec/integration/create_spec.rb
252
+ - spec/integration/destroy_spec.rb
253
+ - spec/integration/find_by_spec.rb
254
+ - spec/integration/find_spec.rb
255
+ - spec/integration/headers_spec.rb
256
+ - spec/integration/naming_spec.rb
257
+ - spec/integration/save_spec.rb
258
+ - spec/integration/update_attributes_spec.rb
259
+ - spec/integration/where_spec.rb
263
260
  - spec/lib/extensions/ethon/easy/queryable_spec.rb
264
261
  - spec/lib/remote_resource/base_spec.rb
265
262
  - spec/lib/remote_resource/builder_spec.rb
@@ -273,6 +270,7 @@ files:
273
270
  - spec/lib/remote_resource/rest_spec.rb
274
271
  - spec/lib/remote_resource/url_naming_determination_spec.rb
275
272
  - spec/lib/remote_resource/url_naming_spec.rb
273
+ - spec/lib/remote_resource/util_spec.rb
276
274
  - spec/lib/remote_resource/version_spec.rb
277
275
  - spec/spec_helper.rb
278
276
  homepage: ''
@@ -290,9 +288,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
290
288
  version: '0'
291
289
  required_rubygems_version: !ruby/object:Gem::Requirement
292
290
  requirements:
293
- - - ">="
291
+ - - ">"
294
292
  - !ruby/object:Gem::Version
295
- version: '0'
293
+ version: 1.3.1
296
294
  requirements: []
297
295
  rubyforge_project:
298
296
  rubygems_version: 2.5.1
@@ -300,6 +298,18 @@ signing_key:
300
298
  specification_version: 4
301
299
  summary: RemoteResource, a gem to use resources with REST services.
302
300
  test_files:
301
+ - spec/fixtures/text_file.txt
302
+ - spec/integration/all_spec.rb
303
+ - spec/integration/collection_prefix_spec.rb
304
+ - spec/integration/create_spec.rb
305
+ - spec/integration/destroy_spec.rb
306
+ - spec/integration/find_by_spec.rb
307
+ - spec/integration/find_spec.rb
308
+ - spec/integration/headers_spec.rb
309
+ - spec/integration/naming_spec.rb
310
+ - spec/integration/save_spec.rb
311
+ - spec/integration/update_attributes_spec.rb
312
+ - spec/integration/where_spec.rb
303
313
  - spec/lib/extensions/ethon/easy/queryable_spec.rb
304
314
  - spec/lib/remote_resource/base_spec.rb
305
315
  - spec/lib/remote_resource/builder_spec.rb
@@ -313,5 +323,6 @@ test_files:
313
323
  - spec/lib/remote_resource/rest_spec.rb
314
324
  - spec/lib/remote_resource/url_naming_determination_spec.rb
315
325
  - spec/lib/remote_resource/url_naming_spec.rb
326
+ - spec/lib/remote_resource/util_spec.rb
316
327
  - spec/lib/remote_resource/version_spec.rb
317
328
  - spec/spec_helper.rb
@@ -1,33 +0,0 @@
1
- module RemoteResource
2
- module HTTPErrors
3
-
4
- private
5
-
6
- def raise_http_errors(response)
7
- case response.response_code
8
- when 301, 302, 303, 307 then raise RemoteResource::HTTPRedirectionError, response
9
- when 400 then raise RemoteResource::HTTPBadRequest, response
10
- when 401 then raise RemoteResource::HTTPUnauthorized, response
11
- when 403 then raise RemoteResource::HTTPForbidden, response
12
- when 404 then raise RemoteResource::HTTPNotFound, response
13
- when 405 then raise RemoteResource::HTTPMethodNotAllowed, response
14
- when 406 then raise RemoteResource::HTTPNotAcceptable, response
15
- when 408 then raise RemoteResource::HTTPRequestTimeout, response
16
- when 409 then raise RemoteResource::HTTPConflict, response
17
- when 410 then raise RemoteResource::HTTPGone, response
18
- when 418 then raise RemoteResource::HTTPTeapot, response
19
- when 444 then raise RemoteResource::HTTPNoResponse, response
20
- when 494 then raise RemoteResource::HTTPRequestHeaderTooLarge, response
21
- when 495 then raise RemoteResource::HTTPCertError, response
22
- when 496 then raise RemoteResource::HTTPNoCert, response
23
- when 497 then raise RemoteResource::HTTPToHTTPS, response
24
- when 499 then raise RemoteResource::HTTPClientClosedRequest, response
25
- when 400..499 then raise RemoteResource::HTTPClientError, response
26
- when 500..599 then raise RemoteResource::HTTPServerError, response
27
- else
28
- raise RemoteResource::HTTPError, response
29
- end
30
- end
31
-
32
- end
33
- end