Class: WPDB::Config::YAML
- Inherits:
-
Object
- Object
- WPDB::Config::YAML
- Defined in:
- lib/ruby-wpdb/config.rb
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(file) ⇒ YAML
constructor
A new instance of YAML.
- #parse ⇒ Object
Constructor Details
#initialize(file) ⇒ YAML
4 5 6 7 8 9 10 11 12 |
# File 'lib/ruby-wpdb/config.rb', line 4 def initialize(file) if file.respond_to? :read @contents = file.read else @contents = File.read(file) end parse end |
Instance Method Details
#config ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby-wpdb/config.rb', line 18 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 |
#parse ⇒ Object
14 15 16 |
# File 'lib/ruby-wpdb/config.rb', line 14 def parse @config = ::YAML::load(@contents) end |