debugvisualizer 0.1.5 → 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/nokogiri.rb +23 -23
- 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 +1 -0
- metadata +3 -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
|
@@ -7,51 +7,51 @@ module DebugVisualizer
|
|
7
7
|
name: "Nokogiri As Tree",
|
8
8
|
data: {
|
9
9
|
kind: { tree: true },
|
10
|
-
root:
|
10
|
+
root: get_nokogiri_as_tree(data.children).last
|
11
11
|
}
|
12
12
|
}
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.
|
16
|
+
def self.get_nokogiri_as_tree(elems)
|
17
17
|
result = []
|
18
18
|
elems.each{|elem|
|
19
|
-
|
19
|
+
items = [
|
20
|
+
{
|
21
|
+
text: elem.name,
|
22
|
+
emphasis: 'style1'
|
23
|
+
}
|
24
|
+
]
|
20
25
|
elem.attributes.each{|key, val|
|
21
|
-
items = []
|
22
26
|
items << {
|
23
|
-
text: "#{key}
|
24
|
-
emphasis: 'style2'
|
27
|
+
text: " #{key} =",
|
25
28
|
}
|
26
29
|
items << {
|
27
|
-
text: val.value,
|
30
|
+
text: "\"#{val.value}\"",
|
28
31
|
emphasis: 'style2'
|
29
32
|
}
|
30
|
-
child << {
|
31
|
-
items: items,
|
32
|
-
children: []
|
33
|
-
}
|
34
33
|
}
|
34
|
+
child = []
|
35
35
|
if elem.children
|
36
|
-
child
|
36
|
+
child = get_nokogiri_as_tree(elem.children)
|
37
37
|
end
|
38
38
|
next if elem.name == 'text'
|
39
39
|
|
40
|
-
tree = {
|
41
|
-
items: [
|
42
|
-
{
|
43
|
-
text: elem.name,
|
44
|
-
emphasis: 'style1'
|
45
|
-
}
|
46
|
-
],
|
47
|
-
children: child
|
48
|
-
}
|
49
40
|
text = elem.xpath('text()').text
|
50
41
|
if text && text.strip != ""
|
51
|
-
|
52
|
-
|
42
|
+
child << {
|
43
|
+
items: [
|
44
|
+
text: text.strip,
|
45
|
+
emphasis: 'style3'
|
46
|
+
],
|
47
|
+
children: []
|
53
48
|
}
|
54
49
|
end
|
50
|
+
|
51
|
+
tree = {
|
52
|
+
items: items,
|
53
|
+
children: child
|
54
|
+
}
|
55
55
|
result << tree
|
56
56
|
}
|
57
57
|
result
|
@@ -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
|
-
children << {
|
30
|
-
items: items,
|
31
|
-
children: []
|
32
|
-
}
|
33
32
|
}
|
33
|
+
children = []
|
34
34
|
if elem.has_elements?
|
35
|
-
children
|
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: children
|
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
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:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/debugvisualizer/hash.rb
|
29
29
|
- lib/debugvisualizer/nokogiri.rb
|
30
30
|
- lib/debugvisualizer/rexml.rb
|
31
|
+
- lib/debugvisualizer/rubyvm_ast.rb
|
31
32
|
- lib/debugvisualizer/string_diff.rb
|
32
33
|
- lib/debugvisualizer/to_string.rb
|
33
34
|
- lib/debugvisualizer/version.rb
|