class DataMask::DBShell
Attributes
options[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/data_mask/db_shell.rb, line 5 def initialize(options) @options = options end
Public Instance Methods
export(**opt)
click to toggle source
# File lib/data_mask/db_shell.rb, line 9 def export(**opt) cmd = '' cmd += send("#{@options[:adapter]}_cmd", 'export') cmd += "> %{database}-masking-#{Time.now.to_f.to_i}.sql" % @options if opt[:to_file] cmd end
import(filepath=nil)
click to toggle source
# File lib/data_mask/db_shell.rb, line 16 def import(filepath=nil) cmd = '' cmd += send("#{@options[:adapter]}_cmd", 'import') cmd += "< #{filepath}" if filepath cmd end
Private Instance Methods
mysql_cmd(type)
click to toggle source
# File lib/data_mask/db_shell.rb, line 34 def mysql_cmd(type) cmd = "#{type=='export' ? 'mysqldump' : 'mysql'} " cmd += "-h %{host} " % @options if @options[:host] cmd += "-P %{port} " % @options if @options[:port] cmd += "-u %{user} " % @options if @options[:user] cmd += "-p %{password} " % @options if @options[:password] cmd += "%{database} " % @options cmd end
postgres_cmd(type)
click to toggle source
# File lib/data_mask/db_shell.rb, line 25 def postgres_cmd(type) cmd = "#{type=='export' ? 'pg_dump' : 'psql'} " cmd += "-h %{host} " % @options if @options[:host] cmd += "-p %{port} " % @options if @options[:port] cmd += "-U %{user} " % @options if @options[:user] cmd += "%{database} " % @options if @options[:database] cmd end