koine-rest_client 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11c13b889e0dd93439ed547233da15fcadc920721f8c8eb8e71f60ec2e1dd835
4
- data.tar.gz: 3f8c917838bb488ca456e8439b2f846462530b29115eb9b2df3918fcfabf8341
3
+ metadata.gz: 5d4381e7f1bd444c3c2c8077d4b4c3b49fd369687a329d08c96d554e94d22284
4
+ data.tar.gz: 18cac30027e56414e700cf6214e3bbfbdc8ea4291ffbf6e284f17e67e0f23025
5
5
  SHA512:
6
- metadata.gz: c335ee8ca7d89cee48ab922b7489c61bba707cf3d97e7a66fc9f4a4e47d866918429624042c3ecfb75cd7abb67de2e3c38d02bb4939a00557d72fd409655e519
7
- data.tar.gz: 71e17720a95bf74661fe368a63162c03206541fe52306908e144d1e6032095be80dc40d9f6b04ca4243ce7475c3854c69194035d71de36b02f6ef25bdfbb1d2e
6
+ metadata.gz: '0526944dac61323072d5d53b62c2211f625a1d3630aa8585e3cf7bb232059ab8fc077ef7f443ec7392ef0600081e9efa1e5a993a7e9cfab7b223f5457ca11798'
7
+ data.tar.gz: 7b1589c08e089ea1240a740206f72b38526be10c955d8e39b3eaad0679a4587c61301a988747669ab5856f910134120c7852d79685d4102f9b516f798800e439
@@ -0,0 +1,30 @@
1
+ name: RSpec
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - '*'
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: RSpec with ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '3.0.2'
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby }}
24
+ bundler-cache: true
25
+ - name: Run the default task
26
+ run: bundle exec rake
27
+ - name: Coveralls
28
+ uses: coverallsapp/github-action@master
29
+ with:
30
+ github-token: ${{ secrets.GITHUB_TOKEN }}
data/Gemfile CHANGED
@@ -4,3 +4,15 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in koine-rest_client.gemspec
6
6
  gemspec
7
+
8
+ gem 'awesome_print'
9
+ gem 'bundler', '~> 2.0'
10
+ gem 'object_comparator'
11
+ gem 'rake', '~> 10.0'
12
+ gem 'reek'
13
+ gem 'rspec', '~> 3.0'
14
+ gem 'rubocop'
15
+ gem 'rubocop-performance'
16
+ gem 'rubocop-rspec'
17
+ gem 'simplecov', require: false
18
+ gem 'simplecov-lcov', require: false
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Koine::RestClient
2
2
 
