Class: Renogen::Formatters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/renogen/formatters/base.rb

Overview

Implements a template pattern that forces the implemention of required methods in sub classes

Direct Known Subclasses

Csv, Html, Markdown, PlainText

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



10
11
12
# File 'lib/renogen/formatters/base.rb', line 10

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/renogen/formatters/base.rb', line 8

def options
  @options
end

Class Method Details

.register(identifier) ⇒ Object

Adds class with identifier to formatters

Parameters:

  • identifier (String)


24
25
26
# File 'lib/renogen/formatters/base.rb', line 24

def self.register(identifier)
  Renogen::Formatters.add(identifier.to_sym, self)
end

Instance Method Details

#header(changelog) ⇒ Object

Generate a header for a given changelog

return [String]

Parameters:



33
34
35
# File 'lib/renogen/formatters/base.rb', line 33

def header(changelog)
  "#{changelog.version} (#{changelog.date})"
end

#table_formatter?Boolean

Switch to determine if the formatter is in table format(instead of group format)

return [Boolean] (default: false)

Returns:

  • (Boolean)


17
18
19
# File 'lib/renogen/formatters/base.rb', line 17

def table_formatter?
  false # for backward compatibility
end

#write_change(change) ⇒ Object

This method is abstract.

Outputs a line or block as the body for a change.

Parameters:

  • change (String)

Raises:

  • NotImplementedError



67
68
69
# File 'lib/renogen/formatters/base.rb', line 67

def write_change(change)
  raise NotImplementedError
end

Outputs a line or block of text appearing at the bottom of the change log.

Parameters:

Returns:

  • (nil)


75
76
# File 'lib/renogen/formatters/base.rb', line 75

def write_footer(changelog)
end

#write_group(group) ⇒ Object

This method is abstract.

Outputs a line or block as a header for a group.

Parameters:

  • group (String)

Raises:

  • NotImplementedError



52
53
# File 'lib/renogen/formatters/base.rb', line 52

def write_group(group)
end

#write_group_endnil

Outputs a line or block of text appearing after a group.

Returns:

  • (nil)


58
59
# File 'lib/renogen/formatters/base.rb', line 58

def write_group_end
end

#write_header(header) ⇒ Object

This method is abstract.

Outputs a line or block of text appearing at the top of the change log.

Parameters:

  • header (String)

Raises:

  • NotImplementedError



43
44
# File 'lib/renogen/formatters/base.rb', line 43

def write_header(header)
end