Sha256: 64840aae35040642dfc611201fe686ea62c66e8fa35772952a9319e3abe094d5
Contents?: true
Size: 904 Bytes
Versions: 6
Compression:
Stored size: 904 Bytes
Contents
require 'forwardable' module AppMap module RSpec # ParseNodeStruct wraps a generic AST parse node. ParseNodeStruct = Struct.new(:node, :file_path, :ancestors) do end # ParseNode wraps a generic AST parse node. class ParseNode < ParseNodeStruct extend Forwardable def_delegators :node, :type, :location class << self # Build a ParseNode from an AST node. def from_node(node, file_path, ancestors) case node.type when :block BlockParseNode.new(node, file_path, ancestors.dup) end end end end # A Ruby block. class BlockParseNode < ParseNode def to_s "RSpec block at #{file_path} #{first_line}:#{last_line}" end def first_line node.location.first_line end def last_line node.location.last_line end end end end
Version data entries
6 entries across 6 versions & 1 rubygems