eezee 1.0.7 → 1.0.8

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: '091f04a358ff0034437fb934f267c82e74ee10109c3f9f9a89625e3cbcb464bf'
4
- data.tar.gz: 413ad4f550a63cfebd4e688181369264a423f26bfa8fc2b3e1496b3c5552978c
3
+ metadata.gz: d15fad54814782889522712e0b2fce58d831d0a3781ce63959aebd149cbda6e9
4
+ data.tar.gz: d708469dd5d96a66433391f79f7f0908aa36c251cafa02b6a490ae81888790e7
5
5
  SHA512:
6
- metadata.gz: cb1b44f8219ba5bca6b40703c066f3c3da4ff681ac5cd005599866389d9a30bccdc7b52a2e708da8fd99d8adb0846280f3d71c07a30387671a9db2b98738e331
7
- data.tar.gz: 89eef48f82b9a9cd284e2332cdfc2de54a187624c961ae7f8600bbed90e6b68f8f439f6930856e30d19298ed575969531987cb70fa1df513a65cd4e335e8c111
6
+ metadata.gz: 6e08b1abe503f6ea1bd7321682bde827061334f221dd77285c3a66496da59c6eaecf8c92408ffe73b04887ebcce0421cc4386c7ad4c67656802108ccccd2856f
7
+ data.tar.gz: 1735d4f1dcfdc4955ba6a1b664b6141b806b0e0e37ee7da6ec404ef6f1fae2d68f0f318e4c81b611b9a43f2cfd43aa62dcfe58fe00400fefd7a6c104d54767c8
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  # [Eezee][gem_page]
2
2
 
3
+ *Eezee or ee-zee sounds like "Easy"*
4
+
3
5
  [![Gem Version][gem_version_image]][gem_version_page]
4
6
  [![Build Status][travis_status_image]][travis_page]
5
7
  [![Maintainability][code_climate_maintainability_image]][code_climate_maintainability_page]
6
8
  [![Test Coverage][code_climate_test_coverage_image]][code_climate_test_coverage_page]
7
9
 
8
- The easiest HTTP client for Ruby
10
+ The easiest HTTP client for Ruby!
9
11
 
10
12
  With Eezee you can do these things:
11
13
  * Define external services in an initializer file and use them through a simple method
@@ -17,7 +19,7 @@ With Eezee you can do these things:
17
19
  * Raise errors in failed requests
18
20
  * Spend more time coding your API integrations instead defining and testing HTTP settings and clients
19
21
 
20
- This gem is supported for Ruby 2.6+ applications
22
+ This gem is supported for Ruby 2.6+ applications.
21
23
 
22
24
  ## Table of Contents
