Skip to content

Instantly share code, notes, and snippets.

@bmaland
Created May 24, 2009 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmaland/117293 to your computer and use it in GitHub Desktop.
Save bmaland/117293 to your computer and use it in GitHub Desktop.
require "yaml"
# Parser for Debian Control Files (http://www.debian.org/doc/debian-policy/ch-controlfields.html)
# Piggybacks on the stdlib YAML parser, so this only works as long as there is a
# space after the field names (this is a stated DCF convention). You'll encounter problems if
# there are unescaped colons in the values.
#
# I've also built a full Treetop grammar for DCF: http://github.com/Chrononaut/treetop-dcf
module Dcf
# Returns an array of { attr => val } hashes
def self.parse(input)
input.split("\n\n").collect { |p| YAML.load(p) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment