Class: GitHubChangelogGenerator::Section
- Inherits:
-
Object
- Object
- GitHubChangelogGenerator::Section
- Defined in:
- lib/github_changelog_generator/generator/section.rb
Overview
This class generates the content for a single section of a changelog entry. It turns the tagged issues and PRs into a well-formatted list of changes to be later incorporated into a changelog entry.
Instance Attribute Summary collapse
- #body_only ⇒ Boolean readonly
- #issues ⇒ Array<Hash> readonly
- #labels ⇒ Array<String> readonly
- #name ⇒ String
- #options ⇒ Options readonly
-
#prefix ⇒ String
readonly
A merge prefix, or an issue prefix.
Instance Method Summary collapse
-
#generate_content ⇒ String
Returns the content of a section.
-
#initialize(opts = {}) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(opts = {}) ⇒ Section
Returns a new instance of Section.
28 29 30 31 32 33 34 35 36 |
# File 'lib/github_changelog_generator/generator/section.rb', line 28 def initialize(opts = {}) @name = opts[:name] @prefix = opts[:prefix] @labels = opts[:labels] || [] @issues = opts[:issues] || [] @options = opts[:options] || Options.new({}) @body_only = opts[:body_only] || false @entry = Entry.new() end |
Instance Attribute Details
#body_only ⇒ Boolean (readonly)
23 24 25 |
# File 'lib/github_changelog_generator/generator/section.rb', line 23 def body_only @body_only end |
#issues ⇒ Array<Hash> (readonly)
17 18 19 |
# File 'lib/github_changelog_generator/generator/section.rb', line 17 def issues @issues end |
#labels ⇒ Array<String> (readonly)
20 21 22 |
# File 'lib/github_changelog_generator/generator/section.rb', line 20 def labels @labels end |
#name ⇒ String
11 12 13 |
# File 'lib/github_changelog_generator/generator/section.rb', line 11 def name @name end |
#options ⇒ Options (readonly)
26 27 28 |
# File 'lib/github_changelog_generator/generator/section.rb', line 26 def @options end |
#prefix ⇒ String (readonly)
Returns a merge prefix, or an issue prefix.
14 15 16 |
# File 'lib/github_changelog_generator/generator/section.rb', line 14 def prefix @prefix end |
Instance Method Details
#generate_content ⇒ String
Returns the content of a section.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/github_changelog_generator/generator/section.rb', line 41 def generate_content content = "" if @issues.any? content += "#{@prefix}\n\n" unless @options[:simple_list] || @prefix.blank? @issues.each do |issue| merge_string = get_string_for_issue(issue) content += "- " unless @body_only content += "#{merge_string}\n" end content += "\n" end content end |