Class: WPDB::Config::WPConfig

Inherits:
Object
  • Object
show all
Includes:
ConfigFormat
Defined in:
lib/ruby-wpdb/config.rb

Instance Method Summary collapse

Methods included from ConfigFormat

#config, #initialize

Instance Method Details

#parseObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/ruby-wpdb/config.rb', line 39

def parse
  config = Hash[@contents.scan(/define\((?:'|")(.+)(?:'|"), *(?:'|")(.+)(?:'|")\)/)]
  @config = {
    "username" => config["DB_USER"],
    "password" => config["DB_PASSWORD"],
    "hostname" => config["DB_HOST"],
    "database" => config["DB_NAME"],
    "prefix"   => config["DB_PREFIX"] || "wp_"
  }
end