Class: Spoom::Coverage::D3::CircleMap::Sigils

Inherits:
Spoom::Coverage::D3::CircleMap show all
Defined in:
lib/spoom/coverage/d3/circle_map.rb

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Spoom::Coverage::D3::CircleMap

header_script, header_style, #script

Methods inherited from Base

header_script, header_style, #html, #script, #tooltip

Constructor Details

#initialize(id, file_tree, nodes_strictnesses, nodes_scores) ⇒ Sigils

: (String id, FileTree file_tree, Hash[FileTree::Node, String?] nodes_strictnesses, Hash[FileTree::Node, Float] nodes_scores) -> void



149
150
151
152
153
# File 'lib/spoom/coverage/d3/circle_map.rb', line 149

def initialize(id, file_tree, nodes_strictnesses, nodes_scores)
  @nodes_strictnesses = nodes_strictnesses
  @nodes_scores = nodes_scores
  super(id, file_tree.roots.map { |r| tree_node_to_json(r) })
end

Instance Method Details

#tree_node_to_json(node) ⇒ Object

: (FileTree::Node node) -> Hash[Symbol, untyped]



156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/spoom/coverage/d3/circle_map.rb', line 156

def tree_node_to_json(node)
  if node.children.empty?
    {
      name: node.name,
      strictness: @nodes_strictnesses.fetch(node, "false"),
    }
  else
    {
      name: node.name,
      children: node.children.values.map { |n| tree_node_to_json(n) },
      score: @nodes_scores.fetch(node, 0.0),
    }
  end
end