squake 0.6.0 → 0.6.1

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: 9998b15ce76aa8dbc8be90d10591fcc590a6371f49ff5f18782ce77081ff1420
4
- data.tar.gz: 68b42dec21a0f57f64b1fd12b1a206496cd7b0e2c2aefccb75d3890914865f2a
3
+ metadata.gz: 8d74376a8394904dde68ee22c591d59a26de63cc3f7273077cec9d1c755a8e01
4
+ data.tar.gz: ebf2977af63c7874817ee0251a3f3ce117f2da242597c31c07a43326eec984a8
5
5
  SHA512:
6
- metadata.gz: 20b305cc676a3fce372ca814206a4299b173ae9560115f582dd957abd2387b3d8defd44f254ec5a835a94e1eb6e366fe7c23ecb9bf5c71edc360ee92268ebb05
7
- data.tar.gz: ef97791c2cfb0bddde5cc0e15eca9e5d2055d24daceffee4e77473d3595bb4fa5f1ee5eeb6430580b7da2efdc0a610763f5d75bcee65010d727a04774706ade0
6
+ metadata.gz: 5a93a636570247e9a16cf6d81b2ee94c37271d00d75516e104a7813b508173cf80f6b301422e9b5c037751a857b9a490afa2d077522aa09d50d88b96780d4be8
7
+ data.tar.gz: a0742ff2711d8c0e461ae6594135a532908afe498a2cca43036d7e34c981f33d928157dfe36ceb6e0af92ec1d8f3c17dc3f0e4d41e4b423a4a264b0f855e8bd7
data/lib/squake/client.rb CHANGED
@@ -68,7 +68,7 @@ module Squake
68
68
 
69
69
  headers = request_headers(api_key).merge!(headers)
70
70
  query = query_params ? Util.encode_parameters(query_params) : nil
71
- body = body_params ? ::Oj.dump(body_params) : nil
71
+ body = body_params ? ::Oj.dump(body_params, Squake::OJ_CONFIG) : nil
72
72
  sanitized_path = path[0] == '/' ? path : "/#{path}"
73
73
  uri = URI.parse(api_base + sanitized_path)
74
74
 
@@ -93,6 +93,7 @@ module Squake
93
93
  'http.route': request.path,
94
94
  'http.headers': request.to_hash,
95
95
  },
96
+ Squake::OJ_CONFIG,
96
97
  )
97
98
  canonical_request_line.gsub!(api_key, 'API_KEY_REDACTED')
98
99
  @config.logger.info(canonical_request_line)
@@ -118,7 +119,7 @@ module Squake
118
119
 
119
120
  sig { params(result_body: T.untyped).returns(JsonResponseBody) }
120
121
  private def try_parse_json(result_body)
121
- ::Oj.load(result_body, symbol_keys: true)
122
+ ::Oj.load(result_body, Squake::OJ_CONFIG)
122
123
  rescue ::Oj::ParseError, TypeError, JSON::ParserError, EncodingError => e
123
124
  # in case of an error, Squake's response body is HTML not JSON
124
125
  { error: { 'message' => e.message, 'body' => result_body } }
@@ -36,7 +36,7 @@ module Squake
36
36
  <<~TXT
37
37
  Failed Request
38
38
  http_code=#{code}
39
- body=#{::Oj.dump(body)}
39
+ body=#{::Oj.dump(body, Squake::OJ_CONFIG)}
40
40
  original_request_http_method=#{original_request.method}
41
41
  original_request_http_path=#{original_request.path}
42
42
  TXT
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Squake
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.1'
6
6
  end
data/lib/squake.rb CHANGED
@@ -5,14 +5,21 @@ require 'sorbet-runtime'
5
5
  require 'oj'
6
6
  require 'net/http'
7
7
 
8
- Oj.default_options = {
9
- mode: :compat, # required to dump hashes with symbol-keys
10
- symbol_keys: true,
11
- }
12
-
13
8
  Dir[File.join(__dir__, './**/*', '*.rb')].each { require(_1) }
14
9
 
15
10
  module Squake
11
+ # Don't freeze this constant, since we don't know what Oj is doing with the object under the hood
12
+ # Don't set this as global Oj settings to avoid bleeding into other apps that build on this gem
13
+ # rubocop:disable Style/MutableConstant
14
+ OJ_CONFIG = T.let(
15
+ {
16
+ mode: :compat, # required to dump hashes with symbol-keys
17
+ symbol_keys: true,
18
+ },
19
+ T::Hash[Symbol, T.untyped],
20
+ )
21
+ # rubocop:enable Style/MutableConstant
22
+
16
23
  class << self
17
24
  extend T::Sig
18
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SQUAKE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-19 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-http
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  - !ruby/object:Gem::Version
219
219
  version: '0'
220
220
  requirements: []
221
- rubygems_version: 3.4.19
221
+ rubygems_version: 3.5.3
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: The industry solution for sustainable travel and logistics.