Class: Packwerk::Formatters::ProgressFormatter

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/formatters/progress_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(out, style: OutputStyles::Plain.new) ⇒ ProgressFormatter

Returns a new instance of ProgressFormatter.



12
13
14
15
# File 'lib/packwerk/formatters/progress_formatter.rb', line 12

def initialize(out, style: OutputStyles::Plain.new)
  @out = out
  @style = style
end

Instance Method Details

#increment_progress(failed = false) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/packwerk/formatters/progress_formatter.rb', line 34

def increment_progress(failed = false)
  if failed
    mark_as_failed
  else
    mark_as_inspected
  end
end

#interruptedObject



53
54
55
56
57
# File 'lib/packwerk/formatters/progress_formatter.rb', line 53

def interrupted
  @out.puts
  @out.puts("Manually interrupted. Violations caught so far are listed below:")
  @out.puts
end

#mark_as_failedObject



48
49
50
# File 'lib/packwerk/formatters/progress_formatter.rb', line 48

def mark_as_failed
  @out.print("#{@style.error}E#{@style.reset}")
end

#mark_as_inspectedObject



43
44
45
# File 'lib/packwerk/formatters/progress_formatter.rb', line 43

def mark_as_inspected
  @out.print(".")
end

#started_inspection(target_files, &block) ⇒ Object



26
27
28
29
30
31
# File 'lib/packwerk/formatters/progress_formatter.rb', line 26

def started_inspection(target_files, &block)
  start_inspection(target_files)

  execution_time = Benchmark.realtime(&block)
  finished(execution_time)
end

#started_validation(&block) ⇒ Object



18
19
20
21
22
23
# File 'lib/packwerk/formatters/progress_formatter.rb', line 18

def started_validation(&block)
  start_validation

  execution_time = Benchmark.realtime(&block)
  finished(execution_time)
end