Class: CookbookRelease::Changelog

Inherits:
Object
  • Object
show all
Defined in:
lib/cookbook-release/changelog.rb

Constant Summary collapse

DEFAULT_OPTS =
{
  expand_major: true,
  expand_risky: true,
  short_sha: true
}

Instance Method Summary collapse

Constructor Details

#initialize(git, opts = {}) ⇒ Changelog

Returns a new instance of Changelog.



10
11
12
13
# File 'lib/cookbook-release/changelog.rb', line 10

def initialize(git, opts = {})
  @git = git
  @opts = DEFAULT_OPTS.merge(opts)
end

Instance Method Details

#htmlObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cookbook-release/changelog.rb', line 19

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

#markdownObject



38
39
40
41
42
43
44
45
# File 'lib/cookbook-release/changelog.rb', line 38

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

#rawObject



15
16
17
# File 'lib/cookbook-release/changelog.rb', line 15

def raw
  changelog.map(&:to_s_oneline)
end