Module: DBConfig::Wordpress
- Defined in:
- lib/db-config-parse.rb
Class Method Summary collapse
Class Method Details
.parse(config) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/db-config-parse.rb', line 17 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_PASSWORD'], :database => configuration['DB_HOST']} end |