Class: Dbmanager::Importer
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
Attributes inherited from Runner
#environments, #input, #output
Instance Method Summary collapse
Methods inherited from Runner
#get_env, #get_filename, #initialize
Constructor Details
This class inherits a constructor from Dbmanager::Runner
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/dbmanager/importer.rb', line 4 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
4 5 6 |
# File 'lib/dbmanager/importer.rb', line 4 def target @target end |
Instance Method Details
#adapter ⇒ Object
22 23 24 25 |
# File 'lib/dbmanager/importer.rb', line 22 def adapter raise MixedAdapterError if source.adapter != target.adapter Dbmanager::Adapters.const_get source.adapter.capitalize end |
#execute_import ⇒ Object
18 19 20 |
# File 'lib/dbmanager/importer.rb', line 18 def execute_import adapter::Importer.new(source, target, tmp_file).run end |
#get_data ⇒ Object
13 14 15 16 |
# File 'lib/dbmanager/importer.rb', line 13 def get_data self.source = get_env('source') self.target = get_env('target') end |
#run ⇒ Object
6 7 8 9 10 11 |
# File 'lib/dbmanager/importer.rb', line 6 def run get_data raise EnvironmentProtectedError if target.protected? execute_import output.puts 'Database Import completed.' end |
#tmp_file ⇒ Object
27 28 29 |
# File 'lib/dbmanager/importer.rb', line 27 def tmp_file @tmp_file ||= File.join Dbmanager.rails_root, 'tmp', Time.now.strftime('%y%m%d%H%M%S') end |