lib/cabbage/dotfile/parser.rb
# pass it a string containing either the DotFile itself, or the path to
# a DOTfile.
pass it a string containing either the DotFile itself, or the path to
a DOTfile.
pass it a string containing either the DotFile itself or the path to a DOTfile .
def parse_header(raw_header, delimiter)
      temp = {}
      raw_header.scan(/(\w+)(?:\s*=?\s*)(?:["|\[](.+?)["|\]]#{delimiter})/m).each do |n|
        if n[1].include?("=")
          temp[n[0]] = parse_header(n[1], ",")
        else
          temp[n[0]] = n[1].strip
        end
      end
      return temp
    end
def parse_header ( raw_header , delimiter ) temp = { } raw_header . scan ( / ( \w +)(?: \s *=? \s *)(?:["| \[ ](.+?)["| \] ] #{ delimiter } ) /m ) . each do | n | if n [ 1 ] . include? ( "=" ) temp [ n [ 0 ] ] = parse_header ( n [ 1 ] , "," ) else temp [ n [ 0 ] ] = n [ 1 ] . strip end end return temp end
pass it a string containing either the DotFile itself, or the path to
a DOTfile.
pass it a string containing either the DotFile itself or the path to a DOTfile .
raw_header
<not_specific>
delimiter
<not_specific>