Skip to content

Instantly share code, notes, and snippets.

@nvkv
Created September 6, 2010 15:15
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 nvkv/567147 to your computer and use it in GitHub Desktop.
Save nvkv/567147 to your computer and use it in GitHub Desktop.
def parse
result, utf8 = [], Iconv.new("UTF-8", "UTF-16")
@parsing_string = utf8.iconv(@parsing_string)
# Get all comments (including multiline)
comments = @parsing_string.scan /\*((?:.|[\r\n])*?)\*/
# Get all key-value pairs
pairs = @parsing_string.scan /\"(.*)\" = \"(.*)\"/
comments.each_with_index do |comment, index|
result << {
:comment => comment.first,
:key => pairs[index].first,
:value => pairs[index].last
}
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment