change internal logic

This commit is contained in:
Petr Korolev 2015-06-10 14:37:26 +03:00
parent 67fbb04b31
commit a415010e86
5 changed files with 10 additions and 10 deletions

View File

@ -10,7 +10,7 @@ module GitHubChangelogGenerator
end
class Generator
attr_accessor :options, :all_tags, :github
attr_accessor :options, :filtered_tags, :github
# A Generator responsible for all logic, related with change log generation from ready-to-parse issues
#

View File

@ -17,8 +17,8 @@ module GitHubChangelogGenerator
# Async fetching tags:
threads = []
i = 0
all = @all_tags.count
@all_tags.each do |tag|
all = @filtered_tags.count
@filtered_tags.each do |tag|
print " \r"
threads << Thread.new do
@fetcher.get_time_of_tag(tag)

View File

@ -131,7 +131,7 @@ module GitHubChangelogGenerator
(1...all_tags.size).each do |index|
log += generate_log_between_tags(all_tags[index], all_tags[index - 1])
end
if @all_tags.count != 0
if @filtered_tags.count != 0
log += generate_log_between_tags(nil, all_tags.last)
end

View File

@ -36,7 +36,7 @@ module GitHubChangelogGenerator
false
else
# check, that this milestone in tag list:
milestone_is_tag = @all_tags.find do |tag|
milestone_is_tag = @filtered_tags.find do |tag|
tag.name == issue.milestone.title
end
@ -57,7 +57,7 @@ module GitHubChangelogGenerator
true
else
# check, that this milestone in tag list:
@all_tags.find { |tag| tag.name == issue.milestone.title }.nil?
@filtered_tags.find { |tag| tag.name == issue.milestone.title }.nil?
end
end
end

View File

@ -2,15 +2,15 @@ module GitHubChangelogGenerator
class Generator
# fetch, filter tags, fetch dates and sort them in time order
def fetch_and_filter_tags
@all_tags = get_filtered_tags(@fetcher.get_all_tags)
@filtered_tags = get_filtered_tags(@fetcher.get_all_tags)
fetch_tags_dates
sort_tags_by_date
sort_tags_by_date(@filtered_tags)
end
# Sort all tags by date
def sort_tags_by_date
def sort_tags_by_date(tags)
puts "Sorting tags..." if @options[:verbose]
@all_tags.sort_by! { |x| @fetcher.get_time_of_tag(x) }.reverse!
tags.sort_by! { |x| @fetcher.get_time_of_tag(x) }.reverse!
end
# Detect link, name and time for specified tag.