Drop Hashie dependency

This commit is contained in:
Olle Jonsson 2016-07-02 15:29:23 +02:00
parent ad44c035f0
commit 1177f09ca5
3 changed files with 19 additions and 15 deletions

View File

@ -40,21 +40,22 @@ module GitHubChangelogGenerator
end.reverse!
end
# Try to find tag date in local hash.
# Otherwise fFetch tag time and put it to local hash file.
# @param [Hash] tag_name name of the tag
# Returns date for given GitHub Tag hash
#
# Memoize the date by tag name.
#
# @param [Hash] tag_hash
#
# @return [Time] time of specified tag
def get_time_of_tag(tag_name)
raise ChangelogGeneratorError, "tag_name is nil" if tag_name.nil?
name_of_tag = tag_name["name"]
time_for_name = @tag_times_hash[name_of_tag]
if !time_for_name.nil?
time_for_name
else
time_string = @fetcher.fetch_date_of_tag tag_name
name_of_tag = tag_hash.fetch("name")
time_for_tag_name = @tag_times_hash[name_of_tag]
return time_for_tag_name if time_for_tag_name
@fetcher.fetch_date_of_tag(tag_hash).tap do |time_string|
@tag_times_hash[name_of_tag] = time_string
time_string
end
end
@ -151,7 +152,7 @@ module GitHubChangelogGenerator
if @options[:between_tags]
@options[:between_tags].each do |tag|
unless tag_names.include? tag
unless tag_names.include?(tag)
Helper.log.warn "Warning: can't find tag #{tag}, specified with --between-tags option."
end
end
@ -207,7 +208,7 @@ module GitHubChangelogGenerator
end
def warn_if_tag_not_found(all_tags, tag)
unless all_tags.map { |t| t["name"] }.include? tag
unless all_tags.map { |t| t["name"] }.include?(tag)
Helper.log.warn "Warning: can't find tag #{tag}, specified with --exclude-tags option."
end
end

View File

@ -200,7 +200,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
# Fetch tag time from repo
#
# @param [Hash] tag
# @param [Hash] tag GitHub data item about a Tag
#
# @return [Time] time of specified tag
def fetch_date_of_tag(tag)
commit_data = check_github_response { @client.commit(user_project, tag["commit"]["sha"]) }

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
describe GitHubChangelogGenerator::Generator do
def tag_with_name(tag)
{}.tap { |mash_tag| mash_tag["name"] = tag }
{
'name' => tag
}
end
def tags_from_strings(tags_strings)