Module: VladExtras::Database

Defined in:
lib/vlad-extras/database.rb

Class Method Summary collapse

Class Method Details

.mysql_config(config) ⇒ Object


3
4
5
6
7
8
9
10
11
# File 'lib/vlad-extras/database.rb', line 3

def self.mysql_config(config)
  cmd  = " "
  cmd += "-h #{config['host']} " unless config['host'].blank?
  cmd += "-P #{config['port']} " unless config['port'].blank?
  cmd += "-u #{config['username']} " unless config['username'].blank?
  cmd += "-p#{config['password']} " unless config['password'].blank?
  cmd += config['database']
  cmd
end

.psql_config(config) ⇒ Object


13
14
15
16
17
18
19
20
# File 'lib/vlad-extras/database.rb', line 13

def self.psql_config(config)
  cmd  = " "
  cmd += "-h #{config['host']} " unless config['host'].blank?
  cmd += "-p #{config['port']} " unless config['port'].blank?
  cmd += "-U #{config['username']} " unless config['username'].blank?
  cmd += config['password'].blank? ? "#{config['database']}" : "'dbname=#{config['database']} password=#{config['password']}'"
  cmd
end