Class: Schmersion::Formatters::Markdown
Instance Attribute Summary
#filename
Instance Method Summary
collapse
#initialize
Instance Method Details
#generate(repo, version) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/schmersion/formatters/markdown.rb', line 9
def generate(repo, version)
lines = []
lines << "## #{version.version}\n"
sections_for_commits(version.commits).each do |section, commits|
lines << "### #{section['title']}\n"
commits.each do |_, scope_commits|
scope_commits.sort_by { |c| c.message.description.upcase }.each do |commit|
lines << commit_line(repo, commit)
end
end
lines << nil
end
lines.join("\n")
end
|
#insert(part) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/schmersion/formatters/markdown.rb', line 25
def insert(part)
text_to_insert = "#{}\n#{part}"
unless File.file?(@filename)
File.write(@filename, text_to_insert)
return
end
contents = File.read(@filename)
= contents.sub(/\A.*?##/m, '##')
File.write(@filename, "#{text_to_insert}\n#{}")
true
end
|