debugvisualizer 0.1.0 → 0.1.2

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: 7a8a3162f364560e6455c89c36a29b7d82fd5aa437928b342d6317eb457c0d1b
4
- data.tar.gz: c642e62625d02e20ef8d2691bbc737eb365619db984964be01d596b40e60c070
3
+ metadata.gz: 3b719636b47462d2a54b48ff79f1ede7f301e3dd9e46eace72082229c04456c3
4
+ data.tar.gz: 237313e0d0370b4f6ae84f863d942fe302880fc99c2ba0aedcf987cce81cf096
5
5
  SHA512:
6
- metadata.gz: e1ed30c914a88b7f86b08c77df974bb0e61471428565ad9f73e7a67d9bf3c05503b694ec5f873d7cb1c8908e025e86a70a9f8193f43b5886af903eef4741d300
7
- data.tar.gz: 847b26a202f2bf10210635958d5b5ecc460c09a6baf037147c5b900f20f24fa19acb23e1b4e95633197518c0fce480ef476d0993c62ee5ed9a3f066ec47fa8f4
6
+ metadata.gz: 8137405f3127b4aa8c4bd2ae65f63983a064fb33b12daaaf6460058aaa89307692c6ce217f1bc8dd6883934ee93f5326b66145dfe186f848e5d285b352605c4d
7
+ data.tar.gz: 0db17a85c88c001d4ed17c2dc15ac044f9647b11c54d2d3b3d69949882c1a8ed6812251b2edb92e09a2123c8bafb2b6c0830580d5fab978a4ace8b9b540056a1
data/README.md CHANGED
@@ -40,3 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
40
40
  ## Contributing
41
41
 
42
42
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/debugvisualizer.
43
+
44
+ ## Acknowledgement
45
+
46
+ [Koichi Sasada (@ko1)](https://github.com/ko1) - He reviewed API and gave me many ideas to improve `debugvisualizer`.
@@ -2,6 +2,8 @@
2
2
 
3
3
  require_relative "lib/debugvisualizer/version"
4
4
 
5
+ $LOAD_PATH.unshift(File.join(__dir__, 'lib'))
6
+
5
7
  Gem::Specification.new do |spec|
6
8
  spec.name = "debugvisualizer"
7
9
  spec.version = DebugVisualizer::VERSION
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DebugVisualizer
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -4,13 +4,18 @@ require 'securerandom'
4
4
  require 'json'
5
5
 
6
6
  module DebugVisualizer
7
- def register &block
7
+ def register klass = nil, &block
8
8
  raise unless block_given?
9
9
 
10
10
  unless defined? GENERATOR
11
11
  DebugVisualizer.const_set(:GENERATOR, JSONGenerator.new)
12
12
  end
13
- GENERATOR.register_block block
13
+
14
+ if klass
15
+ GENERATOR.register_block_with_class klass, block
16
+ else
17
+ GENERATOR.register_block block
18
+ end
14
19
  end
15
20
 
16
21
  def to_debug_visualizer_protocol_json preferred_id, data
@@ -24,12 +29,17 @@ module DebugVisualizer
24
29
 
25
30
  def initialize
26
31
  @blocks = []
32
+ @block_with_class = {}
27
33
  end
28
34
 
29
35
  def register_block block
30
36
  @blocks << block
31
37
  end
32
38
 
39
+ def register_block_with_class klass, block
40
+ @block_with_class[klass] = block
41
+ end
42
+
33
43
  def generate preferred_id, data
34
44
  extractors = []
35
45
  @blocks.each{|block|
@@ -39,6 +49,15 @@ module DebugVisualizer
39
49
  end
40
50
  }
41
51
 
52
+ @block_with_class.each{|klass, block|
53
+ if data.kind_of? klass
54
+ result = block.call(data)
55
+ if result && result[:id] && result[:data]
56
+ extractors << get_extractor(result)
57
+ end
58
+ end
59
+ }
60
+
42
61
  return JSON.generate({ kind: "NoExtractors" }) if extractors.empty?
43
62
 
44
63
  sorted = extractors.sort_by{|ex| -ex[:priority]}
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.0
4
+ version: 0.1.2
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-11-15 00:00:00.000000000 Z
11
+ date: 2022-11-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: debugvisualizer generates JSON based on VS Code Debug Visualizer protocol
14
14
  email: