Class: Nochmal::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/nochmal/output.rb

Overview

Handles output for the Reupload Task

Class Method Summary collapse

Class Method Details

.attachment(filename) ⇒ Object



33
34
35
# File 'lib/nochmal/output.rb', line 33

def attachment(filename)
  print attachment_detail(filename)
end

.model(model, skipping: false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/nochmal/output.rb', line 15

def model(model, skipping: false)
  if skipping
    puts "Skipping #{pastel.green(model)}"
    return true
  end

  puts model_header(model)
  yield
  puts model_footer
end

.notes(notes) ⇒ Object



37
38
39
40
41
42
# File 'lib/nochmal/output.rb', line 37

def notes(notes)
  notes = Array.wrap(notes)
  return unless notes.any?

  puts reupload_notes(notes)
end


58
59
60
# File 'lib/nochmal/output.rb', line 58

def print_failure_indicator
  print pastel.red("F")
end


54
55
56
# File 'lib/nochmal/output.rb', line 54

def print_progress_indicator
  print pastel.green(".")
end


44
45
46
47
48
49
50
51
52
# File 'lib/nochmal/output.rb', line 44

def print_result_indicator(status)
  case status
  when :ok      then print_progress_indicator
  when :missing then print_failure_indicator
  when :skip    then print_skip_indicator
  when :noop    then nil
  else print_unknown_indicator
  end
end


62
63
64
# File 'lib/nochmal/output.rb', line 62

def print_skip_indicator
  print pastel.yellow("*")
end


66
67
68
# File 'lib/nochmal/output.rb', line 66

def print_unknown_indicator
  print pastel.blue("?")
end

.reupload(models) ⇒ Object



9
10
11
12
13
# File 'lib/nochmal/output.rb', line 9

def reupload(models)
  puts reupload_header(models)
  yield
  puts reupload_footer
end

.type(type, count, action) ⇒ Object



26
27
28
29
30
31
# File 'lib/nochmal/output.rb', line 26

def type(type, count, action)
  puts type_header(type)
  print attachment_summary(count, action)
  yield
  puts type_footer
end