virtuous 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21706d887ab7c6356cf12b521724170cd196d432d73bca548d678240f593a0c7
4
- data.tar.gz: 79702a4ff37002499687c5eb6d2bd52d5b5ca719ad7654a0d40ed4213af7e6a5
3
+ metadata.gz: dde636ea3b588b861eb1571600585b5a92f221c427b1de5d0dd5da6019f19906
4
+ data.tar.gz: c82140d46fe427a713015074ae28c81fa2ef7494cc9a527cd1dac9f129525b69
5
5
  SHA512:
6
- metadata.gz: cd02d1df0306c1d7c575e8dc4c782f9047599b3eb0c3820b09fc240ccaa49a708c9310115b993e8f00041069442565770beb57b744ef8c2be8f11c7bae36523d
7
- data.tar.gz: 25c7401a3029d7d5796a416b07081a921b33d34cadb31c9a091e6f4276d6939f49a90b61f0743d8fd76795960e777c55ae019cc1adc218a3462db0853b65838a
6
+ metadata.gz: 408bdd4c97d63495fca22af299e1878ef70ca601428bde15ecc684c59f8d01cb0d3340389de1b4adb77958d6fc9972f2864338d31b729ef1e8db2a3951b3c180
7
+ data.tar.gz: a917e9353ad30d8ac5f4626dedf67890fa5cbc3123d9559aa0a61475034e7e98faf2e0e45644428326326529392c215c1fb0a91beb3955cdac3ef0ff46c33179
data/.reek.yml CHANGED
@@ -8,7 +8,7 @@ detectors:
8
8
  - "Virtuous::Client#connection"
9
9
  - "Virtuous::Client#unauthorized_connection"
10
10
  - "Virtuous::HashHelper#self.deep_transform_keys"
11
- - "FaradayMiddleware::ParseOj#on_complete"
11
+ - "Virtuous::FaradayMiddleware::ParseOj#on_complete"
12
12
  NilCheck:
13
13
  exclude:
14
14
  - "Virtuous::Client#initialize"
@@ -22,7 +22,7 @@ detectors:
22
22
  - "Virtuous::HashHelper#self.deep_transform_keys"
23
23
  - "Virtuous::Client#connection"
24
24
  - "Virtuous::Client#unauthorized_connection"
25
- - "FaradayMiddleware::VirtuousErrorHandler#on_complete"
25
+ - "Virtuous::FaradayMiddleware::VirtuousErrorHandler#on_complete"
26
26
  ControlParameter:
27
27
  exclude:
28
28
  - "Virtuous::Client#initialize"
@@ -264,7 +264,7 @@ module Virtuous
264
264
  conn.request :json
265
265
  conn.response :oj
266
266
  conn.response :logger, @logger if @logger
267
- conn.use FaradayMiddleware::VirtuousErrorHandler
267
+ conn.use Virtuous::FaradayMiddleware::VirtuousErrorHandler
268
268
  conn.adapter @adapter
269
269
  yield(conn) if block_given?
270
270
  end
@@ -1,3 +1,5 @@
1
+ require 'faraday'
2
+
1
3
  module Virtuous # :nodoc: all
2
4
  class Error < StandardError; end
3
5
  class BadGateway < Error; end
@@ -9,46 +11,45 @@ module Virtuous # :nodoc: all
9
11
  class NotFound < Error; end
10
12
  class ServiceUnavailable < Error; end
11
13
  class Unauthorized < Error; end
12
- end
13
14
 
14
- require 'faraday'
15
- module FaradayMiddleware
16
- class VirtuousErrorHandler < Faraday::Middleware
17
- ERROR_STATUSES = (400..600).freeze
15
+ module FaradayMiddleware
16
+ class VirtuousErrorHandler < Faraday::Middleware
17
+ ERROR_STATUSES = (400..600).freeze
18
18
 
