Module: RaceGuard::IndexIntegrity::SchemaAnalyzer

Defined in:
lib/race_guard/index_integrity/schema_analyzer.rb

Class Method Summary collapse

Class Method Details

.from_connection(connection, tables: nil) ⇒ Object



37
38
39
# File 'lib/race_guard/index_integrity/schema_analyzer.rb', line 37

def from_connection(connection, tables: nil)
  SchemaConnectionIndexes.fetch(connection, tables: tables)
end

.parse_file(path) ⇒ Object



19
20
21
22
23
24
# File 'lib/race_guard/index_integrity/schema_analyzer.rb', line 19

def parse_file(path)
  src = File.read(path, encoding: 'UTF-8')
  parse_source(src)
rescue Errno::ENOENT, ArgumentError, Parser::SyntaxError
  []
end

.parse_source(source) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/race_guard/index_integrity/schema_analyzer.rb', line 26

def parse_source(source)
  ast = Parser::CurrentRuby.parse(source)
  return [] unless ast

  out = []
  SchemaWalker.new(out).walk(ast, nil)
  out
rescue Parser::SyntaxError
  []
end