Class: PG::DSNParser
- Inherits:
-
Object
- Object
- PG::DSNParser
- Defined in:
- lib/pg/dsn_parser.rb,
lib/pg/dsn_parser/version.rb
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.parse(*args) ⇒ Object
6 7 8 |
# File 'lib/pg/dsn_parser.rb', line 6 def self.parse(*args) new.parse(*args) end |
Instance Method Details
#parse(dsn) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pg/dsn_parser.rb', line 10 def parse(dsn) scanner = StringScanner.new(dsn.strip) dsn_hash = {} until scanner.eos? # get the key by matching up to and including the (optionally) white space bordered '=' key = scanner.scan_until(/\s*=\s*/) key = key[0...-scanner.matched_size] dsn_hash[key.to_sym] = get_dsn_value(scanner) end dsn_hash end |