19
- ##
20
- # Throws an exception for responses with an HTTP error code.
21
- def on_complete(env)
22
- message = error_message(env)
19
+ ##
20
+ # Throws an exception for responses with an HTTP error code.
21
+ def on_complete(env)
22
+ message = error_message(env)
23
23
 
24
- case env[:status]
25
- when 400
26
- raise Virtuous::BadRequest, message
27
- when 401
28
- raise Virtuous::Unauthorized, message
29
- when 403
30
- raise Virtuous::Forbidden, message
31
- when 404
32
- raise Virtuous::NotFound, message
33
- when 500
34
- raise Virtuous::InternalServerError, message
35
- when 502
36
- raise Virtuous::BadGateway, message
37
- when 503
38
- raise Virtuous::ServiceUnavailable, message
39
- when 504
40
- raise Virtuous::GatewayTimeout, message
41
- when 520
42
- raise Virtuous::CloudflareError, message
43
- when ERROR_STATUSES
44
- raise Virtuous::Error, message
24
+ case env[:status]
25
+ when 400
26
+ raise Virtuous::BadRequest, message
27
+ when 401
28
+ raise Virtuous::Unauthorized, message
29
+ when 403
30
+ raise Virtuous::Forbidden, message
31
+ when 404
32
+ raise Virtuous::NotFound, message
33
+ when 500
34
+ raise Virtuous::InternalServerError, message
35
+ when 502
36
+ raise Virtuous::BadGateway, message
37
+ when 503
38
+ raise Virtuous::ServiceUnavailable, message
39
+ when 504
40
+ raise Virtuous::GatewayTimeout, message
41
+ when 520
42
+ raise Virtuous::CloudflareError, message
43
+ when ERROR_STATUSES
44
+ raise Virtuous::Error, message
45
+ end
45
46
  end
46
- end
47
47
 
48
- private
48
+ private
49
49
 
50
- def error_message(env)
51
- "#{env[:status]}: #{env[:url]} #{env[:body]}"
50
+ def error_message(env)
51
+ "#{env[:status]}: #{env[:url]} #{env[:body]}"
52
+ end
52
53
  end
53
54
  end
54
55
  end
@@ -1,24 +1,26 @@
1
1
  require 'oj'
2
2
 
3
- module FaradayMiddleware
4
- class ParseOj < Faraday::Middleware
5
- ##
6
- # Parses JSON responses.
7
- def on_complete(env)
8
- body = env[:body]
9
- env[:body] = if empty_body?(body.strip)
10
- nil
11
- else
12
- Oj.load(body, mode: :compat)
13
- end
14
- end
3
+ module Virtuous
4
+ module FaradayMiddleware
5
+ class ParseOj < Faraday::Middleware
6
+ ##
7
+ # Parses JSON responses.
8
+ def on_complete(env)
9
+ body = env[:body]
10
+ env[:body] = if empty_body?(body.strip)
11
+ nil
12
+ else
13
+ Oj.load(body, mode: :compat)
14
+ end
15
+ end
15
16
 
16
- private
17
+ private
17
18
 
18
- def empty_body?(body)
19
- body.empty? && body == ''
19
+ def empty_body?(body)
20
+ body.empty? && body == ''
21
+ end
20
22
  end
21
23
  end
22
24
  end
23
25
 
24
- Faraday::Response.register_middleware(oj: FaradayMiddleware::ParseOj)
26
+ Faraday::Response.register_middleware(oj: Virtuous::FaradayMiddleware::ParseOj)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Virtuous
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtuous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Brooks
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: A Ruby wrapper for the Virtuous CRM API
42
- email:
42
+ email:
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
@@ -104,7 +104,7 @@ licenses:
104
104
  - MIT
105
105
  metadata:
106
106
  rubygems_mfa_required: 'true'
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubygems_version: 3.4.10
123
- signing_key:
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: A Ruby wrapper for the Virtuous CRM API
126
126
  test_files: []