Class: Sprig::ProcessNotifier

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/sprig/process_notifier.rb

Constant Summary

Constants included from Logging

Logging::LOG_COLORS, Logging::LOG_LEVELS

Instance Method Summary collapse

Constructor Details

#initializeProcessNotifier

Returns a new instance of ProcessNotifier.



7
8
9
10
11
# File 'lib/sprig/process_notifier.rb', line 7

def initialize
  @success_count = 0
  @error_count = 0
  @errors = []
end

Instance Method Details

#error(seed) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/sprig/process_notifier.rb', line 22

def error(seed)
  @errors << seed.record
  log_error seed.error_log_text
  log_error seed.record
  log_error seed.record.errors.messages
  @error_count += 1
end

#finishedObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sprig/process_notifier.rb', line 30

def finished
  log_debug 'Seeding complete.'

  if @success_count > 0
    log_info success_summary
  else
    log_error success_summary
  end

  if @error_count > 0
    log_error error_summary

    @errors.each do |error|
      log_error error
      log_error "#{error.errors.messages}\n"
    end
  end
end

#in_progress(seed) ⇒ Object



13
14
15
# File 'lib/sprig/process_notifier.rb', line 13

def in_progress(seed)
  log_debug seed.in_progress_text
end

#success(seed) ⇒ Object



17
18
19
20
# File 'lib/sprig/process_notifier.rb', line 17

def success(seed)
  log_info seed.success_log_text
  @success_count += 1
end