Class: GoldenRose::ExecutionDetails
- Inherits:
-
Object
- Object
- GoldenRose::ExecutionDetails
- Defined in:
- lib/golden_rose/execution_details.rb
Instance Method Summary collapse
- #failures_count ⇒ Object
- #formatted_time ⇒ Object
-
#initialize(parsed_plist, items) ⇒ ExecutionDetails
constructor
A new instance of ExecutionDetails.
- #model_name ⇒ Object
- #name ⇒ Object
- #os_version ⇒ Object
- #passing_count ⇒ Object
- #pluralized(number, noun) ⇒ Object
- #total_tests_count ⇒ Object
- #total_time ⇒ Object
Constructor Details
#initialize(parsed_plist, items) ⇒ ExecutionDetails
Returns a new instance of ExecutionDetails.
3 4 5 6 |
# File 'lib/golden_rose/execution_details.rb', line 3 def initialize(parsed_plist, items) @parsed_plist = parsed_plist @items = items end |
Instance Method Details
#failures_count ⇒ Object
24 25 26 |
# File 'lib/golden_rose/execution_details.rb', line 24 def failures_count @items.reduce(0) { |count, item| count + item[:failures_count].to_i } end |
#formatted_time ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/golden_rose/execution_details.rb', line 12 def formatted_time hours = total_time / (60 * 60) minutes = (total_time / 60) % 60 seconds = total_time % 60 "".tap do |time| time << "#{pluralized(hours, 'hour')}, " if hours > 0 time << "#{pluralized(minutes, 'minute')} and " if minutes > 0 time << "#{pluralized(seconds, 'second')}" end end |
#model_name ⇒ Object
36 37 38 |
# File 'lib/golden_rose/execution_details.rb', line 36 def model_name @parsed_plist["RunDestination"]["TargetDevice"]["ModelName"] end |
#name ⇒ Object
8 9 10 |
# File 'lib/golden_rose/execution_details.rb', line 8 def name @parsed_plist["TestableSummaries"].first['TestName'] end |
#os_version ⇒ Object
40 41 42 |
# File 'lib/golden_rose/execution_details.rb', line 40 def os_version @parsed_plist["RunDestination"]["TargetDevice"]["OperatingSystemVersion"] end |
#passing_count ⇒ Object
32 33 34 |
# File 'lib/golden_rose/execution_details.rb', line 32 def passing_count total_tests_count - failures_count end |
#pluralized(number, noun) ⇒ Object
53 54 55 |
# File 'lib/golden_rose/execution_details.rb', line 53 def pluralized(number, noun) "#{number} #{noun}#{'s' if number != 1}" end |
#total_tests_count ⇒ Object
28 29 30 |
# File 'lib/golden_rose/execution_details.rb', line 28 def total_tests_count @items.reduce(0) { |count, item| count + item[:subtests].count } end |
#total_time ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/golden_rose/execution_details.rb', line 44 def total_time @items.reduce(0) do |time, item| subtests_time = item[:subtests].reduce(0) do |time, item| time + item[:time].to_f end time + subtests_time end.round end |