Class: Decision
- Inherits:
-
PersistentDocument
- Object
- BaseDocument
- PersistentDocument
- Decision
- Defined in:
- lib/almirah/doc_types/decision.rb
Overview
rubocop:disable Style/Documentation,Metrics/ClassLength
Instance Attribute Summary collapse
-
#current_status ⇒ Object
Returns the value of attribute current_status.
-
#html_rel_path ⇒ Object
Returns the value of attribute html_rel_path.
-
#path ⇒ Object
Returns the value of attribute path.
-
#record_type ⇒ Object
Returns the value of attribute record_type.
-
#root_prefix ⇒ Object
Returns the value of attribute root_prefix.
-
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
-
#specifications_path ⇒ Object
Returns the value of attribute specifications_path.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#target_release_version ⇒ Object
Returns the value of attribute target_release_version.
-
#wrong_links_hash ⇒ Object
Returns the value of attribute wrong_links_hash.
Attributes inherited from PersistentDocument
#controlled_items, #frontmatter, #headings, #items, #up_link_docs
Attributes inherited from BaseDocument
Instance Method Summary collapse
-
#effective_status_on(date) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity.
- #extract_current_status ⇒ Object
- #extract_start_date ⇒ Object
- #extract_target_release_version ⇒ Object
-
#initialize(file_path) ⇒ Decision
constructor
A new instance of Decision.
- #to_console ⇒ Object
- #to_html(nav_pane, output_file_path) ⇒ Object
Methods inherited from BaseDocument
#decisions_link, #index_link, #save_html_to_file
Constructor Details
#initialize(file_path) ⇒ Decision
Returns a new instance of Decision.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/almirah/doc_types/decision.rb', line 12 def initialize(file_path) super @path = file_path stem = File.basename(file_path, File.extname(file_path)) assign_id_parts(stem) @current_status = nil @start_date = nil @target_release_version = nil @wrong_links_hash = {} end |
Instance Attribute Details
#current_status ⇒ Object
Returns the value of attribute current_status.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def current_status @current_status end |
#html_rel_path ⇒ Object
Returns the value of attribute html_rel_path.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def html_rel_path @html_rel_path end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def path @path end |
#record_type ⇒ Object
Returns the value of attribute record_type.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def record_type @record_type end |
#root_prefix ⇒ Object
Returns the value of attribute root_prefix.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def root_prefix @root_prefix end |
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def sequence_number @sequence_number end |
#specifications_path ⇒ Object
Returns the value of attribute specifications_path.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def specifications_path @specifications_path end |
#start_date ⇒ Object
Returns the value of attribute start_date.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def start_date @start_date end |
#target_release_version ⇒ Object
Returns the value of attribute target_release_version.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def target_release_version @target_release_version end |
#wrong_links_hash ⇒ Object
Returns the value of attribute wrong_links_hash.
9 10 11 |
# File 'lib/almirah/doc_types/decision.rb', line 9 def wrong_links_hash @wrong_links_hash end |
Instance Method Details
#effective_status_on(date) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/almirah/doc_types/decision.rb', line 61 def effective_status_on(date) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity table = find_section_table('Status') return nil if table.nil? date_idx = column_index(table, 'Date') status_idx = column_index(table, 'Status') return nil if date_idx.nil? || status_idx.nil? best_idx = nil best_date = nil table.rows.each_with_index do |row, i| parsed = parse_dd_mm_yyyy(row[date_idx]) next if parsed.nil? || parsed > date if best_date.nil? || parsed > best_date || (parsed == best_date && i > best_idx) best_date = parsed best_idx = i end end return nil if best_idx.nil? status = table.rows[best_idx][status_idx].to_s.strip status.empty? ? nil : status end |
#extract_current_status ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/almirah/doc_types/decision.rb', line 38 def extract_current_status status_table = find_section_table('Status') return if status_table.nil? status_table.is_decision_status_table = true marker_rows = status_table.rows.select { |row| row[0].to_s.strip == '*' } @current_status = marker_rows.length == 1 ? marker_rows[0][-1].to_s.strip : nil end |
#extract_start_date ⇒ Object
47 48 49 50 |
# File 'lib/almirah/doc_types/decision.rb', line 47 def extract_start_date dates = collect_dates('Status', 'Date') + collect_dates('Scope', 'Start Date') @start_date = dates.min end |
#extract_target_release_version ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/almirah/doc_types/decision.rb', line 52 def extract_target_release_version @target_release_version = lookup_cell( section_name: 'Software Versions', key_column: 'Software Version Category', value_column: 'Software Version ID', key: 'Target Release Version' ) end |
#to_console ⇒ Object
23 24 25 |
# File 'lib/almirah/doc_types/decision.rb', line 23 def to_console puts "\e[36mDecision: #{@id}\e[0m" end |
#to_html(nav_pane, output_file_path) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/almirah/doc_types/decision.rb', line 27 def to_html(nav_pane, output_file_path) html_rows = [] html_rows.append('') @items.each do |item| html_rows.append item.to_html end save_html_to_file(html_rows, nav_pane, output_file_path) end |