summaryrefslogtreecommitdiff
path: root/lib/wrongdoc/readme.rb
blob: 8c5f5b66728999631b912d07896d8bb2771db211 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# helpers for parsing the top-level README file (no suffix support :P)
module Wrongdoc::Readme

  # returns a one-paragraph summary from the README
  def readme_description
    File.read("README").split(/\n\n/)[1]
  end

  # parses the README file in the top-level directory for project metadata
  def readme_metadata
    l = File.readlines("README")[0].strip!
    l.gsub!(/^=\s+/, '') or abort "#{l.inspect} doesn't start with '='"
    title = l.dup
    if l.gsub!(/^(\w+\!)\s+/, '') # Rainbows!
      return $1, l, title
    else
      return (l.split(/\s*[:-]\s*/, 2)).push(title)
    end
  end
end