Module: Helper
- Defined in:
- lib/db/helper.rb
Class Method Summary collapse
- .append_stage_to_filename(file_name, stage = 'local') ⇒ Object
- .duplicate_local_dump_to_staged_dump ⇒ Object
- .local_stage? ⇒ Boolean
- .mysql_args(additional_args = []) ⇒ Object
Instance Method Summary collapse
Class Method Details
.append_stage_to_filename(file_name, stage = 'local') ⇒ Object
12 13 14 15 16 17 |
# File 'lib/db/helper.rb', line 12 def self.append_stage_to_filename(file_name, stage = 'local') splitted = file_name.split('.') extension = splitted.pop splitted.push stage, extension splitted.join('.') end |
.duplicate_local_dump_to_staged_dump ⇒ Object
19 20 21 22 23 |
# File 'lib/db/helper.rb', line 19 def self.duplicate_local_dump_to_staged_dump() staged_file = append_stage_to_filename(fetch(:db_local_dump), fetch(:stage)) FileUtils.cp(fetch(:db_local_dump), staged_file) end |
.local_stage? ⇒ Boolean
25 26 27 |
# File 'lib/db/helper.rb', line 25 def self.local_stage? fetch(:local_stage_name).to_sym == fetch(:stage).to_sym end |
.mysql_args(additional_args = []) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/db/helper.rb', line 2 def self.mysql_args(additional_args=[]) command = " -u #{fetch(:db_user)}" command+= " -p#{fetch(:db_pass)}" unless fetch(:db_pass).empty? command+= " #{additional_args.join(' ')} " # dont use --database statement, so no use '...' will be generated command+= " #{fetch(:db_name)}" unless fetch(:db_name).empty? command end |
Instance Method Details
#execute_local_or_remote(cmd) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/db/helper.rb', line 29 def execute_local_or_remote(cmd) if local_stage? run_locally do execute cmd end else execute cmd end end |