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, separate_nodes: true, short_sha: true }
- RISKY =
'RISKY/BREAKING (details below):'- NO_RISKY =
'NO RISKY/BREAKING COMMITS. READ FULL CHANGELOG.'- NON_NODES_ONLY =
'Non-risky/major, Non-node-only commits'- NODES_ONLY =
'Commits impacting only nodes'- 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
- #markdown_priority_nodes ⇒ Object
- #raw ⇒ Object
- #raw_priority ⇒ Object
Constructor Details
#initialize(git, opts = {}) ⇒ Changelog
Returns a new instance of Changelog.
18 19 20 21 |
# File 'lib/cookbook-release/changelog.rb', line 18 def initialize(git, opts = {}) @git = git @opts = DEFAULT_OPTS.merge(opts) end |
Instance Method Details
#html ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cookbook-release/changelog.rb', line 39 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[:separate_nodes] && c.nodes_only? 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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cookbook-release/changelog.rb', line 59 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
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cookbook-release/changelog.rb', line 84 def markdown changelog.map do |c| full_body ||= @opts[:expand_major] && c.major? full_body ||= @opts[:expand_risky] && c.risky? full_body ||= @opts[:separate_nodes] && c.nodes_only? full_body ||= @opts[:expand_commit] && (c[:subject] =~ @opts[:expand_commit] || c[:body] =~ @opts[:expand_commit]) 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
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cookbook-release/changelog.rb', line 95 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 |
#markdown_priority_nodes ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/cookbook-release/changelog.rb', line 112 def markdown_priority_nodes result = [] result << append_risky(changelog) result << append_by_impact(changelog) result << append_risky_details(changelog) result end |
#raw ⇒ Object
23 24 25 |
# File 'lib/cookbook-release/changelog.rb', line 23 def raw changelog.map(&:to_s_oneline) end |
#raw_priority ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cookbook-release/changelog.rb', line 27 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 |