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

Html, Markdown, PlainText

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



6
7
# File 'lib/renogen/formatters/base.rb', line 6

def initialize(options={})
end

Class Method Details

.register(identifier) ⇒ Object

Adds class with identifier to formatters

Parameters:

  • identifier (String)


12
13
14
# File 'lib/renogen/formatters/base.rb', line 12

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:



21
22
23
# File 'lib/renogen/formatters/base.rb', line 21

def header(changelog)
  "#{changelog.version} (#{changelog.date})"
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



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

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)


65
66
# File 'lib/renogen/formatters/base.rb', line 65

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



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

def write_group(group)
  raise NotImplementedError
end

#write_group_endnil

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

Returns:

  • (nil)


48
49
# File 'lib/renogen/formatters/base.rb', line 48

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



31
32
33
# File 'lib/renogen/formatters/base.rb', line 31

def write_header(header)
  raise NotImplementedError
end