Class: ArrayFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- ArrayFormatter
- Defined in:
- lib/teuton/report/formatter/array_formatter.rb
Overview
ArrayFormatter class: format report data into an array
Direct Known Subclasses
Instance Method Summary collapse
- #build_data ⇒ Object
-
#build_final_data ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
-
#build_history_data ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
- #build_hof_data ⇒ Object
- #build_initial_data ⇒ Object
-
#initialize(report) ⇒ ArrayFormatter
constructor
Initialize class.
-
#process ⇒ Object
Execute format action.
Methods inherited from BaseFormatter
Constructor Details
#initialize(report) ⇒ ArrayFormatter
Initialize class
11 12 13 14 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 11 def initialize(report) super(report) @data = {} end |
Instance Method Details
#build_data ⇒ Object
24 25 26 27 28 29 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 24 def build_data build_initial_data build_history_data build_final_data build_hof_data end |
#build_final_data ⇒ Object
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
81 82 83 84 85 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 81 def build_final_data tail = {} @tail.each { |key, value| tail[key] = value } @data[:results] = tail end |
#build_history_data ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
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 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 39 def build_history_data @data[:logs] = [] groups = [] title = nil targets = [] @lines.each do |i| if i.class.to_s == 'Hash' value = 0.0 value = i[:weight] if i[:check] if i[:groupname] != title # Add currentgroup groups << { title: title, targets: targets } unless title.nil? # Create new group title = i[:groupname] targets = [] end target = {} # target[:target_id] = format('%02d', i[:id]) target[:target_id] = format('%<id>02d', id: i[:id]) target[:check] = i[:check] target[:score] = value target[:weight] = i[:weight] target[:description] = i[:description] target[:command] = i[:command] target[:conn_type] = i[:conn_type] target[:duration] = i[:duration] target[:alterations] = i[:alterations] target[:expected] = i[:expected] target[:result] = i[:result] targets << target else @data[:logs] << i.to_s # Add log line end end groups << { title: title, targets: targets } unless title.nil? @data[:groups] = groups end |
#build_hof_data ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 87 def build_hof_data app = Application.instance @data[:hall_of_fame] = {} return if app.[:case_number] < 3 fame = {} app.hall_of_fame.each { |line| fame[line[0]] = line[1] } @data[:hall_of_fame] = fame end |
#build_initial_data ⇒ Object
31 32 33 34 35 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 31 def build_initial_data head = {} @head.each { |key, value| head[key] = value } @data[:config] = head end |
#process ⇒ Object
Execute format action
18 19 20 21 22 |
# File 'lib/teuton/report/formatter/array_formatter.rb', line 18 def process build_data w @data.to_s # Write data into ouput file deinit end |