client-api-builder 0.6.0 → 0.6.1

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: ae35befd024cba590ae2f644877243c536612ef9ce0e66c6c7c69f2481a7fc20
4
- data.tar.gz: cd843e5f96ed9a63f9fb4012ab94b7ebe7b8bd443fa2cec35fe04e1bf50e0806
3
+ metadata.gz: a417fa853b68dc6e9e96eff4cf99d6a0e026d459e38ae57cbec7341e4735e291
4
+ data.tar.gz: b2cb35125eb9cdea344051788aee903daea7762c1f0bbbfc13526e1a8815692b
5
5
  SHA512:
6
- metadata.gz: a97833f34c6dde60bc8edbe9d38180e6f2904884ceb5b85a38e43358856e6e9c95f57e06f4356c0a10fe50d33801513e89132b452482bd689abf610a9ac53894
7
- data.tar.gz: 9686a7f14ed8144f3e310cddf9abdf0681bfd237149397adba9d1376ca5d47a106530e099e165d22264bd7178b663e026a9e0658a2e95ef6a9b1fb1c3beb874e
6
+ metadata.gz: 7fbc5052d79571ea1b901067bbaa3feb9a5e0e3c29ccebe1279905b917c121ecda94284f583c52badc5f00ef2c8c55fcba062563e1e8446730ea496659ac5ba3
7
+ data.tar.gz: f2521e526d45195ff795ad3663c7f6bf8140bb8316a8c3b04f170fe215c0b185745536b152ea0879a896d60ea82cc33a7e7e2e0a9086892c1ee1c5c6a82125eb
data/.rubocop.yml CHANGED
@@ -18,7 +18,7 @@ Metrics/ClassLength:
18
18
  Max: 200
19
19
 
20
20
  Metrics/ModuleLength:
21
- Max: 320
21
+ Max: 340
22
22
 
23
23
  Metrics/CyclomaticComplexity:
24
24
  Max: 30
data/README.md CHANGED
@@ -433,6 +433,28 @@ subscriber = ClientApiBuilder::ActiveSupportLogSubscriber.new(Rails.logger)
433
433
  subscriber.subscribe!
434
434
  ```
435
435
 
436
+ #### Production Logging
437
+
438
+ For production environments, it's important to log requests without exposing sensitive credentials that may be present in query parameters. The following example strips query parameters from logged URLs:
439
+
440
+ ```ruby
441
+ ActiveSupport::Notifications.subscribe('client_api_builder.request') do |_, start_time, end_time, _, payload|
442
+ client = payload[:client]
443
+ method = client.request_options[:method].to_s.upcase
444
+ uri = client.request_options[:uri]
445
+ response_code = client.response ? client.response.code : 'UNKNOWN'
446
+
447
+ duration = ((end_time - start_time) * 1000).to_i
448
+ Rails.logger.info "#{method} #{uri.scheme}://#{uri.host}#{uri.path}[#{response_code}] took #{duration}ms"
449
+ end
450
+ ```
451
+
452
+ This produces clean log entries like:
453
+ ```
454
+ GET https://api.example.com/users/123[200] took 45ms
455
+ POST https://api.example.com/auth/token[201] took 120ms
456
+ ```
457
+
436
458
  ## Security Features
437
459
 
438
460
  Client API Builder includes several security features enabled by default:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'client-api-builder'
5
- s.version = '0.6.0'
5
+ s.version = '0.6.1'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'Build robust, secure API clients through declarative configuration'
8
8
  s.description = <<~DESC
@@ -282,10 +282,37 @@ module ClientApiBuilder
282
282
  [path, path_arguments]
283
283
  end
284
284
 
285
+ # Converts a value to Ruby code string with consistent hash syntax across Ruby versions.
286
+ # Uses modern {key: value} syntax for symbol keys.
287
+ def value_to_code(value)
288
+ case value
289
+ when Hash
290
+ return '{}' if value.empty?
291
+
292
+ pairs = value.map do |k, v|
293
+ key_code = case k
294
+ when Symbol then "#{k}: "
295
+ when String then "#{k.inspect} => "
296
+ else "#{value_to_code(k)} => "
297
+ end
298
+ "#{key_code}#{value_to_code(v)}"
299
+ end
300
+ "{#{pairs.join(', ')}}"
301
+ when Array
302
+ "[#{value.map { |v| value_to_code(v) }.join(', ')}]"
303
+ when NilClass
304
+ 'nil'
305
+ when TrueClass, FalseClass
306
+ value.to_s
307
+ else
308
+ value.inspect
309
+ end
310
+ end
311
+
285
312
  def build_query_code(options)
286
313
  if options[:query]
287
314
  query_arguments = get_arguments(options[:query])
288
- str = options[:query].inspect
315
+ str = value_to_code(options[:query])
289
316
  str = str.gsub(/"__\|\|(.+?)\|\|__"/) { Regexp.last_match(1) }
290
317
  [str, query_arguments.map(&:to_s)]
291
318
  else
@@ -296,7 +323,7 @@ module ClientApiBuilder
296
323
  def build_body_code(options, has_body_param)
297
324
  if options[:body]
298
325
  body_arguments = get_arguments(options[:body])
299
- str = options[:body].inspect
326
+ str = value_to_code(options[:body])
300
327
  str = str.gsub(/"__\|\|(.+?)\|\|__"/) { Regexp.last_match(1) }
301
328
  [str, body_arguments.map(&:to_s), false]
302
329
  else
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client-api-builder
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
  - Doug Youch
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-01-31 00:00:00.000000000 Z
10
+ date: 2026-02-01 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: inheritance-helper