add docs. add fail statment

This commit is contained in:
Petr Korolev 2015-04-04 03:27:05 +03:00
parent c44be45ce4
commit b598bd5ba1

View File

@ -229,6 +229,8 @@ module GitHubChangelogGenerator
puts "Generated log placed in #{`pwd`.strip!}/#{output_filename}"
end
# The full cycle of generation for whole project
# @return [String] The complete change log
def generate_log_for_all_tags
fetch_tags_dates
@ -261,6 +263,7 @@ module GitHubChangelogGenerator
log
end
# Async fetching of all tags dates
def fetch_tags_dates
if @options[:verbose]
print "Fetching tag dates...\r"
@ -398,8 +401,8 @@ module GitHubChangelogGenerator
def delete_by_time(array, hash_key = :actual_date, older_tag = nil, newer_tag = nil)
fail ChangelogGeneratorError, "At least one of the tags should be not nil!".red if older_tag.nil? && newer_tag.nil?
newer_tag_time = get_time_of_tag(newer_tag)
older_tag_time = get_time_of_tag(older_tag)
newer_tag_time = newer_tag && get_time_of_tag(newer_tag)
older_tag_time = older_tag && get_time_of_tag(older_tag)
array.select { |req|
if req[hash_key]
@ -529,10 +532,13 @@ module GitHubChangelogGenerator
log
end
# Try to find tag date in local hash.
# Otherwise fFetch tag time and put it to local hash file.
# @param [String] tag_name name of the tag
# @param [Hash] tag_times_hash the hash of tag times
# @return [Time] time of specified tag
def get_time_of_tag(tag_name, tag_times_hash = @tag_times_hash)
if tag_name.nil?
return nil
end
fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
if tag_times_hash[tag_name["name"]]
return @tag_times_hash[tag_name["name"]]