brainzlab 0.1.22 → 0.1.23

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: 007c390978f334950c503b50293ed7c9bb940d21528a1c8226976020ae17f7f6
4
- data.tar.gz: 6c9f9a9bb98170602f6de0e0a328ac62ec10e806facf06d59534ae09017b3497
3
+ metadata.gz: bba9f09002a8dcd486cb1b110567274f2d558c471eed12657996fbb0589cbba0
4
+ data.tar.gz: 60a5d0b80300d8ccf3aa6aa48bd615514fd222246be796f3ba7e2c9260578050
5
5
  SHA512:
6
- metadata.gz: 1470ab31ba66285d1787294a9c90266e516f4a0a3b7a30ee523a7c8f66c57dc5eb3b337c3de7644e21ab26cdf1fec619972b9cf283816f9bf4e743c3318d8601
7
- data.tar.gz: c09a981ac1521930ad7f109f1ccac6294ccfbbe4bea122c0a1c0f32c7538cb51c0576dc8f783cf88e7e83a1a6682454a364be63b2302fd220c7eb1f786935266
6
+ metadata.gz: 2d4d0694747b4b08413636cb030465ad5babdd79388d8751f6fe6482229eea1dee0ca891711eb82a56641f745018b09c04cdfdcd87843ac1271c40f0b54bd2e8
7
+ data.tar.gz: cfd9ba154ac07f66eca51f22a4666a5c5a97db6c28265b725b7fcb1bbbd90a9064203957b0a26a39164201b963d55da8dbe7f23f45a9357cd89eccbe1cbce202
@@ -644,6 +644,17 @@ module BrainzLab
644
644
  obj.is_a?(Hash) || (!obj.is_a?(Array) && obj.respond_to?(:to_h) && obj.respond_to?(:each))
645
645
  end
646
646
 
647
+ # Convert hash-like values for display without raising. ActionController::Parameters
648
+ # raises UnfilteredParameters on #to_h when not permitted — use #to_unsafe_h (this
649
+ # is a log formatter, not a security boundary; param filtering happens elsewhere).
650
+ def safe_to_h(obj)
651
+ return obj.to_unsafe_h if obj.respond_to?(:to_unsafe_h)
652
+
653
+ obj.to_h
654
+ rescue StandardError
655
+ obj
656
+ end
657
+
647
658
  def format_params_toml(params, prefix = '', depth = 0)
648
659
  lines = []
649
660
  line_prefix = colorize("#{BOX[:vertical]} ", :cyan)
@@ -654,11 +665,7 @@ module BrainzLab
654
665
 
655
666
  case value
656
667
  when Hash, ActionController::Parameters
657
- value_hash = begin
658
- value.to_h
659
- rescue StandardError
660
- value
661
- end
668
+ value_hash = safe_to_h(value)
662
669
  if value_hash.keys.length <= 3 && value_hash.values.all? { |v| !hash_like?(v) && !v.is_a?(Array) }
663
670
  # Compact inline hash for simple cases
664
671
  inline = value_hash.map { |k, v| "#{k} = #{format_value(v)}" }.join(', ')
@@ -669,16 +676,12 @@ module BrainzLab
669
676
  value_hash.each do |k, v|
670
677
  if hash_like?(v)
671
678
  # Recursively format nested hashes
672
- lines << format_hash_nested(v.to_h, "#{full_key}.#{k}", depth + 1)
679
+ lines << format_hash_nested(safe_to_h(v), "#{full_key}.#{k}", depth + 1)
673
680
  elsif v.is_a?(Array) && hash_like?(v.first)
674
681
  lines << "#{line_prefix}#{indent} #{colorize("[[#{full_key}.#{k}]]",
675
682
  :gray)} #{colorize("# #{v.length} items", :gray)}"
676
683
  if v.first
677
- first_hash = begin
678
- v.first.to_h
679
- rescue StandardError
680
- v.first
681
- end
684
+ first_hash = safe_to_h(v.first)
682
685
  first_hash.each do |nested_k, nested_v|
683
686
  lines << "#{line_prefix}#{indent} #{colorize(nested_k.to_s, :white)} = #{format_value(nested_v)}"
684
687
  end
@@ -699,19 +702,11 @@ module BrainzLab
699
702
  :gray)} #{colorize("# #{value.length} items", :gray)}"
700
703
  # Show first item fully expanded
701
704
  if value.first
702
- first_item = begin
703
- value.first.to_h
704
- rescue StandardError
705
- value.first
706
- end
705
+ first_item = safe_to_h(value.first)
707
706
  first_item.each do |k, v|
708
707
  if hash_like?(v)
709
708
  # Expand nested hash fully
710
- nested_hash = begin
711
- v.to_h
712
- rescue StandardError
713
- v
714
- end
709
+ nested_hash = safe_to_h(v)
715
710
  lines << "#{line_prefix}#{indent} #{colorize("[#{k}]", :gray)}"
716
711
  nested_hash.each do |nested_k, nested_v|
717
712
  lines << "#{line_prefix}#{indent} #{colorize(nested_k.to_s,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrainzLab
4
- VERSION = '0.1.22'
4
+ VERSION = '0.1.23'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrainzLab