autoperf 1.1.0beta1 → 1.1.0beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/autoperf/display/console.rb +29 -27
- data/lib/autoperf/display/csv.rb +15 -13
- data/lib/autoperf/display/json.rb +20 -18
- data/lib/autoperf/version.rb +1 -1
- metadata +1 -1
@@ -1,35 +1,37 @@
|
|
1
|
-
class Autoperf
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
report
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
class Autoperf
|
2
|
+
class Display
|
3
|
+
class Console
|
4
|
+
def initialize results, report=nil
|
5
|
+
@table = if report.kind_of?(Array)
|
6
|
+
table_from_array(report)
|
7
|
+
elsif report.kind_of?(Ruport::Data::Table)
|
8
|
+
report
|
9
|
+
else
|
10
|
+
# ignore input and use defaults
|
11
|
+
table_from_array(::Autoperf::Display::DEFAULT_FIELDS)
|
12
|
+
end
|
13
|
+
results.each do |rate, result|
|
14
|
+
result.merge!(:rate => rate) if @table.column_names.include?(:rate)
|
15
|
+
@table << result
|
16
|
+
end
|
17
|
+
@table
|
15
18
|
end
|
16
|
-
@table
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def table
|
21
|
+
@table
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def to_s
|
25
|
+
@table.to_s
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def print
|
29
|
+
puts to_s
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
def table_from_array report
|
33
|
+
Table(:column_names => report)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
data/lib/autoperf/display/csv.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
class Autoperf
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Autoperf
|
2
|
+
class Display
|
3
|
+
class CSV
|
4
|
+
def initialize results, report=nil
|
5
|
+
@table = ::Autoperf::Display::Console.new(results, report).table
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def to_s
|
9
|
+
@table.to_csv
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def to_csv
|
13
|
+
to_s
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def print
|
17
|
+
puts to_s
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,25 +1,27 @@
|
|
1
|
-
class Autoperf
|
2
|
-
class
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
class Autoperf
|
2
|
+
class Display
|
3
|
+
class JSON
|
4
|
+
def initialize(results, fields=nil)
|
5
|
+
@results = []
|
6
|
+
fields ||= ::Autoperf::Display::DEFAULT_FIELDS
|
7
|
+
results.each do |rate, result|
|
8
|
+
result.keep_if { |k,v| fields.include?(k) }
|
9
|
+
result.merge!(:rate => rate) if fields.include?(:rate)
|
10
|
+
@results.push(result)
|
11
|
+
end
|
10
12
|
end
|
11
|
-
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def to_s
|
15
|
+
to_json
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def to_json
|
19
|
+
@results.to_json
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
def print
|
23
|
+
puts ::JSON.pretty_generate(@results)
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/autoperf/version.rb
CHANGED