Module: MyObfuscate::InsertStatementParser

Included in:
Mysql, SqlServer
Defined in:
lib/my_obfuscate/insert_statement_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(obfuscator, config, input_io, output_io) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/my_obfuscate/insert_statement_parser.rb', line 4

def parse(obfuscator, config, input_io, output_io)
  input_io.each do |line|
    if table_data = parse_insert_statement(line)
      table_name = table_data[:table_name]
      columns = table_data[:column_names]
      if config[table_name]
        output_io.puts obfuscator.obfuscate_bulk_insert_line(line, table_name, columns)
      else
        $stderr.puts "Deprecated: #{table_name} was not specified in the config.  A future release will cause this to be an error.  Please specify the table definition or set it to :keep."
        output_io.write line
      end
    else
      output_io.write line
    end
  end
end