Lurker News

Comments (61) 22 threads

Show all comments

Showing thread 15 of 22

dchuk1 reply#
Interesting to see that decent-sized list of languages without Ruby in it. Is there some technical limitation preventing ruby support?
Gehinnn1 reply#
It should work out of the box, but nobody confirmed yet that it works with ruby ;)
daviding1 reply#
In ruby if you have the right json schema set up it works. I'm not sure I completely grok yet how the data extractors would work on the ruby side yet though.

https://i.imgur.com/84mgPdF.jpg

Gehinnn1 reply#
Data Extractors usually need support from the extension. But you can configure how to construct the expression that is sent to the debugger to be evaluated. By default, it is `x => x`, but you could do `x => extract_json(x)`.
daviding1 reply#
Thanks, that works. I can put something simple in my settings.json like this

  "debugVisualizer.debugAdapterConfigurations": {
    "Ruby": {
      "expressionTemplate": "DataExtractor.to_table(${expr})",
    }
   },
..and something simple in the debugee like this..

  table_example =
    {"id"=> "1", "label"=> "One"},
    {"id"=> "2", "label"=> "Two"},
    {"id"=> "3", "label"=> "Three"}

  # Quick hash to visual table helper
  class DataExtractor
    def self.to_table(hash)
      meta_hash = {
        "kind" => {"table"=> true},
        "rows"=> hash
      }
      meta_hash.to_json
    end
  end
..and we get a decent hash or ActiveRecord visualizer. Thanks for the hint.
Gehinnn2 replies#
Data Extractors would also allow to offer alternative extraction options (like how visualization data should be constructed from the given value). The user can then select an alternative data extractor.

The `expressionTemplate` does not allow to do that yet.
If somebody is interested in implementing data extractors for Ruby, I can offer help!

Continue this thread — 2 replies