Module: DBConfig::Prestashop
- Defined in:
- lib/db-config-parse.rb
Class Method Summary collapse
Class Method Details
.parse(config) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/db-config-parse.rb', line 30 def self.parse(config) db_credentials = File.readlines config configuration = db_credentials.find_all do |cr| cr =~ /define\('_DB/ end.inject({}) do |acc, e| f = e.match(/define\('(.*)', '(.*)'\).*$/) acc.merge({f[1] => f[2]}) end {:username => configuration['_DB_USER_'], :password => configuration['_DB_PASSWD_'], :database => configuration['_DB_NAME_']} end |