39 lines
852 B
Ruby
Raw Normal View History

module GitHubChangelogGenerator
class Generator
2014-12-03 16:31:43 +02:00
def initialize(options = nil)
@options = options
end
2015-02-25 19:02:41 +02:00
def get_string_for_issue(issue)
encapsulated_title = self.encapsulate_string issue[:title]
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
2015-02-25 19:02:41 +02:00
unless issue.pull_request.nil?
if @options[:author]
if issue.user.nil?
title_with_number += " ({Null user})"
2015-02-25 19:02:41 +02:00
else
title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
2015-02-25 19:02:41 +02:00
end
2014-12-15 15:54:11 +02:00
end
end
title_with_number
end
2014-12-03 16:31:43 +02:00
def encapsulate_string(string)
string.gsub! '\\', '\\\\'
2015-03-03 17:33:51 +02:00
encpas_chars = %w(> * _ \( \) [ ] #)
2015-02-25 19:02:41 +02:00
encpas_chars.each { |char|
2014-12-03 16:31:43 +02:00
string.gsub! char, "\\#{char}"
}
string
end
end
2014-12-03 16:31:43 +02:00
end