ruby_var_dump 0.1.4 → 0.1.5
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/ruby_var_dump/version.rb +1 -1
- data/lib/ruby_var_dump.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32a37618c09c721d7677fa7324b178ab96bcee787792be3f183ace3ceb2902da
|
4
|
+
data.tar.gz: 68d8fb523c3d91e95e2e3b3d7983a3e2262940396b17942acc72c65816b1cf61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83e17077afb7639b4dbc1b11ecda8dcb6c7a94ee411084045b73efec8c73f70c4a4315f1bbcfc7e7ef2835d08a727fb0631ef362cb855ebf6358d56f53db0f62
|
7
|
+
data.tar.gz: efd57f9f7ebceb180080b2288ba7e16ea08412ccc58620da63a4b22ee4064a5008e7656fdc9873effb41a8a12bcf5e5dd70473fba1612ca5167e14df573fcdca
|
data/lib/ruby_var_dump.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative "ruby_var_dump/version"
|
|
5
5
|
module RubyVarDump
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
|
-
def
|
8
|
+
def vdump(obj, level = 0, is_value = false, dumped_objects = [], is_first=true)
|
9
9
|
indent = ' ' * level * 2
|
10
10
|
|
11
11
|
if (defined?(ActiveRecord::Base) && obj.is_a?(ActiveRecord::Base)) || (defined?(ActiveRecord::Relation) && obj.is_a?(ActiveRecord::Relation))
|
@@ -25,7 +25,7 @@ module RubyVarDump
|
|
25
25
|
else
|
26
26
|
print "\n"
|
27
27
|
obj.each_with_index do |item, index|
|
28
|
-
|
28
|
+
vdump(item, level + 1, false, dumped_objects, false)
|
29
29
|
print "," unless index == obj.size - 1
|
30
30
|
print "\n"
|
31
31
|
end
|
@@ -43,7 +43,7 @@ module RubyVarDump
|
|
43
43
|
# キーにインデントを適用し、値にはインデントを適用しない
|
44
44
|
print "#{indent} #{key.inspect.chomp} => "
|
45
45
|
if value.is_a?(Hash) || value.is_a?(Array)
|
46
|
-
|
46
|
+
vdump(value, level + 1, true, dumped_objects, false) # ハッシュのバリューの場合には is_value を true に設定
|
47
47
|
else
|
48
48
|
print value.inspect # プリミティブな値の場合は現在のレベルで出力
|
49
49
|
end
|
@@ -88,12 +88,12 @@ module RubyVarDump
|
|
88
88
|
print "#{indent}#{obj.class}:#{obj.object_id}\n"
|
89
89
|
print "#{indent}[\n"
|
90
90
|
obj.each_with_index do |item, index|
|
91
|
-
|
91
|
+
vdump(item, level + 1, false, dumped_objects, index == 0)
|
92
92
|
end
|
93
93
|
print "#{indent}]"
|
94
94
|
print "\n" if level == 0 # メソッドの出力の最後に改行を追加
|
95
95
|
elsif obj.respond_to?(:attributes)
|
96
|
-
|
96
|
+
vdump(obj.attributes, level, false, dumped_objects, false)
|
97
97
|
else
|
98
98
|
print indent + obj.inspect.chomp
|
99
99
|
print "\n" if level == 0 # メソッドの出力の最後に改行を追加
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_var_dump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirokiyam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby gem for detailed debugging and inspection of objects, mimicking
|
14
14
|
PHP's var_dump function.
|