Top Level Namespace
Defined Under Namespace
Modules: Mina
Constant Summary collapse
- ARGUMENTS =
" dc = YAML.load(ERB.new(File.read(ARGV[0])).result)[ARGV[1]]\n adapter = dc[\"adapter\"]\n database = dc[\"database\"]\n host = dc[\"host\"]\n username = dc[\"username\"]\n password = dc[\"password\"]\n port = dc[\"port\"]\n arguments = \"\"\n case adapter.to_s\n when \"postgresql\"\n arguments += \" -d \" + database if database\n arguments += \" -h \" + host if host\n arguments += \" -U \" + username if username\n arguments += \" -p \" + port.to_s if port\n when \"mysql2\"\n arguments += \" \" + database if database\n arguments += \" -h \" + host if host\n arguments += \" -u \" + username if username\n arguments += \" --password=\" + password if password\n arguments += \" -P \" + port.to_s if port\n end\n puts arguments\n"- CONF =
" function conf {\n ruby -ryaml -rerb -e '\#{ARGUMENTS}' \"$@\"\n };\n"
Instance Method Summary collapse
- #backup_file ⇒ Object
- #dump ⇒ Object
- #options ⇒ Object
- #read_conf(path, rails_env) ⇒ Object
- #restore ⇒ Object
Instance Method Details
#backup_file ⇒ Object
36 37 38 |
# File 'lib/mina/data_sync/helpers.rb', line 36 def backup_file "#{@conf['database']}-#{Date.today}.sql" end |
#dump ⇒ Object
40 41 42 43 44 45 |
# File 'lib/mina/data_sync/helpers.rb', line 40 def dump case @conf['adapter'] when 'postgresql' then 'pg_dump' when 'mysql2' then 'mysqldump' end end |
#options ⇒ Object
54 55 56 57 58 59 |
# File 'lib/mina/data_sync/helpers.rb', line 54 def case @conf['adapter'] when 'postgresql' then '-O -c' when 'mysql2' then '' end end |
#read_conf(path, rails_env) ⇒ Object
32 33 34 |
# File 'lib/mina/data_sync/helpers.rb', line 32 def read_conf(path, rails_env) @conf ||= YAML.load(ERB.new(File.read(path)).result)[rails_env] end |
#restore ⇒ Object
47 48 49 50 51 52 |
# File 'lib/mina/data_sync/helpers.rb', line 47 def restore case @conf['adapter'] when 'postgresql' then 'psql -q' when 'mysql2' then 'mysql --verbose' end end |