Class: Undercover::AstBranchAnnotator
- Inherits:
-
Object
- Object
- Undercover::AstBranchAnnotator
- Defined in:
- lib/undercover/ast_branch_annotator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#annotate(ast_node, info = {}) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize.
Class Method Details
.call(ast_node) ⇒ Object
5 6 7 |
# File 'lib/undercover/ast_branch_annotator.rb', line 5 def self.call(ast_node) new.annotate(ast_node) end |
Instance Method Details
#annotate(ast_node, info = {}) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/undercover/ast_branch_annotator.rb', line 10 def annotate(ast_node, info = {}) return info unless ast_node.is_a?(::Parser::AST::Node) case ast_node.type when :if annotate_if_node(ast_node, info) when :case ast_node.children.drop(1).each do |child| next unless child.is_a?(::Parser::AST::Node) && child.type == :when cond_src = expression_source(child.children.first) info[child.location.keyword.line] ||= "when #{cond_src}" end end ast_node.children.each { |c| annotate(c, info) } info end |