Class: Dbmanager::Adapters::Mysql::Importer

Inherits:
Object
  • Object
show all
Includes:
Connectable
Defined in:
lib/dbmanager/adapters/mysql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Connectable

#params

Constructor Details

#initialize(source, target, tmp_file) ⇒ Importer

Returns a new instance of Importer.



91
92
93
94
95
# File 'lib/dbmanager/adapters/mysql.rb', line 91

def initialize(source, target, tmp_file)
  @source   = source
  @target   = target
  @tmp_file = tmp_file
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



89
90
91
# File 'lib/dbmanager/adapters/mysql.rb', line 89

def source
  @source
end

#targetObject (readonly)

Returns the value of attribute target.



89
90
91
# File 'lib/dbmanager/adapters/mysql.rb', line 89

def target
  @target
end

#tmp_fileObject (readonly)

Returns the value of attribute tmp_file.



89
90
91
# File 'lib/dbmanager/adapters/mysql.rb', line 89

def tmp_file
  @tmp_file
end

Instance Method Details

#remove_tmp_fileObject



104
105
106
# File 'lib/dbmanager/adapters/mysql.rb', line 104

def remove_tmp_file
  Dbmanager.execute "rm '#{tmp_file}'"
end

#runObject



97
98
99
100
101
102
# File 'lib/dbmanager/adapters/mysql.rb', line 97

def run
  Dumper.new(source, tmp_file).run
  Loader.new(target, tmp_file).run
ensure
  remove_tmp_file
end