Class: GoldenRose::ExecutionDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/golden_rose/execution_details.rb

Instance Method Summary collapse

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_countObject



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_timeObject



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_nameObject



36
37
38
# File 'lib/golden_rose/execution_details.rb', line 36

def model_name
  @parsed_plist["RunDestination"]["TargetDevice"]["ModelName"]
end

#nameObject



8
9
10
# File 'lib/golden_rose/execution_details.rb', line 8

def name
  @parsed_plist["TestableSummaries"].first['TestName']
end

#os_versionObject



40
41
42
# File 'lib/golden_rose/execution_details.rb', line 40

def os_version
  @parsed_plist["RunDestination"]["TargetDevice"]["OperatingSystemVersion"]
end

#passing_countObject



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_countObject



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_timeObject



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