Class: AbstractImporter::Reporters::DebugReporter
- Inherits:
-
BaseReporter
- Object
- BaseReporter
- AbstractImporter::Reporters::DebugReporter
- Defined in:
- lib/abstract_importer/reporters/debug_reporter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#invalid_params ⇒ Object
readonly
Returns the value of attribute invalid_params.
Attributes inherited from BaseReporter
Instance Method Summary collapse
- #count_error(message) ⇒ Object
- #count_notice(message) ⇒ Object
- #file(s) ⇒ Object
- #finish_all(importer, ms) ⇒ Object
- #finish_collection(collection, summary) ⇒ Object
- #finish_setup(ms) ⇒ Object
-
#initialize(io) ⇒ DebugReporter
constructor
A new instance of DebugReporter.
- #production? ⇒ Boolean
- #record_failed(record, hash) ⇒ Object
- #start_all(importer) ⇒ Object
- #start_collection(collection) ⇒ Object
- #stat(s) ⇒ Object (also: #info)
- #status(s) ⇒ Object
Methods inherited from BaseReporter
Constructor Details
#initialize(io) ⇒ DebugReporter
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 (readonly)
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
82 83 84 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 82 def count_error() @errors[] = (@errors[] || 0) + 1 end |
#count_notice(message) ⇒ Object
77 78 79 80 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 77 def count_notice() return if production? @notices[] = (@notices[] || 0) + 1 end |
#file(s) ⇒ Object
71 72 73 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 71 def file(s) io.puts s.inspect end |
#finish_all(importer, ms) ⇒ Object
25 26 27 28 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 25 def finish_all(importer, ms) print_invalid_params super end |
#finish_collection(collection, summary) ⇒ Object
44 45 46 47 48 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 44 def finish_collection(collection, summary) print_summary summary, collection.name @notices, "Notices" @errors, "Errors" end |
#finish_setup(ms) ⇒ Object
32 33 34 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 32 def finish_setup(ms) super end |
#production? ⇒ Boolean
15 16 17 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 15 def production? Rails.env.production? end |
#record_failed(record, hash) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 52 def record_failed(record, hash) = invalid_params[record.class.name] ||= {} record.errors..each do || [] = hash unless .key?() count_error() end end |
#start_all(importer) ⇒ Object
21 22 23 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 21 def start_all(importer) super end |
#start_collection(collection) ⇒ Object
38 39 40 41 42 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 38 def start_collection(collection) super @notices = {} @errors = {} end |
#stat(s) ⇒ Object Also known as: info
66 67 68 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 66 def stat(s) io.puts " #{s}" end |
#status(s) ⇒ Object
62 63 64 |
# File 'lib/abstract_importer/reporters/debug_reporter.rb', line 62 def status(s) io.puts s end |