debugvisualizer 0.1.4 → 0.1.6
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/debugvisualizer/array.rb +59 -30
- data/lib/debugvisualizer/hash.rb +62 -2
- data/lib/debugvisualizer/nokogiri.rb +59 -0
- data/lib/debugvisualizer/rexml.rb +21 -22
- data/lib/debugvisualizer/rubyvm_ast.rb +46 -0
- data/lib/debugvisualizer/version.rb +1 -1
- data/lib/debugvisualizer.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461fb0f531078730280dcec06b08e0e4ba60f0fc2aecb3ce123d737528ab2620
|
4
|
+
data.tar.gz: 50fb672349d99438b782df5df1ff815bac81f690c415a129b815ef12ce75441b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c436bc8dff430329455ae925c61f75d427656be8dd0d382ade6f064d251eee360e75c9f188afece3fea654d3d783fd40b21c7db6a495b4adfd63876202c803e0
|
7
|
+
data.tar.gz: 0a50a51f32fa9e76a1d7b0bd92836e1d1167727efc23164e360c2929339cd863880c834dca8c338d33325e128f18ff6a470ad085708f043bd59afe947c848da2
|
@@ -1,43 +1,72 @@
|
|
1
1
|
module DebugVisualizer
|
2
2
|
DebugVisualizer.register do |data|
|
3
|
-
if data.is_a?(Array)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if data.is_a?(Array) && data.all? {|v| v.is_a?(Integer) || v.is_a?(Float) }
|
4
|
+
{
|
5
|
+
id: "array_as_line_chart",
|
6
|
+
name: "Array As Line Chart",
|
7
|
+
priority: 100,
|
8
|
+
data: {
|
8
9
|
"kind":{ "plotly": true },
|
9
10
|
"data":[
|
10
11
|
{ "y": data },
|
11
12
|
]
|
12
13
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
DebugVisualizer.register do |data|
|
19
|
+
if data.is_a?(Array)
|
20
|
+
columns = []
|
21
|
+
data.each{|elem|
|
22
|
+
columns << {content: elem.to_s}
|
23
|
+
}
|
24
|
+
new_data = {
|
25
|
+
"kind": { "grid": true },
|
26
|
+
"rows": [
|
27
|
+
{
|
28
|
+
"columns": columns
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
{
|
33
|
+
id: "array_as_grid",
|
34
|
+
name: "Array As Grid",
|
35
|
+
priority: 80,
|
36
|
+
data: new_data
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
DebugVisualizer.register do |data|
|
42
|
+
if data.is_a?(Array) && data.all? {|v| v.is_a?(Hash) }
|
43
|
+
{
|
44
|
+
id: "array_as_table",
|
45
|
+
name: "Array As Table",
|
46
|
+
priority: 100,
|
47
|
+
data: {
|
48
|
+
kind: { table: true },
|
49
|
+
rows: data
|
18
50
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
DebugVisualizer.register do |data|
|
56
|
+
if data.is_a?(Array) && data.all? {|v| v.is_a?(Integer) || v.is_a?(Float) }
|
57
|
+
{
|
58
|
+
id: "array_as_bar_chart",
|
59
|
+
name: "Array As Bar Chart",
|
60
|
+
priority: 50,
|
61
|
+
data: {
|
62
|
+
kind: { plotly: true },
|
63
|
+
data: [
|
64
|
+
{
|
65
|
+
y: data,
|
66
|
+
type: :bar
|
67
|
+
}
|
32
68
|
]
|
33
69
|
}
|
34
|
-
name = "Array As Grid"
|
35
|
-
end
|
36
|
-
{
|
37
|
-
id: "array_visualizer",
|
38
|
-
name: name,
|
39
|
-
priority: 30,
|
40
|
-
data: new_data
|
41
70
|
}
|
42
71
|
end
|
43
72
|
end
|
data/lib/debugvisualizer/hash.rb
CHANGED
@@ -2,11 +2,71 @@ module DebugVisualizer
|
|
2
2
|
DebugVisualizer.register do |data|
|
3
3
|
if data.is_a?(Hash)
|
4
4
|
{
|
5
|
-
id: "
|
5
|
+
id: "hash_as_table",
|
6
6
|
name: "Hash As Table",
|
7
|
+
priority: 50,
|
7
8
|
data: {
|
8
9
|
kind: { table: true },
|
9
|
-
rows:
|
10
|
+
rows: data.map{|key, val| {key: key, value: val}}
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
DebugVisualizer.register do |data|
|
17
|
+
if data.is_a?(Hash) && data.values.all? {|v| v.is_a?(Integer) || v.is_a?(Float) }
|
18
|
+
{
|
19
|
+
id: "hash_as_line_chart",
|
20
|
+
name: "Hash As Line Chart",
|
21
|
+
priority: 80,
|
22
|
+
data: {
|
23
|
+
kind: { plotly: true },
|
24
|
+
data: [
|
25
|
+
{
|
26
|
+
x: data.keys,
|
27
|
+
y: data.values
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
DebugVisualizer.register do |data|
|
36
|
+
if data.is_a?(Hash) && data.values.all? {|v| v.is_a?(Integer) || v.is_a?(Float) }
|
37
|
+
{
|
38
|
+
id: "hash_as_pie_chart",
|
39
|
+
name: "Hash As Pie Chart",
|
40
|
+
priority: 20,
|
41
|
+
data: {
|
42
|
+
kind: { plotly: true },
|
43
|
+
data: [
|
44
|
+
{
|
45
|
+
labels: data.keys,
|
46
|
+
values: data.values,
|
47
|
+
type: :pie
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
DebugVisualizer.register do |data|
|
56
|
+
if data.is_a?(Hash) && data.values.all? {|v| v.is_a?(Integer) || v.is_a?(Float) }
|
57
|
+
{
|
58
|
+
id: "hash_as_bar_chart",
|
59
|
+
name: "Hash As Bar Chart",
|
60
|
+
priority: 100,
|
61
|
+
data: {
|
62
|
+
kind: { plotly: true },
|
63
|
+
data: [
|
64
|
+
{
|
65
|
+
x: data.keys,
|
66
|
+
y: data.values,
|
67
|
+
type: :bar
|
68
|
+
}
|
69
|
+
]
|
10
70
|
}
|
11
71
|
}
|
12
72
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module DebugVisualizer
|
2
|
+
DebugVisualizer.register do |data|
|
3
|
+
if (defined?(Nokogiri::HTML4::Document) && data.kind_of?(Nokogiri::HTML4::Document)) ||
|
4
|
+
(defined?(Nokogiri::XML::Document) && data.kind_of?(Nokogiri::XML::Document))
|
5
|
+
{
|
6
|
+
id: "nokogiri_visualizer",
|
7
|
+
name: "Nokogiri As Tree",
|
8
|
+
data: {
|
9
|
+
kind: { tree: true },
|
10
|
+
root: get_nokogiri_as_tree(data.children).last
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_nokogiri_as_tree(elems)
|
17
|
+
result = []
|
18
|
+
elems.each{|elem|
|
19
|
+
items = [
|
20
|
+
{
|
21
|
+
text: elem.name,
|
22
|
+
emphasis: 'style1'
|
23
|
+
}
|
24
|
+
]
|
25
|
+
elem.attributes.each{|key, val|
|
26
|
+
items << {
|
27
|
+
text: " #{key} =",
|
28
|
+
}
|
29
|
+
items << {
|
30
|
+
text: "\"#{val.value}\"",
|
31
|
+
emphasis: 'style2'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
child = []
|
35
|
+
if elem.children
|
36
|
+
child = get_nokogiri_as_tree(elem.children)
|
37
|
+
end
|
38
|
+
next if elem.name == 'text'
|
39
|
+
|
40
|
+
text = elem.xpath('text()').text
|
41
|
+
if text && text.strip != ""
|
42
|
+
child << {
|
43
|
+
items: [
|
44
|
+
text: text.strip,
|
45
|
+
emphasis: 'style3'
|
46
|
+
],
|
47
|
+
children: []
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
tree = {
|
52
|
+
items: items,
|
53
|
+
children: child
|
54
|
+
}
|
55
|
+
result << tree
|
56
|
+
}
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
@@ -6,48 +6,47 @@ module DebugVisualizer
|
|
6
6
|
name: "REXML As Tree",
|
7
7
|
data: {
|
8
8
|
kind: { tree: true },
|
9
|
-
root:
|
9
|
+
root: get_rexml_as_tree(data)[0]
|
10
10
|
}
|
11
11
|
}
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.
|
15
|
+
def self.get_rexml_as_tree(elems)
|
16
16
|
result = []
|
17
17
|
elems.each_element{|elem|
|
18
|
-
|
18
|
+
items = [
|
19
|
+
{
|
20
|
+
text: elem.name,
|
21
|
+
emphasis: 'style1'
|
22
|
+
}
|
23
|
+
]
|
19
24
|
elem.attributes.each_attribute{|atr|
|
20
|
-
items = []
|
21
25
|
items << {
|
22
|
-
text: "#{atr.name}
|
23
|
-
emphasis: 'style2'
|
26
|
+
text: " #{atr.name} =",
|
24
27
|
}
|
25
28
|
items << {
|
26
29
|
text: atr.value,
|
27
30
|
emphasis: 'style2'
|
28
31
|
}
|
29
|
-
child << {
|
30
|
-
items: items,
|
31
|
-
children: []
|
32
|
-
}
|
33
32
|
}
|
33
|
+
children = []
|
34
34
|
if elem.has_elements?
|
35
|
-
|
35
|
+
children = get_rexml_as_tree(elem)
|
36
36
|
end
|
37
|
-
tree = {
|
38
|
-
items: [
|
39
|
-
{
|
40
|
-
text: elem.name,
|
41
|
-
emphasis: 'style1'
|
42
|
-
}
|
43
|
-
],
|
44
|
-
children: child
|
45
|
-
}
|
46
37
|
if elem.text && elem.text.strip != ""
|
47
|
-
|
48
|
-
|
38
|
+
children << {
|
39
|
+
items: [
|
40
|
+
text: elem.text.strip,
|
41
|
+
emphasis: 'style3'
|
42
|
+
],
|
43
|
+
children: []
|
49
44
|
}
|
50
45
|
end
|
46
|
+
tree = {
|
47
|
+
items: items,
|
48
|
+
children: children
|
49
|
+
}
|
51
50
|
result << tree
|
52
51
|
}
|
53
52
|
result
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module DebugVisualizer
|
2
|
+
DebugVisualizer.register do |data|
|
3
|
+
if data.kind_of? ::RubyVM::AbstractSyntaxTree::Node
|
4
|
+
{
|
5
|
+
id: "rubyvm_ast_visualizer",
|
6
|
+
name: "RubyVM As Tree",
|
7
|
+
data: {
|
8
|
+
kind: { tree: true },
|
9
|
+
root: get_tree(data).last
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.inspect obj
|
16
|
+
obj.inspect
|
17
|
+
rescue Exception => e
|
18
|
+
"failed to inspect: #{e.message}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_tree data
|
22
|
+
result = []
|
23
|
+
data.children.each{|child|
|
24
|
+
next if child.nil?
|
25
|
+
|
26
|
+
node = {
|
27
|
+
items: [],
|
28
|
+
children: []
|
29
|
+
}
|
30
|
+
if child.kind_of? ::RubyVM::AbstractSyntaxTree::Node
|
31
|
+
node[:items] << {
|
32
|
+
text: child.type,
|
33
|
+
emphasis: 'style1'
|
34
|
+
}
|
35
|
+
node[:children].push *get_tree(child)
|
36
|
+
else
|
37
|
+
node[:items] << {
|
38
|
+
text: inspect(child),
|
39
|
+
emphasis: 'style2'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
result << node
|
43
|
+
}
|
44
|
+
result
|
45
|
+
end
|
46
|
+
end
|
data/lib/debugvisualizer.rb
CHANGED
@@ -116,3 +116,5 @@ require_relative 'debugvisualizer/hash'
|
|
116
116
|
require_relative 'debugvisualizer/to_string'
|
117
117
|
require_relative 'debugvisualizer/string_diff'
|
118
118
|
require_relative 'debugvisualizer/rexml'
|
119
|
+
require_relative 'debugvisualizer/nokogiri'
|
120
|
+
require_relative 'debugvisualizer/rubyvm_ast'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugvisualizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naoto Ono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: debugvisualizer generates JSON based on VS Code Debug Visualizer protocol
|
14
14
|
email:
|
@@ -26,7 +26,9 @@ files:
|
|
26
26
|
- lib/debugvisualizer/active_record.rb
|
27
27
|
- lib/debugvisualizer/array.rb
|
28
28
|
- lib/debugvisualizer/hash.rb
|
29
|
+
- lib/debugvisualizer/nokogiri.rb
|
29
30
|
- lib/debugvisualizer/rexml.rb
|
31
|
+
- lib/debugvisualizer/rubyvm_ast.rb
|
30
32
|
- lib/debugvisualizer/string_diff.rb
|
31
33
|
- lib/debugvisualizer/to_string.rb
|
32
34
|
- lib/debugvisualizer/version.rb
|