Class: DatabaseStalker::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/database_stalker/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_file) ⇒ Parser

Returns a new instance of Parser.



2
3
4
# File 'lib/database_stalker/parser.rb', line 2

def initialize(log_file)
  @log_file = log_file
end

Instance Method Details

#table_namesObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/database_stalker/parser.rb', line 6

def table_names
  tables = []
  File.open(@log_file, 'r') do |f|
    f.each_line do |line|
      matched = line.match(/INSERT\ INTO\ `(.+)` \(/)
      tables << matched[1] unless matched.nil?
    end
  end
  tables.uniq
end