Module: Url2Yml
- Defined in:
- lib/url2yml.rb
Constant Summary collapse
- @@parameters =
{ adapter: /(.*):\/\//, username: /\/\/([^:]*):/, password: /\/\/.*:(.*)@/, host: /@(.*):/, port: /@.*:([0-9]*)/, database: /[0-9]\/(.*)$/ }.freeze
Class Method Summary collapse
Class Method Details
.parse(url) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/url2yml.rb', line 13 def parse(url) if url @@parameters.inject({}) do |connection_info, (param,regex)| matched = url.match(regex) matched && connection_info.update( param.to_sym => matched[1] ) connection_info end else {} end end |