Module: Dub::OptsParser
- Defined in:
- lib/dub/opts_parser.rb
Constant Summary collapse
- ENTRY_REGEXP =
%r{^\s*([^:]+):\s*('[^']*'|"[^"]*")\s*,?\s*}m
Class Method Summary collapse
Class Method Details
.extract_hash(xml) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dub/opts_parser.rb', line 4 def self.extract_hash(xml) (xml/'simplesect').each do |x| if (x/'title').inner_html == 'Bindings info:' (x/'title').remove() (x/'ref').each do |r| r.swap(r.inner_html) end code = EntitiesUnescape::Decoder.decode((x/'para').inner_html) return self.parse(code) end end nil end |
.parse(src) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dub/opts_parser.rb', line 18 def self.parse(src) res = {} while !src.empty? && src =~ ENTRY_REGEXP src = src.sub(ENTRY_REGEXP) do res[$1.to_sym] = $2[1..-2] '' end end res end |