Class: Cyrun::SpecGroupExecutionResult

Inherits:
Object
  • Object
show all
Defined in:
lib/cyrun/spec_group_execution_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(single_results, screenshots, gross_time_in_seconds) ⇒ SpecGroupExecutionResult

Returns a new instance of SpecGroupExecutionResult.



11
12
13
14
15
# File 'lib/cyrun/spec_group_execution_result.rb', line 11

def initialize(single_results, screenshots, gross_time_in_seconds)
  @single_results = single_results
  @gross_time_in_seconds = gross_time_in_seconds
  @screenshots = screenshots
end

Instance Attribute Details

#gross_time_in_secondsObject (readonly)

Returns the value of attribute gross_time_in_seconds.



5
6
7
# File 'lib/cyrun/spec_group_execution_result.rb', line 5

def gross_time_in_seconds
  @gross_time_in_seconds
end

#screenshotsObject (readonly)

Returns the value of attribute screenshots.



5
6
7
# File 'lib/cyrun/spec_group_execution_result.rb', line 5

def screenshots
  @screenshots
end

#single_resultsObject (readonly)

Returns the value of attribute single_results.



5
6
7
# File 'lib/cyrun/spec_group_execution_result.rb', line 5

def single_results
  @single_results
end

Class Method Details

.create_emptyObject



7
8
9
# File 'lib/cyrun/spec_group_execution_result.rb', line 7

def self.create_empty
  SpecGroupExecutionResult.new([], [], 0)
end

Instance Method Details

#clear_screenshot_list!Object



56
57
58
# File 'lib/cyrun/spec_group_execution_result.rb', line 56

def clear_screenshot_list!
  @screenshots = []
end

#effectivenessObject



21
22
23
24
25
# File 'lib/cyrun/spec_group_execution_result.rb', line 21

def effectiveness
  return 0.0 if gross_time_in_seconds.zero?

  net_time_in_seconds.to_f / gross_time_in_seconds
end

#latest_resultsObject



48
49
50
51
52
53
54
# File 'lib/cyrun/spec_group_execution_result.rb', line 48

def latest_results
  tasks = single_results.map(&:task).uniq

  tasks.map do |task|
    task_results(task).last
  end
end

#merge!(other) ⇒ Object



27
28
29
30
31
# File 'lib/cyrun/spec_group_execution_result.rb', line 27

def merge!(other)
  @single_results += other.single_results
  @gross_time_in_seconds += other.gross_time_in_seconds
  @screenshots += other.screenshots
end

#net_time_in_secondsObject



17
18
19
# File 'lib/cyrun/spec_group_execution_result.rb', line 17

def net_time_in_seconds
  single_results.map(&:net_time_in_seconds).sum
end

#task_fail_count(task) ⇒ Object



33
34
35
36
37
# File 'lib/cyrun/spec_group_execution_result.rb', line 33

def task_fail_count(task)
  single_results
    .select { |result| !result.success && result.task == task }
    .size
end

#task_result_count(task) ⇒ Object



39
40
41
# File 'lib/cyrun/spec_group_execution_result.rb', line 39

def task_result_count(task)
  task_results(task).size
end

#task_results(task) ⇒ Object



43
44
45
46
# File 'lib/cyrun/spec_group_execution_result.rb', line 43

def task_results(task)
  single_results
    .select { |result| result.task == task }
end