Class: ArrayFormatter
Instance Method Summary
collapse
#deinit, #init, #trim, #w
Constructor Details
Returns a new instance of ArrayFormatter.
6
7
8
9
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 6
def initialize(report)
super(report)
@data = {}
end
|
Instance Method Details
#build_data ⇒ Object
17
18
19
20
21
22
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 17
def build_data
build_initial_data
build_history_data
build_final_data
build_hof_data
end
|
#build_final_data ⇒ Object
70
71
72
73
74
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 70
def build_final_data
tail = {}
@tail.each { |key, value| tail[key] = value }
@data[:results] = tail
end
|
#build_history_data ⇒ Object
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
67
68
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 30
def build_history_data
@data[:logs] = []
groups = []
title = nil
targets = []
@lines.each do |i|
unless i.instance_of? Hash
@data[:logs] << i.to_s next
end
value = 0.0
value = i[:weight] if i[:check]
if i[:groupname] != title
groups << {title: title, targets: targets} unless title.nil?
title = i[:groupname]
targets = []
end
target = {}
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
end
groups << {title: title, targets: targets} unless title.nil?
@data[:groups] = groups
end
|
#build_hof_data ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 76
def build_hof_data
app = Application.instance
@data[:hall_of_fame] = {}
return if app.options[: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
24
25
26
27
28
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 24
def build_initial_data
head = {}
@head.each { |key, value| head[key] = value }
@data[:config] = head
end
|
#process ⇒ Object
11
12
13
14
15
|
# File 'lib/teuton/report/formatter/array_formatter.rb', line 11
def process
build_data
w @data.to_s deinit
end
|