Class: Dbmanager::Adapters::Mysql::Loader
- Inherits:
-
Object
- Object
- Dbmanager::Adapters::Mysql::Loader
- Includes:
- Connectable
- Defined in:
- lib/dbmanager/adapters/mysql.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#tmp_file ⇒ Object
readonly
Returns the value of attribute tmp_file.
Instance Method Summary collapse
- #create_db_if_missing ⇒ Object
- #create_db_if_missing_command ⇒ Object
-
#initialize(target, tmp_file) ⇒ Loader
constructor
A new instance of Loader.
- #load ⇒ Object
- #load_command ⇒ Object
- #load_command_ssh ⇒ Object
- #run ⇒ Object
Methods included from Connectable
Constructor Details
#initialize(target, tmp_file) ⇒ Loader
Returns a new instance of Loader.
69 70 71 72 |
# File 'lib/dbmanager/adapters/mysql.rb', line 69 def initialize(target, tmp_file) @target = target @tmp_file = tmp_file end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
67 68 69 |
# File 'lib/dbmanager/adapters/mysql.rb', line 67 def target @target end |
#tmp_file ⇒ Object (readonly)
Returns the value of attribute tmp_file.
67 68 69 |
# File 'lib/dbmanager/adapters/mysql.rb', line 67 def tmp_file @tmp_file end |
Instance Method Details
#create_db_if_missing ⇒ Object
79 80 81 |
# File 'lib/dbmanager/adapters/mysql.rb', line 79 def create_db_if_missing Dbmanager.execute! create_db_if_missing_command end |
#create_db_if_missing_command ⇒ Object
95 96 97 |
# File 'lib/dbmanager/adapters/mysql.rb', line 95 def create_db_if_missing_command "bundle exec rake db:create RAILS_ENV=#{target.name}" end |
#load ⇒ Object
83 84 85 |
# File 'lib/dbmanager/adapters/mysql.rb', line 83 def load Dbmanager.execute! load_command end |
#load_command ⇒ Object
87 88 89 |
# File 'lib/dbmanager/adapters/mysql.rb', line 87 def load_command "mysql #{params(target)} < '#{tmp_file}'" end |
#load_command_ssh ⇒ Object
91 92 93 |
# File 'lib/dbmanager/adapters/mysql.rb', line 91 def load_command_ssh "mysql #{params target}" end |
#run ⇒ Object
74 75 76 77 |
# File 'lib/dbmanager/adapters/mysql.rb', line 74 def run create_db_if_missing load end |