Class: Solargraph::Rspec::SpecWalker::FullConstantName

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/rspec/spec_walker/full_constant_name.rb

Class Method Summary collapse

Class Method Details

.from_ast(ast) ⇒ String

Parameters:

  • ast (::Parser::AST::Node)

Returns:

  • (String)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/solargraph/rspec/spec_walker/full_constant_name.rb', line 10

def from_ast(ast)
  parts = []

  until ast.nil?
    if ast.is_a? ::Parser::AST::Node
      break unless ast.type == :const

      parts << ast.children[1]
      ast = ast.children[0]
    else
      parts << ast
      break
    end
  end

  parts.reverse.join('::')
end

.from_context_block_ast(block_ast) ⇒ Object



28
29
30
31
# File 'lib/solargraph/rspec/spec_walker/full_constant_name.rb', line 28

def from_context_block_ast(block_ast)
  ast = NodeTypes.context_description_node(block_ast)
  from_ast(ast)
end