Class: CookbookRelease::Changelog
- Inherits:
-
Object
- Object
- CookbookRelease::Changelog
- Defined in:
- lib/cookbook-release/changelog.rb
Constant Summary collapse
- DEFAULT_OPTS =
{ expand_major: true, expand_risky: true, short_sha: true }
- RISKY =
'RISKY/BREAKING (details below):'- NO_RISKY =
'NO RISKY/BREAKING COMMITS. READ FULL CHANGELOG.'- FULL =
'Full changelog:'- DETAILS =
'Details of risky commits:'
Instance Method Summary collapse
- #html ⇒ Object
- #html_priority ⇒ Object
-
#initialize(git, opts = {}) ⇒ Changelog
constructor
A new instance of Changelog.
- #markdown ⇒ Object
- #markdown_priority ⇒ Object
- #raw ⇒ Object
- #raw_priority ⇒ Object
Constructor Details
#initialize(git, opts = {}) ⇒ Changelog
Returns a new instance of Changelog.
15 16 17 18 |
# File 'lib/cookbook-release/changelog.rb', line 15 def initialize(git, opts = {}) @git = git @opts = DEFAULT_OPTS.merge(opts) end |
Instance Method Details
#html ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cookbook-release/changelog.rb', line 36 def html result = [] result << <<-EOH <html> <body> EOH result << changelog.map do |c| full_body ||= @opts[:expand_major] && c.major? full_body ||= @opts[:expand_risky] && c.risky? full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit]) c.to_s_html(full_body) end.map { |c| " <p>#{c}</p>" } result << <<-EOH </body> </html> EOH result.join("\n") end |
#html_priority ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/cookbook-release/changelog.rb', line 55 def html_priority risky_commits = changelog.select { |c| c.risky? || c.major? } result = [] result << <<-EOH <html> <body> EOH if risky_commits.any? result << " <p>#{RISKY}</p>\n" << risky_commits.map { |c| c.to_s_html(false) }.map {|c| " <p>#{c}</p>"}.join("\n") else result << " <p>#{NO_RISKY}</p>\n\n" end result << " <p>#{FULL}</p>\n" result << changelog.map { |c| c.to_s_html(false) }.map { |c| " <p>#{c}</p>" }.join("\n") if risky_commits.any? result << "\n<p>#{DETAILS}</p>\n" result << risky_commits.map { |c| c.to_s_html(true) }.map { |c| " <p>#{c}</p>" }.join("\n") end result << <<-EOH </body> </html> EOH result.join("\n") end |
#markdown ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/cookbook-release/changelog.rb', line 80 def markdown changelog.map do |c| full_body ||= @opts[:expand_major] && c.major? full_body ||= @opts[:expand_risky] && c.risky? full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit]) c.to_s_markdown(full_body) end.join("\n") end |
#markdown_priority ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/cookbook-release/changelog.rb', line 89 def markdown_priority risky_commits = changelog.select { |c| c.risky? || c.major? } result = [] if risky_commits.any? result << "*#{RISKY}*\n" << risky_commits.map { |c| c.to_s_markdown(false) }.join("\n") << "\n" else result << "*#{NO_RISKY}*\n\n" end result << "*#{FULL}*\n" result << changelog.map { |c| c.to_s_markdown(false) }.join("\n") if risky_commits.any? result << "\n#{DETAILS}\n" result << risky_commits.map { |c| c.to_s_markdown(true) }.join("\n") end result end |
#raw ⇒ Object
20 21 22 |
# File 'lib/cookbook-release/changelog.rb', line 20 def raw changelog.map(&:to_s_oneline) end |
#raw_priority ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cookbook-release/changelog.rb', line 24 def raw_priority risky_commits = changelog.select { |c| c.risky? || c.major? } result = [] if risky_commits.any? result << "#{RISKY}\n" << risky_commits.map(&:to_s_oneline).join("\n") << "\n" else result << "#{NO_RISKY}\n\n" end result << "#{FULL}\n" result << changelog.map(&:to_s_oneline).join("\n") end |