class Nitra::Formatter
Attributes
configuration[RW]
progress[RW]
start_time[RW]
Public Class Methods
new(progress, configuration)
click to toggle source
# File lib/nitra/formatter.rb, line 8 def initialize(progress, configuration) self.progress = progress self.configuration = configuration end
Public Instance Methods
finish()
click to toggle source
# File lib/nitra/formatter.rb, line 23 def finish puts progress.filtered_output puts "\n#{overview}" puts "#{$aborted ? "Aborted after" : "Finished in"} #{"%0.1f" % (Time.now-start_time)} seconds" end
print_progress()
click to toggle source
# File lib/nitra/formatter.rb, line 18 def print_progress print_failures print_bar end
start()
click to toggle source
# File lib/nitra/formatter.rb, line 13 def start self.start_time = Time.now print_progress end
Private Instance Methods
overview()
click to toggle source
A simple overview of files processed so far and success/failure numbers.
# File lib/nitra/formatter.rb, line 55 def overview "#{progress.files_completed}/#{progress.file_count} files | #{progress.example_count} examples, #{progress.failure_count} failures" end
print_bar()
click to toggle source
Print the progress bar, doesn’t do anything if we’re in debug.
# File lib/nitra/formatter.rb, line 35 def print_bar return if configuration.quiet || configuration.debug || progress.file_count == 0 total = 50 completed = (progress.files_completed / progress.file_count.to_f * total).to_i print "\r[#{"X" * completed}#{"." * (total - completed)}] #{overview}\r" $stdout.flush end
print_failures()
click to toggle source
Prints the output in the progress object and resets it if we’ve got eager printing turned on.
# File lib/nitra/formatter.rb, line 46 def print_failures return unless progress.output.length > 0 && configuration.print_failures puts progress.filtered_output progress.output = "" end