Class: Packwerk::Formatters::ProgressFormatter
- Inherits:
-
Object
- Object
- Packwerk::Formatters::ProgressFormatter
- Defined in:
- lib/packwerk/formatters/progress_formatter.rb
Instance Method Summary collapse
- #increment_progress(failed = false) ⇒ Object
-
#initialize(out, style: OutputStyles::Plain.new) ⇒ ProgressFormatter
constructor
A new instance of ProgressFormatter.
- #interrupted ⇒ Object
- #mark_as_failed ⇒ Object
- #mark_as_inspected ⇒ Object
- #started_inspection(target_files, &block) ⇒ Object
- #started_validation(&block) ⇒ Object
Constructor Details
#initialize(out, style: OutputStyles::Plain.new) ⇒ ProgressFormatter
Returns a new instance of ProgressFormatter.
10 11 12 13 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 10 def initialize(out, style: OutputStyles::Plain.new) @out = out @style = style end |
Instance Method Details
#increment_progress(failed = false) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 32 def increment_progress(failed = false) if failed mark_as_failed else mark_as_inspected end end |
#interrupted ⇒ Object
51 52 53 54 55 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 51 def interrupted @out.puts @out.puts("Manually interrupted. Violations caught so far are listed below:") @out.puts end |
#mark_as_failed ⇒ Object
46 47 48 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 46 def mark_as_failed @out.print("#{@style.error}E#{@style.reset}") end |
#mark_as_inspected ⇒ Object
41 42 43 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 41 def mark_as_inspected @out.print(".") end |
#started_inspection(target_files, &block) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 24 def started_inspection(target_files, &block) start_inspection(target_files) execution_time = Benchmark.realtime(&block) finished(execution_time) end |
#started_validation(&block) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/packwerk/formatters/progress_formatter.rb', line 16 def started_validation(&block) start_validation execution_time = Benchmark.realtime(&block) finished(execution_time) end |