create class and implement encapsulation. This fix #34
This commit is contained in:
parent
f1d9c839c7
commit
057fb488d5
|
@ -4,6 +4,7 @@ require 'github_api'
|
||||||
require 'json'
|
require 'json'
|
||||||
require 'colorize'
|
require 'colorize'
|
||||||
require_relative 'github_changelog_generator/parser'
|
require_relative 'github_changelog_generator/parser'
|
||||||
|
require_relative 'github_changelog_generator/generator'
|
||||||
require_relative 'github_changelog_generator/version'
|
require_relative 'github_changelog_generator/version'
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
|
@ -29,6 +30,8 @@ module GitHubChangelogGenerator
|
||||||
@github = Github.new oauth_token: @github_token
|
@github = Github.new oauth_token: @github_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
generator = Generator.new(@options)
|
||||||
|
|
||||||
@all_tags = self.get_all_tags
|
@all_tags = self.get_all_tags
|
||||||
@pull_requests = self.get_all_closed_pull_requests
|
@pull_requests = self.get_all_closed_pull_requests
|
||||||
if @options[:issues]
|
if @options[:issues]
|
||||||
|
@ -264,19 +267,11 @@ module GitHubChangelogGenerator
|
||||||
|
|
||||||
if @options[:pulls]
|
if @options[:pulls]
|
||||||
# Generate pull requests:
|
# Generate pull requests:
|
||||||
if pull_requests
|
pull_requests.each { |pull_request|
|
||||||
|
merge = generator.get_string_for_pull_request(pull_request)
|
||||||
|
log += "- #{merge}"
|
||||||
|
|
||||||
pull_requests.each { |dict|
|
} if pull_requests
|
||||||
merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})"
|
|
||||||
if @options[:author]
|
|
||||||
merge += " ([#{dict.user.login}](#{dict.user.html_url}))\n\n"
|
|
||||||
else
|
|
||||||
merge += "\n\n"
|
|
||||||
end
|
|
||||||
log += "- #{merge}"
|
|
||||||
}
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:issues]
|
if @options[:issues]
|
||||||
|
|
20
lib/github_changelog_generator/generator.rb
Normal file
20
lib/github_changelog_generator/generator.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
module GitHubChangelogGenerator
|
||||||
|
class Generator
|
||||||
|
|
||||||
|
def initialize(options)
|
||||||
|
@options = options
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_string_for_pull_request(pull_request)
|
||||||
|
trimmed_title = pull_request[:title].gsub '>', '/>'
|
||||||
|
merge = "#{@options[:merge_prefix]}#{trimmed_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
||||||
|
if @options[:author]
|
||||||
|
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
||||||
|
else
|
||||||
|
merge += "\n\n"
|
||||||
|
end
|
||||||
|
merge
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user