Class: Renogen::Formatters::MarkdownTable
- Defined in:
- lib/renogen/formatters/markdown_table.rb
Overview
For formatting a change into markdown format
Instance Attribute Summary collapse
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
Attributes inherited from Base
Instance Method Summary collapse
-
#header(changelog) ⇒ Object
Generate header.
- #table_formatter? ⇒ Boolean
-
#write_change(ticket) ⇒ String
Outputs a line or block as the body for a change in a group.
-
#write_group(group) ⇒ String
Outputs a line or block as a header for a group.
-
#write_header(header) ⇒ String
Outputs a line or block of text appearing at the top of the change log.
Methods inherited from Base
#initialize, register, #write_footer, #write_group_end
Constructor Details
This class inherits a constructor from Renogen::Formatters::Base
Instance Attribute Details
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
8 9 10 |
# File 'lib/renogen/formatters/markdown_table.rb', line 8 def headings @headings end |
Instance Method Details
#header(changelog) ⇒ Object
Generate header
return [String]
19 20 21 22 23 24 25 26 27 |
# File 'lib/renogen/formatters/markdown_table.rb', line 19 def header(changelog) @headings = changelog.groups.keys [ "# #{changelog.version} (#{changelog.date})", "", "| #{headings.join(' | ')} |", "| #{headings.map{|_| '-' }.join(' | ')} |" ].join("\n") end |
#table_formatter? ⇒ Boolean
10 11 12 |
# File 'lib/renogen/formatters/markdown_table.rb', line 10 def table_formatter? true end |
#write_change(ticket) ⇒ String
Outputs a line or block as the body for a change in a group.
49 50 51 52 53 54 55 |
# File 'lib/renogen/formatters/markdown_table.rb', line 49 def write_change(ticket) "| "+ @headings.map do |heading| value = ticket.fetch(heading, '-') value = value.join("\n") if value.is_a?(Array) value.gsub("\n", "<br>") end.join(' | ') + " |" end |
#write_group(group) ⇒ String
Outputs a line or block as a header for a group.
41 42 43 |
# File 'lib/renogen/formatters/markdown_table.rb', line 41 def write_group(group) "## #{group}\n\n" end |
#write_header(header) ⇒ String
Outputs a line or block of text appearing at the top of the change log.
33 34 35 |
# File 'lib/renogen/formatters/markdown_table.rb', line 33 def write_header(header) "#{header}\n" end |