Class: Lazy::Checker::Reporter
- Inherits:
-
Object
- Object
- Lazy::Checker::Reporter
- Defined in:
- lib/lazy/check/reporter.rb
Instance Attribute Summary collapse
-
#checker ⇒ Object
readonly
Returns the value of attribute checker.
Instance Method Summary collapse
- #add_failure(check_case) ⇒ Object
- #add_success(check_case) ⇒ Object
-
#display ⇒ Object
Affichage du rapport.
-
#display_list_resultats(success) ⇒ Object
Pour afficher la liste de succès ou de failures.
- #duree ⇒ Object
- #end ⇒ Object
- #formated_duree ⇒ Object
-
#initialize(checker) ⇒ Reporter
constructor
A new instance of Reporter.
- #start ⇒ Object
Constructor Details
#initialize(checker) ⇒ Reporter
Returns a new instance of Reporter.
12 13 14 |
# File 'lib/lazy/check/reporter.rb', line 12 def initialize(checker) @checker = checker end |
Instance Attribute Details
#checker ⇒ Object (readonly)
Returns the value of attribute checker.
10 11 12 |
# File 'lib/lazy/check/reporter.rb', line 10 def checker @checker end |
Instance Method Details
#add_failure(check_case) ⇒ Object
40 41 42 |
# File 'lib/lazy/check/reporter.rb', line 40 def add_failure(check_case) @failures << check_case end |
#add_success(check_case) ⇒ Object
37 38 39 |
# File 'lib/lazy/check/reporter.rb', line 37 def add_success(check_case) @successs << check_case end |
#display ⇒ Object
Affichage du rapport
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lazy/check/reporter.rb', line 19 def display clear unless debug? puts "\n\n" puts "#{checker.name}".jaune puts "-"* checker.name.length nombre_erreurs = @failures.count if true #verbose? # TODO À RÉGLER display_list_resultats(success = true) end if nombre_erreurs > 0 display_list_resultats(success = false) end color = nombre_erreurs > 0 ? :red : :vert msg = "#{MESSAGES[:Success]} #{@successs.count} #{MESSAGES[:Failures]} #{@failures.count} #{MESSAGES[:Duration]} #{formated_duree}" puts "-" * msg.length puts msg.send(color) end |
#display_list_resultats(success) ⇒ Object
Pour afficher la liste de succès ou de failures
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lazy/check/reporter.rb', line 45 def display_list_resultats(success) methode = success ? :message : :errors color = success ? :vert : :red liste = success ? @successs : @failures prefix = success ? '👍' : '👎' max_index = liste.count + 1 max_len_index = "[#{prefix} #{max_index}] ".length indent = ' ' * max_len_index liste.each_with_index do |checkedthing, idx| index_str = "[#{prefix} #{idx + 1}]".ljust(max_len_index) puts "#{index_str}#{checkedthing.send(methode).split("\n").join("\n#{indent}")}".send(color) end end |
#duree ⇒ Object
85 86 87 |
# File 'lib/lazy/check/reporter.rb', line 85 def duree @duree ||= @end_time - @start_time end |
#end ⇒ Object
72 73 74 |
# File 'lib/lazy/check/reporter.rb', line 72 def end @end_time = Time.now end |
#formated_duree ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/lazy/check/reporter.rb', line 76 def formated_duree @formated_duree ||= begin if duree < 0.10 "#{(duree.to_f * 1000).round(4)} ms" else "#{duree.round(4)} s" end end end |
#start ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/lazy/check/reporter.rb', line 60 def start unless checker.no_output? clear unless debug? puts "\n\n" puts "#{checker.name}".jaune puts MESSAGES[:PleaseWait].bleu end @start_time = Time.now @successs = [] @failures = [] end |