Change to use Rainbow instead of colorize

colorize is licensed under GPL-2 which conflicts with the MIT license of
github_changelog_generator.  This changes all usage of colorize to
rainbow which does have a compatible license (MIT)
This commit is contained in:
James Casey 2016-08-31 14:17:35 -07:00
parent d23375f5ac
commit f647dc0d98
8 changed files with 25 additions and 26 deletions

View File

@ -2,7 +2,7 @@ PATH
remote: .
specs:
github_changelog_generator (1.13.1)
colorize (>= 0.7)
rainbow (>= 2.1)
github_api (>= 0.12)
rake (>= 10.0)
@ -15,7 +15,6 @@ GEM
ffi (~> 1.0, >= 1.0.11)
codeclimate-test-reporter (0.6.0)
simplecov (>= 0.7.1, < 1.0.0)
colorize (0.8.1)
coveralls (0.8.14)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)

View File

@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "rake", ">= 10.0"
spec.add_runtime_dependency "github_api", ">= 0.12"
spec.add_runtime_dependency "colorize", ">= 0.7"
spec.add_runtime_dependency "rainbow", ">= 2.1"
spec.add_development_dependency "overcommit", ">= 0.31"
spec.add_development_dependency "rspec", ">= 3.2"

View File

@ -2,7 +2,7 @@
require "github_api"
require "json"
require "colorize"
require "rainbow/ext/string"
require "benchmark"
require_relative "github_changelog_generator/helper"

View File

@ -34,7 +34,7 @@ module GitHubChangelogGenerator
def fetch_github_token
env_var = @options[:token] ? @options[:token] : (ENV.fetch CHANGELOG_GITHUB_TOKEN, nil)
Helper.log.warn NO_TOKEN_PROVIDED.yellow unless env_var
Helper.log.warn NO_TOKEN_PROVIDED.color(:yellow) unless env_var
env_var
end
@ -53,11 +53,11 @@ module GitHubChangelogGenerator
begin
value = yield
rescue Github::Error::Unauthorized => e
Helper.log.error e.response_message.red
Helper.log.error e.response_message.color(:red)
abort "Error: wrong GitHub token"
rescue Github::Error::Forbidden => e
Helper.log.warn e.response_message.red
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
Helper.log.warn e.response_message.color(:red)
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow)
end
value
end
@ -78,7 +78,7 @@ module GitHubChangelogGenerator
if tags.count == 0
Helper.log.warn "Warning: Can't find any tags in repo.\
Make sure, that you push tags to remote repo via 'git push --tags'".yellow
Make sure, that you push tags to remote repo via 'git push --tags'".color(:yellow)
else
Helper.log.info "Found #{tags.count} tags"
end
@ -110,8 +110,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
Helper.log.info "Received issues: #{issues.count}"
rescue Github::Error::Forbidden => e
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red)
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow)
end
# separate arrays of issues and pull requests:
@ -145,8 +145,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
end
print_empty_line
rescue Github::Error::Forbidden => e
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red)
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow)
end
Helper.log.info "Fetching merged dates: #{pull_requests.count}"
@ -182,8 +182,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
issue[:events].concat(page)
end
rescue Github::Error::Forbidden => e
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red)
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow)
end
print_in_same_line("Fetching events for issues and PR: #{i + 1}/#{issues.count}")
i += 1
@ -209,8 +209,8 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
@options[:project],
tag["commit"]["sha"]
rescue Github::Error::Forbidden => e
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").red
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.yellow
Helper.log.warn e.error_messages.map { |m| m[:message] }.join(", ").color(:red)
Helper.log.warn GH_RATE_LIMIT_EXCEEDED_MSG.color(:yellow)
end
time_string = commit_data["committer"]["date"]
Time.parse(time_string)

View File

@ -74,7 +74,7 @@ module GitHubChangelogGenerator
commit = @fetcher.fetch_commit(event)
issue[:actual_date] = commit[:author][:date]
rescue
puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".yellow
puts "Warning: Can't fetch commit #{event[:commit_id]}. It is probably referenced from another repo.".color(:yellow)
issue[:actual_date] = issue[:closed_at]
end
end

View File

@ -39,10 +39,10 @@ module GitHubChangelogGenerator
index2 = hash[tag2]
log += generate_log_between_tags(all_tags[index1], all_tags[index2])
else
raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".color(:red)
end
else
raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".color(:red)
end
log
end

View File

@ -19,7 +19,7 @@ module GitHubChangelogGenerator
# @param [Hash] tag_name name of the tag
# @return [Time] time of specified tag
def get_time_of_tag(tag_name)
raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
raise ChangelogGeneratorError, "tag_name is nil".color(:red) if tag_name.nil?
name_of_tag = tag_name["name"]
time_for_name = @tag_times_hash[name_of_tag]

View File

@ -15,15 +15,15 @@ module GitHubChangelogGenerator
string = "#{msg}\n"
if severity == "DEBUG"
string = string.magenta
string = string.color(:magenta)
elsif severity == "INFO"
string = string.white
string = string.color(:white)
elsif severity == "WARN"
string = string.yellow
string = string.color(:yellow)
elsif severity == "ERROR"
string = string.red
string = string.color(:red)
elsif severity == "FATAL"
string = string.red.bold
string = string.color(:red).bright
end
string