23
25
  - [Getting started](#getting-started)
@@ -28,7 +30,7 @@ This gem is supported for Ruby 2.6+ applications
28
30
  - [Available Request options](#available-request-options)
29
31
  - [Services](#services)
30
32
  - [How a service works](#how-a-service-works)
31
- - [Request](#response)
33
+ - [Request](#request)
32
34
  - [Response](#response)
33
35
  - [Errors](#errors)
34
36
  - [Examples](#examples)
@@ -216,21 +218,64 @@ end
216
218
 
217
219
  #### How a service works
218
220
 
219
- When Ruby loads a class/module and it has the method `eezee_service` declared with a service's name, by default, Eezee will try load the service and create a request base for the class/module, so, when the class/module takes a request, Eezee will create the final request instance based on request base to take the HTTP request. You can turn it lazy setting the option `lazy: true`, therefore, the final request will be created just in the HTTP request. If the service doesn't exist when Eezee search about it, it will be raised the error `Eezee::Client::UnknownService`.
221
+ When Ruby loads a class/module and it has the method `eezee_service` declared with a service's name, by default, Eezee will try load the service and create a request base for the class/module, so, when the class/module takes a request, Eezee will create the final request instance based on request base to take the HTTP request. You can turn it lazy setting the option `lazy: true`, therefore, the final request will be created just in the HTTP request. If the service doesn't exist when Eezee search about it, it will be raised the error `Eezee::Client::UnknownServiceError`.
220
222
 
221
223
  About the method `add_service`, you can pass all of [Available Request options](#available-request-options). The meaning of this part is to organize in one way the external services integrations.
222
224
 
223
225
  ### Request
224
226
 
225
- Coming soon...
227
+ In [Hooks](#hooks), you always receive the param request and it is an instance of `Eezee::Request`. [Available Request options](#available-request-options) are the accessors of `Eezee::Request`, just call for the name, like:
228
+
229
+ ```ruby
230
+ request.protocol
231
+ # => :https
232
+
233
+ request.url
234
+ # => "rickandmortyapi.com/api"
235
+ ```
226
236
 
227
237
  ### Response
228
238
 
229
- Coming soon...
239
+ In [Hooks](#hooks) and the return of the request you have an instance of `Eezee::Response`. This class can be used for successful and failed requests. Here are all methods you can call from a response:
240
+
241
+ | Name | Type | What is it? |
242
+ |------|------|-------------|
243
+ | `original` | `Faraday::Response`, `Faraday::Error`, `Faraday::TimeoutError`, `Faraday::ConnectionFailed` or `Net::ReadTimeout` | The instance that made the `Eezee::Response`. |
244
+ | `body` | `Hash` | The body response. It always is an instance of Hash (symbolized). If the response doesn't have a body response, the value will be `{}`. |
245
+ | `success?` | Boolean (`TrueClass` or `FalseClass`) | If the request had a timeout error or response has the code 400+ the value will be `false`, else, the value will be `true`. |
246
+ | `code` | `Integer` or `NilClass` | If the request had a timeout error the value will be `nil`, else, the value will be an integer. |
247
+ | `timeout?` | Boolean (`TrueClass` or `FalseClass`) | If the request had a timeout error. |
230
248
 
231
249
  ### Errors
232
250
 
233
- Coming soon...
251
+ Eezee can raise errors in some situations:
252
+ - When the specified service is unknown
253
+ - When the request got a timeout
254
+ - When the request got a failure response
255
+
256
+ #### When the specified service is unknown
257
+ - `Eezee::Client::UnknownServiceError`
258
+
259
+ #### When the request got a timeout
260
+ - `Eezee::TimeoutError`
261
+
262
+ **Important**: This case happens just if the request option `raise_error` is `true`.
263
+
264
+ #### When the request got a failure response
265
+ - `Eezee::RequestError` for all errors (ancestor of all below)
266
+ - `Eezee::BadRequestError` for code equals 400
267
+ - `Eezee::UnauthorizedError` for code equals 401
268
+ - `Eezee::ForbiddenError` for code equals 403
269
+ - `Eezee::ResourceNotFoundError` for code equals 404
270
+ - `Eezee::UnprocessableEntityError` for code equals 422
271
+ - `Eezee::ClientError` for code between 400 and 499
272
+ - `Eezee::InternalServerError` for code equals 500
273
+ - `Eezee::ServiceUnavailableError` for code equals 503
274
+ - `Eezee::ServerError` for code between 500 and 599
275
+
276
+ All of `Eezee::RequestError` has the accessor `@response` with an instace of `Eezee::Response`.
277
+
278
+ **Important**: This case happens just if the request option `raise_error` is `true`.
234
279
 
235
280
  ### Examples
236
281
 
@@ -254,7 +299,15 @@ Coming soon...
254
299
 
255
300
  ## Why use Eezee instead Faraday
256
301
 
257
- Coming soon...
302
+ So, it's an important part of this README. This gem uses [Faraday](#https://github.com/lostisland/faraday) as the HTTP client and Faraday is an excellent HTTP client, but it brings many difficult, or, in other words, many things could be easier, like:
303
+
304
+ - If you work with microservices, you'll create a Faraday Connection setting per ms, or, it's so common to see many Faraday Connection setting in the same project.
305
+ - To raise errors with Faraday you know to set an adapter (it could be easier)
306
+ - When we have a successful response or an error, the way to catch the params (code, body) is completely different
307
+ - Faraday doesn't have any way to set the external services in an initializer, you'll have to create yours
308
+ - At least, it's common in projects the people create files to instantiate Faraday Connection but these people don't test these files
309
+
310
+ All of these things and others are contemplated by **Eezee**!
258
311
 
259
312
  ## Contributing
260
313
 
@@ -274,9 +327,9 @@ The gem is available as open source under the terms of the [MIT License][mit_lic
274
327
  [contributor_convenant_page]: http://contributor-covenant.org
275
328
  [travis_status_image]: https://travis-ci.org/linqueta/eezee.svg?branch=master
276
329
  [travis_page]: https://travis-ci.org/linqueta/eezee
277
- [code_climate_maintainability_image]: https://api.codeclimate.com/v1/badges/b3ae18295c290b6a92a9/maintainability
330
+ [code_climate_maintainability_image]: https://api.codeclimate.com/v1/badges/b5ec73de9875a4675b5a/maintainability
278
331
  [code_climate_maintainability_page]: https://codeclimate.com/github/linqueta/eezee/maintainability
279
- [code_climate_test_coverage_image]: https://api.codeclimate.com/v1/badges/b3ae18295c290b6a92a9/test_coverage
332
+ [code_climate_test_coverage_image]: https://api.codeclimate.com/v1/badges/b5ec73de9875a4675b5a/test_coverage
280
333
  [code_climate_test_coverage_page]: https://codeclimate.com/github/linqueta/eezee/test_coverage
281
334
  [gem_version_image]: https://badge.fury.io/rb/eezee.svg
282
335
  [gem_version_page]: https://rubygems.org/gems/eezee
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Eezee
4
4
  module Client
5
- class UnknownService < StandardError; end
5
+ class UnknownServiceError < StandardError; end
6
6
 
7
7
  module Builder
8
8
  def self.extended(base)
@@ -51,7 +51,7 @@ module Eezee
51
51
 
52
52
  def handle_unknown_service!(service, force)
53
53
  return unless take_request?(force)
54
- raise UnknownService if !service && eezee_options[:service_name]
54
+ raise UnknownServiceError if !service && eezee_options[:service_name]
55
55
 
56
56
  service
57
57
  end
data/lib/eezee/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eezee
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.8'
5
5
  end
@@ -7,7 +7,7 @@ module Eezee
7
7
  def create_initializer_file
8
8
  create_file(
9
9
  'config/initializers/eezee.rb',
10
- <<~KATINGUELE_INITIALIZER_TEXT
10
+ <<~EEZEE_INITIALIZER_TEXT
11
11
  # frozen_string_literal: true
12
12
 
13
13
  Eezee.configure do |config|
@@ -25,7 +25,7 @@ module Eezee
25
25
 
26
26
  # All available options is on README
27
27
  end
28
- KATINGUELE_INITIALIZER_TEXT
28
+ EEZEE_INITIALIZER_TEXT
29
29
  )
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eezee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - linqueta
@@ -256,7 +256,7 @@ files:
256
256
  - lib/eezee/request_error_factory.rb
257
257
  - lib/eezee/response.rb
258
258
  - lib/eezee/version.rb
259
- - lib/generators/katinguele/install_generator.rb
259
+ - lib/generators/eezee/install_generator.rb
260
260
  homepage: https://github.com/linqueta/eezee
261
261
  licenses:
262
262
  - MIT