Class: DecisionsOverview

Inherits:
BaseDocument show all
Defined in:
lib/almirah/doc_types/decisions_overview.rb

Overview

rubocop:disable Style/Documentation,Metrics/ClassLength

Instance Attribute Summary collapse

Attributes inherited from BaseDocument

#dom, #headings, #id, #title

Instance Method Summary collapse

Methods inherited from BaseDocument

#decisions_link, #index_link, #save_html_to_file

Constructor Details

#initialize(project) ⇒ DecisionsOverview

Returns a new instance of DecisionsOverview.



10
11
12
13
14
15
# File 'lib/almirah/doc_types/decisions_overview.rb', line 10

def initialize(project)
  super()
  @project = project
  @title = 'Decision Records Overview'
  @id = 'overview'
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



8
9
10
# File 'lib/almirah/doc_types/decisions_overview.rb', line 8

def project
  @project
end

Instance Method Details

#to_consoleObject



17
18
19
# File 'lib/almirah/doc_types/decisions_overview.rb', line 17

def to_console
  puts "\e[36mDecisions Overview: #{@id}\e[0m"
end

#to_html(output_file_path) ⇒ Object

rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/almirah/doc_types/decisions_overview.rb', line 21

def to_html(output_file_path) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
  html_rows = []
  html_rows.append('')
  html_rows.append "<h1>#{@title}</h1>\n"

  html_rows.append render_charts_grid

  html_rows.append "<table class=\"controlled decisions_overview\">\n"
  html_rows.append "\t<thead>\n"
  html_rows.append "\t\t<th>#</th>\n"
  html_rows.append "\t\t<th>Type</th>\n"
  html_rows.append "\t\t<th>Status</th>\n"
  html_rows.append "\t\t<th>Title</th>\n"
  html_rows.append "\t\t<th>Start Date</th>\n"
  html_rows.append "\t\t<th>Target Date</th>\n"
  html_rows.append "\t\t<th title=\"Target Release Version\">Release</th>\n"
  html_rows.append "\t\t<th>Owner</th>\n"
  html_rows.append "</thead>\n"

  sorted_items = @project.project_data.decisions.sort_by do |d|
    [d.sequence_number ? 0 : 1, d.sequence_number.to_i, d.id]
  end
  sorted_items.each do |doc|
    s = "\t<tr>\n"
    s += "\t\t<td class=\"item_id\">\n"
    label = doc.sequence_number || doc.id
    href = doc.html_rel_path ? "./#{doc.html_rel_path}" : "##{doc.id}"
    anchor_attrs = %(name="#{doc.id}" id="#{doc.id}" href="#{href}" title="Decision Record ID")
    s += "\t\t\t<a #{anchor_attrs}>#{label}</a>"
    s += "\t\t</td>\n"
    s += "\t\t<td class=\"item_type\">#{doc.record_type}</td>\n"
    s += "\t\t<td class=\"item_status\">#{doc.current_status}</td>\n"
    title_html = doc.html_rel_path ? %(<a href="./#{doc.html_rel_path}" class="external">#{doc.title}</a>) : doc.title
    s += "\t\t<td class=\"item_text\" style='padding: 5px;'>#{title_html}</td>\n"
    start_date_html = doc.start_date ? doc.start_date.strftime('%d-%m-%Y') : ''
    s += "\t\t<td class=\"item_meta\">#{start_date_html}</td>\n"
    s += "\t\t<td class=\"item_meta\"></td>\n"
    s += "\t\t<td class=\"item_meta\">#{doc.target_release_version}</td>\n"
    s += "\t\t<td class=\"item_meta\"></td>\n"
    s += "</tr>\n"
    html_rows.append s
  end
  html_rows.append "</table>\n"

  save_html_to_file(html_rows, nil, output_file_path)
end