Method: GitHubChangelogGenerator::Reader#parse

Defined in:
lib/github_changelog_generator/reader.rb

#parse(data) ⇒ Array<Hash>

Parse the given ChangeLog data into a list of Hashes

Parameters:

  • data (String)

    File data from the ChangeLog.md

Returns:

  • (Array<Hash>)

    Parsed data, e.g. [{ ‘version’ => …, ‘url’ => …, ‘date’ => …, ‘content’ => …}, …]

[View source]

71
72
73
74
75
76
77
78
79
80
# File 'lib/github_changelog_generator/reader.rb', line 71

def parse(data)
  sections = data.split(/^## .+?$/)
  headings = data.scan(/^## .+?$/)

  headings.each_with_index.map do |heading, index|
    section = parse_heading(heading)
    section["content"] = sections.at(index + 1)
    section
  end
end