class AbstractImporter::Reporters::DebugReporter

Attributes

invalid_params[R]

Public Class Methods

new(io) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 6
def initialize(io)
  super
  @notices = {}
  @errors  = {}
  @invalid_params = {}
end

Public Instance Methods

count_error(message) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 75
def count_error(message)
  @errors[message] = (@errors[message] || 0) + 1
end
count_notice(message) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 71
def count_notice(message)
  @notices[message] = (@notices[message] || 0) + 1
end
file(s) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 65
def file(s)
  io.puts s.inspect
end
finish_all(importer, ms) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 19
def finish_all(importer, ms)
  print_invalid_params
  super
end
finish_collection(collection, summary) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 38
def finish_collection(collection, summary)
  print_summary summary, collection.name
  print_messages @notices, "Notices"
  print_messages @errors,  "Errors"
end
finish_setup(importer, ms) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 26
def finish_setup(importer, ms)
  super
end
info(s)
Alias for: stat
record_failed(record, hash) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 46
def record_failed(record, hash)
  error_messages = invalid_params[record.class.name] ||= Hash.new { |hash, key| hash[key] = [] }
  record.errors.full_messages.each do |error_message|
    error_messages[error_message].push hash
    count_error(error_message)
  end
end
start_all(importer) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 15
def start_all(importer)
  super
end
start_collection(collection) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 32
def start_collection(collection)
  super
  @notices = {}
  @errors  = {}
end
stat(s) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 60
def stat(s)
  io.puts "  #{s}"
end
Also aliased as: info
status(s) click to toggle source
# File lib/abstract_importer/reporters/debug_reporter.rb, line 56
def status(s)
  io.puts s
end

Private Instance Methods

print_invalid_params() click to toggle source
print_messages(array, caption) click to toggle source
print_summary(summary, plural) click to toggle source