Class: AbstractImporter::Reporters::DebugReporter
Instance Attribute Summary collapse
Attributes inherited from BaseReporter
#io
Instance Method Summary
collapse
#batch_inserted, #finish_teardown, #record_created
Constructor Details
Returns a new instance of DebugReporter.
6
7
8
9
10
11
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 6
def initialize(io)
super
@notices = {}
@errors = {}
@invalid_params = {}
end
|
Instance Attribute Details
#invalid_params ⇒ Object
Returns the value of attribute invalid_params.
4
5
6
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 4
def invalid_params
@invalid_params
end
|
Instance Method Details
#count_error(message) ⇒ Object
75
76
77
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 75
def count_error(message)
@errors[message] = (@errors[message] || 0) + 1
end
|
#count_notice(message) ⇒ Object
71
72
73
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 71
def count_notice(message)
@notices[message] = (@notices[message] || 0) + 1
end
|
#file(s) ⇒ Object
65
66
67
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 65
def file(s)
io.puts s.inspect
end
|
#finish_all(importer, ms) ⇒ Object
19
20
21
22
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 19
def finish_all(importer, ms)
print_invalid_params
super
end
|
#finish_collection(collection, summary) ⇒ Object
38
39
40
41
42
|
# 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) ⇒ Object
26
27
28
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 26
def finish_setup(importer, ms)
super
end
|
#record_failed(record, hash) ⇒ Object
46
47
48
49
50
51
52
|
# 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) ⇒ Object
15
16
17
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 15
def start_all(importer)
super
end
|
#start_collection(collection) ⇒ Object
32
33
34
35
36
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 32
def start_collection(collection)
super
@notices = {}
@errors = {}
end
|
#stat(s) ⇒ Object
Also known as:
info
60
61
62
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 60
def stat(s)
io.puts " #{s}"
end
|
#status(s) ⇒ Object
56
57
58
|
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 56
def status(s)
io.puts s
end
|