Class: Specification
- Inherits:
-
BaseDocument
- Object
- BaseDocument
- Specification
- Defined in:
- lib/almirah/doc_types/specification.rb
Instance Attribute Summary collapse
-
#controlled_items ⇒ Object
Returns the value of attribute controlled_items.
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
-
#duplicated_ids_number ⇒ Object
Returns the value of attribute duplicated_ids_number.
-
#duplicates_list ⇒ Object
Returns the value of attribute duplicates_list.
-
#items_with_coverage_number ⇒ Object
Returns the value of attribute items_with_coverage_number.
-
#items_with_downlinks_number ⇒ Object
Returns the value of attribute items_with_downlinks_number.
-
#items_with_uplinks_number ⇒ Object
Returns the value of attribute items_with_uplinks_number.
-
#last_used_id ⇒ Object
Returns the value of attribute last_used_id.
-
#last_used_id_number ⇒ Object
Returns the value of attribute last_used_id_number.
-
#todo_blocks ⇒ Object
Returns the value of attribute todo_blocks.
-
#up_link_doc_id ⇒ Object
Returns the value of attribute up_link_doc_id.
Attributes inherited from BaseDocument
#headings, #id, #items, #path, #title
Instance Method Summary collapse
- #adjust_internal_links(line, specifications) ⇒ Object
-
#initialize(fele_path) ⇒ Specification
constructor
A new instance of Specification.
- #to_console ⇒ Object
- #to_html(nav_pane, output_file_path) ⇒ Object
Methods inherited from BaseDocument
Constructor Details
#initialize(fele_path) ⇒ Specification
Returns a new instance of Specification.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/almirah/doc_types/specification.rb', line 18 def initialize(fele_path) @path = fele_path @title = "" @items = Array.new @headings = Array.new @controlled_items = Array.new @dictionary = Hash.new @duplicates_list = Array.new @todo_blocks = Array.new @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 @id = File.basename(fele_path, File.extname(fele_path)).downcase @up_link_doc_id = Hash.new end |
Instance Attribute Details
#controlled_items ⇒ Object
Returns the value of attribute controlled_items.
7 8 9 |
# File 'lib/almirah/doc_types/specification.rb', line 7 def controlled_items @controlled_items end |
#dictionary ⇒ Object
Returns the value of attribute dictionary.
6 7 8 |
# File 'lib/almirah/doc_types/specification.rb', line 6 def dictionary @dictionary end |
#duplicated_ids_number ⇒ Object
Returns the value of attribute duplicated_ids_number.
13 14 15 |
# File 'lib/almirah/doc_types/specification.rb', line 13 def duplicated_ids_number @duplicated_ids_number end |
#duplicates_list ⇒ Object
Returns the value of attribute duplicates_list.
14 15 16 |
# File 'lib/almirah/doc_types/specification.rb', line 14 def duplicates_list @duplicates_list end |
#items_with_coverage_number ⇒ Object
Returns the value of attribute items_with_coverage_number.
12 13 14 |
# File 'lib/almirah/doc_types/specification.rb', line 12 def items_with_coverage_number @items_with_coverage_number end |
#items_with_downlinks_number ⇒ Object
Returns the value of attribute items_with_downlinks_number.
11 12 13 |
# File 'lib/almirah/doc_types/specification.rb', line 11 def items_with_downlinks_number @items_with_downlinks_number end |
#items_with_uplinks_number ⇒ Object
Returns the value of attribute items_with_uplinks_number.
10 11 12 |
# File 'lib/almirah/doc_types/specification.rb', line 10 def items_with_uplinks_number @items_with_uplinks_number end |
#last_used_id ⇒ Object
Returns the value of attribute last_used_id.
15 16 17 |
# File 'lib/almirah/doc_types/specification.rb', line 15 def last_used_id @last_used_id end |
#last_used_id_number ⇒ Object
Returns the value of attribute last_used_id_number.
16 17 18 |
# File 'lib/almirah/doc_types/specification.rb', line 16 def last_used_id_number @last_used_id_number end |
#todo_blocks ⇒ Object
Returns the value of attribute todo_blocks.
8 9 10 |
# File 'lib/almirah/doc_types/specification.rb', line 8 def todo_blocks @todo_blocks end |
#up_link_doc_id ⇒ Object
Returns the value of attribute up_link_doc_id.
5 6 7 |
# File 'lib/almirah/doc_types/specification.rb', line 5 def up_link_doc_id @up_link_doc_id end |
Instance Method Details
#adjust_internal_links(line, specifications) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/almirah/doc_types/specification.rb', line 82 def adjust_internal_links(line, specifications) # check if there are internal links to md files and replace them if tmp = /<a\shref="(.*)"\sclass="external">.*<\/a>/.match(line) if res = /(\w*)[.]md/.match(tmp[1]) id = res[1].downcase res = /(\w*)[.]md(#.*)/.match(tmp[1]) specifications.each do |spec| if spec.id.downcase == id if res && res.length > 2 anchor = res[2] line.sub!(/<a\shref="(.*)"\sclass="external">/, "<a href=\".\\..\\#{id}\\#{id}.html#{anchor}\" class=\"external\">") else line.sub!(/<a\shref="(.*)"\sclass="external">/, "<a href=\".\\..\\#{id}\\#{id}.html\" class=\"external\">") end break end end end end return line end |
#to_console ⇒ Object
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 |
# File 'lib/almirah/doc_types/specification.rb', line 40 def to_console puts "" puts "\e[33m" + "Specification: " + @title + "\e[0m" puts "-" * 53 puts "| Number of Controlled Items | %10d |" % @controlled_items.length puts "| Number of Items w/ Up-links | %10d |" % @items_with_uplinks_number puts "| Number of Items w/ Down-links | %10d |" % @items_with_downlinks_number # coverage if (@controlled_items.length > 0) && (@controlled_items.length == @items_with_coverage_number) puts "| Number of Items w/ Test Coverage |\e[1m\e[32m %10d \e[0m|" % @items_with_coverage_number else puts "| Number of Items w/ Test Coverage | %10d |" % @items_with_coverage_number end # duplicates if @duplicated_ids_number >0 puts "| Duplicated Item Ids found |\e[1m\e[31m %10d \e[0m|" % @duplicated_ids_number else puts "| Duplicated Item Ids found | %10d |" % @duplicated_ids_number end puts "| 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/almirah/doc_types/specification.rb', line 66 def to_html(nav_pane, output_file_path) html_rows = Array.new html_rows.append('') @items.each do |item| a = item.to_html #a = adjust_internal_links(a, nav_pane.specifications) html_rows.append a end self.save_html_to_file(html_rows, nav_pane, output_file_path) end |