Class: Specification

Inherits:
PersistentDocument show all
Defined in:
lib/almirah/doc_types/specification.rb

Instance Attribute Summary collapse

Attributes inherited from PersistentDocument

#controlled_items, #frontmatter, #headings, #items, #path, #up_link_docs

Attributes inherited from BaseDocument

#dom, #headings, #id, #title

Instance Method Summary collapse

Methods inherited from BaseDocument

#save_html_to_file

Constructor Details

#initialize(fele_path) ⇒ Specification

Returns a new instance of Specification.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/almirah/doc_types/specification.rb', line 10

def initialize(fele_path)
  super
  @dictionary = {}
  @duplicates_list = []
  @todo_blocks = []
  @wrong_links_hash = {}

  @items_with_uplinks_number = 0
  @items_with_downlinks_number = 0
  @items_with_coverage_number = 0
  @duplicated_ids_number = 0
  @last_used_id = ''
  @last_used_id_number = 0

  @color = 'bbb'

  @id = File.basename(fele_path, File.extname(fele_path)).downcase
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def color
  @color
end

#dictionaryObject

Returns the value of attribute dictionary.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def dictionary
  @dictionary
end

#duplicated_ids_numberObject

Returns the value of attribute duplicated_ids_number.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def duplicated_ids_number
  @duplicated_ids_number
end

#duplicates_listObject

Returns the value of attribute duplicates_list.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def duplicates_list
  @duplicates_list
end

#items_with_coverage_numberObject

Returns the value of attribute items_with_coverage_number.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def items_with_coverage_number
  @items_with_coverage_number
end

Returns the value of attribute items_with_downlinks_number.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def items_with_downlinks_number
  @items_with_downlinks_number
end

Returns the value of attribute items_with_uplinks_number.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def items_with_uplinks_number
  @items_with_uplinks_number
end

#last_used_idObject

Returns the value of attribute last_used_id.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def last_used_id
  @last_used_id
end

#last_used_id_numberObject

Returns the value of attribute last_used_id_number.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def last_used_id_number
  @last_used_id_number
end

#todo_blocksObject

Returns the value of attribute todo_blocks.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def todo_blocks
  @todo_blocks
end

Returns the value of attribute wrong_links_hash.



6
7
8
# File 'lib/almirah/doc_types/specification.rb', line 6

def wrong_links_hash
  @wrong_links_hash
end

Instance Method Details

#to_consoleObject



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
# File 'lib/almirah/doc_types/specification.rb', line 29

def to_console
  puts ''
  puts "\e[33mSpecification: #{@title}\e[0m"
  puts '-' * 53
  puts '| Number of Controlled Items           | %10d |' % @controlled_items.length
  puts format('| Number of Items w/ Up-links          | %10d |', @items_with_uplinks_number)
  puts format('| Number of Items w/ Down-links        | %10d |', @items_with_downlinks_number)

  # coverage
  if @controlled_items.length.positive? && (@controlled_items.length == @items_with_coverage_number)
    puts format("| Number of Items w/ Test Coverage     |\e[1m\e[32m %10d \e[0m|", @items_with_coverage_number)
  else
    puts format('| Number of Items w/ Test Coverage     | %10d |', @items_with_coverage_number)
  end

  # duplicates
  if @duplicated_ids_number.positive?
    puts format("| Duplicated Item Ids found            |\e[1m\e[31m %10d \e[0m|", @duplicated_ids_number)
  else
    puts format('| Duplicated Item Ids found            | %10d |', @duplicated_ids_number)
  end

  puts format("| Last used Item Id                    |\e[1m\e[37m %10s \e[0m|", @last_used_id)
  puts '-' * 53
end

#to_html(nav_pane, output_file_path) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/almirah/doc_types/specification.rb', line 55

def to_html(nav_pane, output_file_path)
  html_rows = []

  html_rows.append('')

  @items.each do |item|
    a = item.to_html
    html_rows.append a
  end

  save_html_to_file(html_rows, nav_pane, output_file_path)
end