debugvisualizer 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81596abbcfa338e898076371be112d8e0544c9a3b242eb959f39e1fc71bd181e
4
- data.tar.gz: 5dbb1660ec95cc1ed235a085aa5d4ed465b7e16fa039543ba64a08b8540366a5
3
+ metadata.gz: 99b5095a86aff837ff3210a772f31625ec184c6393076a86df47137f10a8da38
4
+ data.tar.gz: e7eda2e94c63f0428960bbd1185e347152c356da410ad9646327983255283797
5
5
  SHA512:
6
- metadata.gz: 624328db9fe88ecbf67d62b0e1cb04e28dfdb6b89c11d035a04e3b7cb7a94864356bca4f1f40a1bb0bb019b89d5e4e9e5ec118b334cec99934dfa3920e1b47bb
7
- data.tar.gz: c81c5ece7c99600621b8e9ce9b589220531d9269516b2bea3a7b139aaf8eef9bedb08c9a05b0d413a1e05366fe7b135acb73d0f828be0aeacf91aa1b3e68f5a0
6
+ metadata.gz: 28059f5e1c89d4642e99e0672ed18d677b4b87430cf8f33ebdb23ebfef09462f054fd865d1bf6b02bfb4915f826a7706482c2bddda50b616cd6ad7f14eec3899
7
+ data.tar.gz: bf6103a0494df88e7ba175402efae691f6ab285b7efa936c05907100af1db59141578a7094cc9ab4d8b655223913854aae4dfb85779b870f32f77804fca735e3
@@ -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
+ child = []
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
+ child << {
30
+ items: items,
31
+ children: []
32
+ }
33
+ }
34
+ if elem.has_elements?
35
+ child.push *get_tree(elem)
36
+ end
37
+ tree = {
38
+ items: [
39
+ {
40
+ text: elem.name,
41
+ emphasis: 'style1'
42
+ }
43
+ ],
44
+ children: child
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DebugVisualizer
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -115,3 +115,4 @@ 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'
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.3
4
+ version: 0.1.4
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-02 00:00:00.000000000 Z
11
+ date: 2022-12-04 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,7 @@ files:
26
26
  - lib/debugvisualizer/active_record.rb
27
27
  - lib/debugvisualizer/array.rb
28
28
  - lib/debugvisualizer/hash.rb
29
+ - lib/debugvisualizer/rexml.rb
29
30
  - lib/debugvisualizer/string_diff.rb
30
31
  - lib/debugvisualizer/to_string.rb
31
32
  - lib/debugvisualizer/version.rb