3
+ [![RSpec](https://github.com/mjacobus/koine-rest_client/actions/workflows/rspec.yml/badge.svg)](https://github.com/mjacobus/koine-rest_client/actions/workflows/rspec.yml)
4
+ [![Coverage Status](https://coveralls.io/repos/github/mjacobus/koine-rest_client/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/koine-rest_client?branch=master)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8b7bf0a115757ca74d9a/maintainability)](https://codeclimate.com/github/mjacobus/koine-rest_client/maintainability)
6
+
3
7
  Another http client with async
4
8
 
5
9
  ## Installation
@@ -32,15 +32,4 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency 'addressable', '>= 2.3'
34
34
  spec.add_dependency 'httparty', '>= 0.17.0'
35
-
36
- spec.add_development_dependency 'bundler', '~> 2.0'
37
- spec.add_development_dependency 'rake', '~> 10.0'
38
- spec.add_development_dependency 'reek'
39
- spec.add_development_dependency 'rspec', '~> 3.0'
40
- spec.add_development_dependency 'rubocop'
41
- spec.add_development_dependency 'rubocop-performance'
42
- spec.add_development_dependency 'rubocop-rspec'
43
- spec.add_development_dependency 'simplecov'
44
- spec.add_development_dependency 'object_comparator'
45
- spec.add_development_dependency 'awesome_print'
46
35
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Koine
4
+ module RestClient
5
+ # base class for http errors
6
+ class Error < StandardError
7
+ attr_reader :response
8
+
9
+ def initialize(response)
10
+ @response = response
11
+ end
12
+
13
+ def message
14
+ @message ||= @response&.body
15
+ end
16
+ end
17
+
18
+ # 400
19
+ BadRequestError = Class.new(Error)
20
+ NotFoundError = Class.new(Error)
21
+ UnauthorizedError = Class.new(Error)
22
+ PaymentRequiredExperimentalError = Class.new(Error)
23
+ ForbiddenError = Class.new(Error)
24
+ MethodNotAllowedError = Class.new(Error)
25
+ NotAcceptableError = Class.new(Error)
26
+ ProxyAuthenticationRequiredError = Class.new(Error)
27
+ RequestTimeoutError = Class.new(Error)
28
+ ConflictError = Class.new(Error)
29
+ GoneError = Class.new(Error)
30
+ LengthRequiredError = Class.new(Error)
31
+ PreconditionFailedError = Class.new(Error)
32
+ PayloadTooLargeError = Class.new(Error)
33
+ URITooLongError = Class.new(Error)
34
+ UnsupportedMediaTypeError = Class.new(Error)
35
+ RangeNotSatisfiableError = Class.new(Error)
36
+ ExpectationFailedError = Class.new(Error)
37
+ ImATeapotError = Class.new(Error)
38
+
39
+ # 500
40
+ InternalServerError = Class.new(Error)
41
+ NotImplementedError = Class.new(Error)
42
+ BadGatewayError = Class.new(Error)
43
+ ServiceUnavailableError = Class.new(Error)
44
+ GatewayTimeoutError = Class.new(Error)
45
+ HTTPVersionNotSupportedError = Class.new(Error)
46
+ VariantAlsoNegotiatesError = Class.new(Error)
47
+ InsufficientStorageError = Class.new(Error)
48
+ LoopDetectedError = Class.new(Error)
49
+ NotExtendedError = Class.new(Error)
50
+ NetworkAuthenticationRequiredError = Class.new(Error)
51
+ end
52
+ end
@@ -23,8 +23,35 @@ module Koine
23
23
  def error_for_code(code)
24
24
  {
25
25
  400 => BadRequestError,
26
+ 401 => UnauthorizedError,
27
+ 402 => PaymentRequiredExperimentalError,
28
+ 403 => ForbiddenError,
26
29
  404 => NotFoundError,
27
- 500 => InternalServerError
30
+ 405 => MethodNotAllowedError,
31
+ 406 => NotAcceptableError,
32
+ 407 => ProxyAuthenticationRequiredError,
33
+ 408 => RequestTimeoutError,
34
+ 409 => ConflictError,
35
+ 410 => GoneError,
36
+ 411 => LengthRequiredError,
37
+ 412 => PreconditionFailedError,
38
+ 413 => PayloadTooLargeError,
39
+ 414 => URITooLongError,
40
+ 415 => UnsupportedMediaTypeError,
41
+ 416 => RangeNotSatisfiableError,
42
+ 417 => ExpectationFailedError,
43
+ 418 => ImATeapotError,
44
+ 500 => InternalServerError,
45
+ 501 => NotImplementedError,
46
+ 502 => BadGatewayError,
47
+ 503 => ServiceUnavailableError,
48
+ 504 => GatewayTimeoutError,
49
+ 505 => HTTPVersionNotSupportedError,
50
+ 506 => VariantAlsoNegotiatesError,
51
+ 507 => InsufficientStorageError,
52
+ 508 => LoopDetectedError,
53
+ 510 => NotExtendedError,
54
+ 511 => NetworkAuthenticationRequiredError
28
55
  }.fetch(code) { Error }
29
56
  end
30
57
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Koine
4
4
  module RestClient
5
- VERSION = '1.0.1'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
@@ -2,15 +2,12 @@
2
2
 
3
3
  require 'httparty'
4
4
  require 'koine/url'
5
- require 'koine/rest_client/error'
5
+ require 'koine/rest_client/errors'
6
6
  require 'koine/rest_client/version'
7
7
  require 'koine/rest_client/client'
8
8
  require 'koine/rest_client/async_builder'
9
9
  require 'koine/rest_client/async_queue'
10
10
  require 'koine/rest_client/response_parser'
11
- require 'koine/rest_client/bad_request_error'
12
- require 'koine/rest_client/not_found_error'
13
- require 'koine/rest_client/internal_server_error'
14
11
  require 'koine/rest_client/request'
15
12
  require 'koine/rest_client/adapters/http_party_adapter'
16
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koine-rest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -38,146 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.17.0
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '10.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '10.0'
69
- - !ruby/object:Gem::Dependency
70
- name: reek
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '3.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '3.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-performance
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: simplecov
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: object_comparator
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: awesome_print
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
41
  description: Another http client - with support to async calls
182
42
  email:
183
43
  - marcelo.jacobus@gmail.com
@@ -185,6 +45,7 @@ executables: []
185
45
  extensions: []
186
46
  extra_rdoc_files: []
187
47
  files:
48
+ - ".github/workflows/rspec.yml"
188
49
  - ".gitignore"
189
50
  - ".reek.yml"
190
51
  - ".rspec"
@@ -204,11 +65,8 @@ files:
204
65
  - lib/koine/rest_client/adapters/http_party_adapter.rb
205
66
  - lib/koine/rest_client/async_builder.rb
206
67
  - lib/koine/rest_client/async_queue.rb
207
- - lib/koine/rest_client/bad_request_error.rb
208
68
  - lib/koine/rest_client/client.rb
209
- - lib/koine/rest_client/error.rb
210
- - lib/koine/rest_client/internal_server_error.rb
211
- - lib/koine/rest_client/not_found_error.rb
69
+ - lib/koine/rest_client/errors.rb
212
70
  - lib/koine/rest_client/request.rb
213
71
  - lib/koine/rest_client/response_parser.rb
214
72
  - lib/koine/rest_client/rspec_mock_client.rb
@@ -222,7 +80,7 @@ metadata:
222
80
  homepage_uri: https://github.com/mjacobus/koine-rest_client
223
81
  source_code_uri: https://github.com/mjacobus/koine-rest_client
224
82
  changelog_uri: https://github.com/mjacobus/koine-rest_client/CHANGELOG.md
225
- post_install_message:
83
+ post_install_message:
226
84
  rdoc_options: []
227
85
  require_paths:
228
86
  - lib
@@ -237,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
95
  - !ruby/object:Gem::Version
238
96
  version: '0'
239
97
  requirements: []
240
- rubygems_version: 3.0.3
241
- signing_key:
98
+ rubygems_version: 3.2.33
99
+ signing_key:
242
100
  specification_version: 4
243
101
  summary: Another http client
244
102
  test_files: []
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koine
4
- module RestClient
5
- # bad request error
6
- class BadRequestError < Error
7
- end
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koine
4
- module RestClient
5
- # base class for http errors
6
- class Error < StandardError
7
- attr_reader :response
8
-
9
- def initialize(response)
10
- @response = response
11
- end
12
- end
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koine
4
- module RestClient
5
- # internal server error
6
- class InternalServerError < Error
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Koine
4
- module RestClient
5
- # not found error
6
- class NotFoundError < Error
7
- end
8
- end
9
- end