module WPDB::Config::ConfigFormat

Public Class Methods

new(file) click to toggle source
# File lib/ruby-wpdb/config.rb, line 7
def initialize(file)
  if file.respond_to? :read
    @contents = file.read
  else
    @contents = File.read(file)
  end

  parse
end

Public Instance Methods

config() click to toggle source
# File lib/ruby-wpdb/config.rb, line 17
def config
  uri  = 'mysql2://'
  uri += "#{@config['username']}:#{@config['password']}"
  uri += "@#{@config['hostname']}"
  uri += ":#{@config['port']}" if @config['port']
  uri += "/#{@config['database']}"

  { uri: uri, prefix: @config['prefix'] }
end