Class: Packwerk::Formatters::ProgressFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/packwerk/formatters/progress_formatter.rb

Instance Method Summary collapse

Constructor Details

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

: ((StringIO | IO) out, ?style: OutputStyle) -> void



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

: (?bool failed) -> void



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

#interruptedObject

: -> void



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_failedObject

: -> void



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_inspectedObject

: -> void



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

: (FilesForProcessing::relative_file_set target_files) { -> void } -> void



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

: { -> void } -> void



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