From dd0d82ab91c4e82b424a691b9197aaa551e4c296 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Fri, 23 Oct 2015 07:44:20 +0200 Subject: [PATCH] [refactor] Fix YARD datatype, use #map --- lib/github_changelog_generator/reader.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/github_changelog_generator/reader.rb b/lib/github_changelog_generator/reader.rb index f46301f..d40769e 100644 --- a/lib/github_changelog_generator/reader.rb +++ b/lib/github_changelog_generator/reader.rb @@ -62,22 +62,19 @@ module GitHubChangelogGenerator captures end - # Parse the given ChangeLog data into a Hash + # Parse the given ChangeLog data into a list of Hashes # # @param [String] data File data from the ChangeLog.md - # @return [Hash] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...] + # @return [Array] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...] def parse(data) sections = data.split(/^## .+?$/) headings = data.scan(/^## .+?$/) - changelog = [] - headings.each_with_index do |heading, index| - captures = parse_heading(heading) - captures["content"] = sections.at(index + 1) - changelog.push captures + headings.each_with_index.map do |heading, index| + section = parse_heading(heading) + section["content"] = sections.at(index + 1) + section end - - changelog end def read(file_path)