Class: GitHubChangelogGenerator::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/github_changelog_generator/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ Generator

Returns a new instance of Generator.



4
5
6
# File 'lib/github_changelog_generator/generator.rb', line 4

def initialize(options = nil)
  @options = options
end

Instance Method Details

#encapsulate_string(string) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/github_changelog_generator/generator.rb', line 24

def encapsulate_string(string)

  string.gsub! '\\', '\\\\'

  encpas_chars = %w(> * _ \( \) [ ])
  encpas_chars.each{ |char|
    string.gsub! char, "\\#{char}"
  }

  string
end

#get_string_for_pull_request(pull_request) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/github_changelog_generator/generator.rb', line 8

def get_string_for_pull_request(pull_request)
  encapsulated_title = self.encapsulate_string pull_request[:title]

  merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
  if @options[:author]
    if pull_request.user.nil?
      merge += " ({Null user})\n\n"
    else
      merge += " ([#{pull_request.user.}](#{pull_request.user.html_url}))\n\n"
    end
  else
    merge += "\n\n"
  end
  merge
end