Class: Knapsack::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack/presenter.rb

Class Method Summary collapse

Class Method Details

.exceeded_time ⇒ Object



31
32
33
# File 'lib/knapsack/presenter.rb', line 31

def exceeded_time
  "Exceeded time: #{Knapsack.tracker.exceeded_time}s"
end

.global_time ⇒ Object



19
20
21
# File 'lib/knapsack/presenter.rb', line 19

def global_time
  "\nKnapsack global time execution for specs: #{Knapsack.tracker.global_time}s"
end

.max_allowed_node_time_execution ⇒ Object



27
28
29
# File 'lib/knapsack/presenter.rb', line 27

def max_allowed_node_time_execution
  "Max allowed node time execution: #{Knapsack.tracker.max_node_time_execution}s"
end

.report_details ⇒ Object



15
16
17
# File 'lib/knapsack/presenter.rb', line 15

def report_details
  "Knapsack report was generated. Preview:\n" + Presenter.report_json
end

.report_json ⇒ Object



11
12
13
# File 'lib/knapsack/presenter.rb', line 11

def report_json
  JSON.pretty_generate(Knapsack.tracker.spec_files_with_time)
end

.report_yml ⇒ Object



7
8
9
# File 'lib/knapsack/presenter.rb', line 7

def report_yml
  Knapsack.tracker.spec_files_with_time.to_yaml
end

.time_offset ⇒ Object



23
24
25
# File 'lib/knapsack/presenter.rb', line 23

def time_offset
  "Time offset: #{Knapsack.tracker.config[:time_offset_in_seconds]}s"
end

.time_offset_warning ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/knapsack/presenter.rb', line 35

def time_offset_warning
  str = %{\n========= Knapsack Time Offset Warning ==========
#{Presenter.time_offset}
#{Presenter.max_allowed_node_time_execution}
#{Presenter.exceeded_time}
  }
  if Knapsack.tracker.time_exceeded?
    str << %{
Specs on this CI node took more than time offset.
Please regenerate your knapsack report.
If that didn't help then split your heavy test file
or bump time_offset_in_seconds setting.}
  else
    str << %{
Global time execution for this CI node is fine.
Happy testing!}
  end
  str << "\n=================================================\n"
  str
end