debugvisualizer 0.1.3 → 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/debugvisualizer/array.rb +59 -30
- data/lib/debugvisualizer/hash.rb +62 -2
- data/lib/debugvisualizer/nokogiri.rb +59 -0
- data/lib/debugvisualizer/rexml.rb +55 -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: 17a5df625ac442f50c8f8455ce630d98afcaec3eab93e004d72374f08ba2d1c3
|
4
|
+
data.tar.gz: 9e08125199a22ccef1d45d5ae04545faff070e7e6085aaf78ec4bdd1745dd7d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cf9bf5a9cb3fb0b28ea54fea1af00dd773fefeeb8c80423b41d3bfd1deb15cb746fd3ff9c45232dac74f66377a863ba3689105a6307b798171f9bd191dd1258
|
7
|
+
data.tar.gz: 4d70f1ac9a6c2a1d3a60579909e2e603af2463615c18a91a79f822898af17db4a55eb2bb27139b10f675de5cfb0c7823c4a33d17a095f271ee5da9061246b5db
|
@@ -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_tree(data.children).last
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.get_tree(elems)
|
17
|
+
result = []
|
18
|
+
elems.each{|elem|
|
19
|
+
child = []
|
20
|
+
elem.attributes.each{|key, val|
|
21
|
+
items = []
|
22
|
+
items << {
|
23
|
+
text: "#{key}: ",
|
24
|
+
emphasis: 'style2'
|
25
|
+
}
|
26
|
+
items << {
|
27
|
+
text: val.value,
|
28
|
+
emphasis: 'style2'
|
29
|
+
}
|
30
|
+
child << {
|
31
|
+
items: items,
|
32
|
+
children: []
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if elem.children
|
36
|
+
child.push *get_tree(elem.children)
|
37
|
+
end
|
38
|
+
next if elem.name == 'text'
|
39
|
+
|
40
|
+
tree = {
|
41
|
+
items: [
|
42
|
+
{
|
43
|
+
text: elem.name,
|
44
|
+
emphasis: 'style1'
|
45
|
+
}
|
46
|
+
],
|
47
|
+
children: child
|
48
|
+
}
|
49
|
+
text = elem.xpath('text()').text
|
50
|
+
if text && text.strip != ""
|
51
|
+
tree[:items] << {
|
52
|
+
text: ' ' * 2 + text.strip
|
53
|
+
}
|
54
|
+
end
|
55
|
+
result << tree
|
56
|
+
}
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module DebugVisualizer
|
2
|
+
DebugVisualizer.register do |data|
|
3
|
+
if defined?(REXML::Document) && data.kind_of?(REXML::Document)
|
4
|
+
{
|
5
|
+
id: "rexml_visualizer",
|
6
|
+
name: "REXML As Tree",
|
7
|
+
data: {
|
8
|
+
kind: { tree: true },
|
9
|
+
root: get_tree(data)[0]
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.get_tree(elems)
|
16
|
+
result = []
|
17
|
+
elems.each_element{|elem|
|
18
|
+
children = []
|
19
|
+
elem.attributes.each_attribute{|atr|
|
20
|
+
items = []
|
21
|
+
items << {
|
22
|
+
text: "#{atr.name}: ",
|
23
|
+
emphasis: 'style2'
|
24
|
+
}
|
25
|
+
items << {
|
26
|
+
text: atr.value,
|
27
|
+
emphasis: 'style2'
|
28
|
+
}
|
29
|
+
children << {
|
30
|
+
items: items,
|
31
|
+
children: []
|
32
|
+
}
|
33
|
+
}
|
34
|
+
if elem.has_elements?
|
35
|
+
children.push *get_tree(elem)
|
36
|
+
end
|
37
|
+
tree = {
|
38
|
+
items: [
|
39
|
+
{
|
40
|
+
text: elem.name,
|
41
|
+
emphasis: 'style1'
|
42
|
+
}
|
43
|
+
],
|
44
|
+
children: children
|
45
|
+
}
|
46
|
+
if elem.text && elem.text.strip != ""
|
47
|
+
tree[:items] << {
|
48
|
+
text: ' ' * 2 + elem.text.strip
|
49
|
+
}
|
50
|
+
end
|
51
|
+
result << tree
|
52
|
+
}
|
53
|
+
result
|
54
|
+
end
|
55
|
+
end
|
data/lib/debugvisualizer.rb
CHANGED
@@ -115,3 +115,5 @@ require_relative 'debugvisualizer/array'
|
|
115
115
|
require_relative 'debugvisualizer/hash'
|
116
116
|
require_relative 'debugvisualizer/to_string'
|
117
117
|
require_relative 'debugvisualizer/string_diff'
|
118
|
+
require_relative 'debugvisualizer/rexml'
|
119
|
+
require_relative 'debugvisualizer/nokogiri'
|
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.5
|
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-12 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,6 +26,8 @@ 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
|
30
|
+
- lib/debugvisualizer/rexml.rb
|
29
31
|
- lib/debugvisualizer/string_diff.rb
|
30
32
|
- lib/debugvisualizer/to_string.rb
|
31
33
|
- lib/debugvisualizer/version.rb
|