code-ruby 5.2.1 → 5.2.2

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: 978d1a5cd5c7828f25ac0d619f50d68dcee1596a9fd3d92ac4e1ba684bfe2481
4
- data.tar.gz: 06c6cb5d2bf9e3b596d1524ea710dd3ec7f6c8abcd871f07c62f1eb291967c94
3
+ metadata.gz: 52e251b96064139d4e72a393de2b727b5d792ff0026d3d5f4830e582b54a7573
4
+ data.tar.gz: 456d6ddc2f99e1d662273af433beaf0461e960be102d829c26a9637af0c29bae
5
5
  SHA512:
6
- metadata.gz: 9c314514dc4d2ca20ebd674fe158b90b1f2200008e9e56389fab38513d8b81a1f21f7bd2dbd85f3bf16fe0d376c6879737524bb7597070a413b767d0b43df5a4
7
- data.tar.gz: 6ad13fe0f05f93e56fece2befeaf33fb08a10c5f3d2a8186021d57a2e7d6bd7c246615690e78bf950ab25f5453ce9af3b4d43399f6b7e3ea543d7fef83daecf1
6
+ metadata.gz: bd013119d2df47feb3c438cee2dccb21e13a01ca319085f7a4dc012966efc02a21578b07ccd104e851f5a0d3c633ac45e07ffea4e7dc4ba34e4fd012fb9bbca8
7
+ data.tar.gz: 057ad7fc9b03bbe40e4c921833e0da2926c0dfb9688b5c63a389cb4e66a687354bebc9591fb95eb8f56f41785fac888d976964c950c88c5532646c164e35c9ed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.1
1
+ 5.2.2
data/lib/code/format.rb CHANGED
@@ -459,11 +459,12 @@ class Code
459
459
  extract_string_concatenation_parts(left_operation: operation)
460
460
  return format_string(merged_string, indent: indent) if merged_string
461
461
 
462
- expression = format_nested_statement(operation[:first], indent: indent)
462
+ first_operator = format_operator(Array(operation[:others]).first&.fetch(:operator, ""))
463
+ expression = format_boolean_operand(operation[:first], first_operator, indent: indent)
463
464
 
464
465
  Array(operation[:others]).each do |other|
465
- right = format_nested_statement(other[:statement], indent: indent)
466
466
  operator = format_operator(other[:operator])
467
+ right = format_boolean_operand(other[:statement], operator, indent: indent)
467
468
 
468
469
  expression =
469
470
  if compact_operator?(operator)
@@ -510,6 +511,21 @@ class Code
510
511
  expression
511
512
  end
512
513
 
514
+ def format_boolean_operand(statement, operator, indent:)
515
+ if BOOLEAN_WORD_OPERATORS.include?(operator) && statement.is_a?(Hash) &&
516
+ statement[:left_operation]
517
+ nested = Array(statement[:left_operation][:others])
518
+ if nested.any? do |other|
519
+ nested_operator = format_operator(other[:operator])
520
+ BOOLEAN_WORD_OPERATORS.include?(nested_operator) && nested_operator != operator
521
+ end
522
+ return format_group([statement], indent: indent)
523
+ end
524
+ end
525
+
526
+ format_nested_statement(statement, indent: indent)
527
+ end
528
+
513
529
  def format_compact_receiver(expression, indent:)
514
530
  return expression unless compact_receiver_needs_parentheses?(expression)
515
531
 
@@ -197,7 +197,8 @@ class Code
197
197
  not_extended: 510,
198
198
  network_authentication_required: 511
199
199
  }.freeze
200
- DEFAULT_TIMEOUT = 1.hour.to_f
200
+ DEFAULT_TIMEOUT = 30
201
+ DEFAULT_OPEN_TIMEOUT = 10
201
202
  MAX_HEADER_BYTES = 32.kilobytes
202
203
  HEADER_NAME = /\A[A-Za-z0-9!#$%&'*+\-.^_`|~]+\z/
203
204
  RESTRICTED_HEADERS = %w[
@@ -348,7 +349,7 @@ class Code
348
349
  redirects =
349
350
  (
350
351
  if options.code_get("redirects").nothing?
351
- 10
352
+ 0
352
353
  else
353
354
  options.code_get("redirects").raw
354
355
  end
@@ -410,7 +411,11 @@ class Code
410
411
  http.use_ssl = true if uri.scheme == "https"
411
412
  http.max_retries = max_retries
412
413
  default_timeout = http_timeout(timeout, DEFAULT_TIMEOUT)
413
- open_timeout_value = http_timeout(open_timeout, default_timeout)
414
+ open_timeout_value =
415
+ http_timeout(
416
+ open_timeout,
417
+ timeout.nothing? ? DEFAULT_OPEN_TIMEOUT : default_timeout
418
+ )
414
419
  read_timeout_value = http_timeout(read_timeout, default_timeout)
415
420
  write_timeout_value = http_timeout(write_timeout, default_timeout)
416
421
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié