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 +4 -4
- data/lib/brainzlab/rails/log_formatter.rb +16 -21
- data/lib/brainzlab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bba9f09002a8dcd486cb1b110567274f2d558c471eed12657996fbb0589cbba0
|
|
4
|
+
data.tar.gz: 60a5d0b80300d8ccf3aa6aa48bd615514fd222246be796f3ba7e2c9260578050
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
data/lib/brainzlab/version.rb
CHANGED