Class: Renogen::ChangeLog::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/renogen/change_log/model.rb

Overview

Object to represent a Changelog/release notes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Model

Returns a new instance of Model.



10
11
12
13
14
# File 'lib/renogen/change_log/model.rb', line 10

def initialize(options={})
  @version = options[:version]
  @date = options[:date] || Date.today
  @items = []
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



8
9
10
# File 'lib/renogen/change_log/model.rb', line 8

def date
  @date
end

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/renogen/change_log/model.rb', line 7

def items
  @items
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'lib/renogen/change_log/model.rb', line 8

def version
  @version
end

Instance Method Details

#add_change(change) ⇒ Array

Adds a change to the changelog

Parameters:

Returns:

  • (Array)

    All changes

Raises:

  • (TypeError)


38
39
40
41
# File 'lib/renogen/change_log/model.rb', line 38

def add_change(change)
  raise TypeError unless change.is_a?(Renogen::ChangeLog::Item)
  items << change
end

#groupsHash<group_name: change>

Returns:

  • (Hash<group_name: change>)


17
18
19
20
21
22
23
# File 'lib/renogen/change_log/model.rb', line 17

def groups
  items.inject({}) do |hash, change|
    hash[change.group_name] ||= []
    hash[change.group_name] << change
    hash
  end
end

#ticketsHash<ticket id: string>

Returns:

  • (Hash<ticket id: string>)


26
27
28
29
30
31
32
# File 'lib/renogen/change_log/model.rb', line 26

def tickets
  items.inject({}) do |hash, change|
    hash[change.ticket_id] ||= {}
    hash[change.ticket_id][change.group_name] = change.to_s
    hash
  end
end