ruby_var_dump 0.1.6 → 0.2.0
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/.rspec_status +6 -6
- data/lib/ruby_var_dump/version.rb +1 -1
- data/lib/ruby_var_dump.rb +18 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2500e049b226d5690eaf4d5352d6817b19f331713fa2866f0d7b9750e36a9a65
|
4
|
+
data.tar.gz: f6593f187ebf2dfffb5fae98c3b906f0fdebbf3014a9e32b960e9f4b7eb5ac05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71512e0e4cafdd53d9a20c764119d7b7e4fee1703ed2ea84fa4aff823848b6aedda1ea91e19326854bccc5336a37d06b5304f99d7c329621aaaf702635384631
|
7
|
+
data.tar.gz: 525b53da60b91a9182326e501f7d1f494070cea54f6b4e74868bff8a4809b097038a47ebc800f637f141a1c149cf754a68643c2a5fa072b7c9f26714b1597074
|
data/.rspec_status
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
--------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/ruby_var_dump_spec.rb[1:1:1] | passed | 0.
|
4
|
-
./spec/ruby_var_dump_spec.rb[1:1:2:1:1] | passed | 0.
|
5
|
-
./spec/ruby_var_dump_spec.rb[1:1:2:1:2] | passed | 0.
|
3
|
+
./spec/ruby_var_dump_spec.rb[1:1:1] | passed | 0.00037 seconds |
|
4
|
+
./spec/ruby_var_dump_spec.rb[1:1:2:1:1] | passed | 0.00031 seconds |
|
5
|
+
./spec/ruby_var_dump_spec.rb[1:1:2:1:2] | passed | 0.001 seconds |
|
6
6
|
./spec/ruby_var_dump_spec.rb[1:1:2:2:1] | passed | 0.00004 seconds |
|
7
7
|
./spec/ruby_var_dump_spec.rb[1:1:2:2:2] | passed | 0.00003 seconds |
|
8
|
-
./spec/ruby_var_dump_spec.rb[1:1:2:3:1] | passed | 0.
|
8
|
+
./spec/ruby_var_dump_spec.rb[1:1:2:3:1] | passed | 0.0001 seconds |
|
9
9
|
./spec/ruby_var_dump_spec.rb[1:1:2:3:2] | passed | 0.00004 seconds |
|
10
10
|
./spec/ruby_var_dump_spec.rb[1:1:3:1] | passed | 0.00003 seconds |
|
11
11
|
./spec/ruby_var_dump_spec.rb[1:1:3:2] | passed | 0.00004 seconds |
|
12
12
|
./spec/ruby_var_dump_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
|
13
|
-
./spec/ruby_var_dump_spec.rb[1:1:4:2] | passed | 0.
|
14
|
-
./spec/ruby_var_dump_spec.rb[1:1:5:1] | passed | 0.
|
13
|
+
./spec/ruby_var_dump_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
|
14
|
+
./spec/ruby_var_dump_spec.rb[1:1:5:1] | passed | 0.00004 seconds |
|
15
15
|
./spec/ruby_var_dump_spec.rb[1:1:6:1] | passed | 0.00009 seconds |
|
data/lib/ruby_var_dump.rb
CHANGED
@@ -77,14 +77,16 @@ module RubyVarDump
|
|
77
77
|
next if association.macro.nil? # アソシエーションが存在しない場合はスキップ
|
78
78
|
|
79
79
|
associated_value = obj.send(association.name)
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
# has_many や has_and_belongs_to_many など、コレクションを返すアソシエーション
|
82
|
+
if association.macro == :has_many || association.macro == :has_and_belongs_to_many
|
83
|
+
next if associated_value.nil? || (associated_value.respond_to?(:empty?) && associated_value.empty?)
|
82
84
|
|
83
85
|
associated_value.each do |item|
|
84
86
|
next if dumped_objects.any? { |dumped_obj| dumped_obj.object_id == item.object_id && dumped_obj.class == item.class }
|
85
87
|
|
86
88
|
# CollectionProxy の内容(アソシエーション)をダンプ
|
87
|
-
print("#{indent} #{RED_COLOR}#{association.name} #{ORANGE_COLOR}(association)#{RESET_COLOR}: #{GREEN_COLOR}<< #{item.class}:#{item.object_id} >>#{RESET_COLOR}\n")
|
89
|
+
print("#{indent} #{RED_COLOR}#{association.name} #{ORANGE_COLOR}(#{association.macro})#{RESET_COLOR}: #{GREEN_COLOR}<< #{item.class}:#{item.object_id} >>#{RESET_COLOR}\n")
|
88
90
|
print("#{indent} {\n")
|
89
91
|
item.attributes.each do |attr_name, attr_value|
|
90
92
|
print("#{indent} #{attr_name}: #{colorize_by_type(attr_value)}\n")
|
@@ -92,6 +94,19 @@ module RubyVarDump
|
|
92
94
|
|
93
95
|
print("#{indent} }\n") #ここまでアソシエーションの描画
|
94
96
|
end
|
97
|
+
# belongs_to や has_one など、単一オブジェクトを返すアソシエーション
|
98
|
+
elsif association.macro == :belongs_to || association.macro == :has_one
|
99
|
+
next if associated_value.nil?
|
100
|
+
next if dumped_objects.any? { |dumped_obj| dumped_obj.object_id == associated_value.object_id && dumped_obj.class == associated_value.class }
|
101
|
+
|
102
|
+
# 単一オブジェクトのアソシエーションをダンプ
|
103
|
+
print("#{indent} #{RED_COLOR}#{association.name} #{ORANGE_COLOR}(#{association.macro})#{RESET_COLOR}: #{GREEN_COLOR}<< #{associated_value.class}:#{associated_value.object_id} >>#{RESET_COLOR}\n")
|
104
|
+
print("#{indent} {\n")
|
105
|
+
associated_value.attributes.each do |attr_name, attr_value|
|
106
|
+
print("#{indent} #{attr_name}: #{colorize_by_type(attr_value)}\n")
|
107
|
+
end
|
108
|
+
|
109
|
+
print("#{indent} }\n") #ここまでアソシエーションの描画
|
95
110
|
end
|
96
111
|
end
|
97
112
|
print "#{indent}}\n"
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hirokiyam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-06 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.
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.5.
|
54
|
+
rubygems_version: 3.5.10
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: A Ruby gem for detailed debugging and inspection of objects.
|