Class: Topographer::Importer::Logger::Base
- Inherits:
-
Object
- Object
- Topographer::Importer::Logger::Base
- Defined in:
- lib/topographer/importer/logger/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fatal_errors ⇒ Object
readonly
Returns the value of attribute fatal_errors.
Instance Method Summary collapse
- #all_entries ⇒ Object
- #entries? ⇒ Boolean
- #errors? ⇒ Boolean
- #failed_imports ⇒ Object
- #failures ⇒ Object
- #fatal_error? ⇒ Boolean
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #log_failure(log_entry) ⇒ Object
- #log_fatal(source, message) ⇒ Object
- #log_import(log_entry) ⇒ Object
- #log_success(log_entry) ⇒ Object
- #save ⇒ Object
- #successes ⇒ Object
- #successful_imports ⇒ Object
- #total_imports ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/topographer/importer/logger/base.rb', line 5 def initialize @fatal_errors = [] end |
Instance Attribute Details
#fatal_errors ⇒ Object (readonly)
Returns the value of attribute fatal_errors.
3 4 5 |
# File 'lib/topographer/importer/logger/base.rb', line 3 def fatal_errors @fatal_errors end |
Instance Method Details
#all_entries ⇒ Object
53 54 55 |
# File 'lib/topographer/importer/logger/base.rb', line 53 def all_entries (successes + failures + fatal_errors).sort {|a, b| a. <=> b.} end |
#entries? ⇒ Boolean
45 46 47 |
# File 'lib/topographer/importer/logger/base.rb', line 45 def entries? total_imports > 0 end |
#errors? ⇒ Boolean
57 58 59 |
# File 'lib/topographer/importer/logger/base.rb', line 57 def errors? fatal_error? || failed_imports > 0 end |
#failed_imports ⇒ Object
41 42 43 |
# File 'lib/topographer/importer/logger/base.rb', line 41 def failed_imports raise NotImplementedError end |
#failures ⇒ Object
13 14 15 |
# File 'lib/topographer/importer/logger/base.rb', line 13 def failures raise NotImplementedError end |
#fatal_error? ⇒ Boolean
61 62 63 |
# File 'lib/topographer/importer/logger/base.rb', line 61 def fatal_error? @fatal_errors.any? end |
#log_failure(log_entry) ⇒ Object
29 30 31 |
# File 'lib/topographer/importer/logger/base.rb', line 29 def log_failure(log_entry) raise NotImplementedError end |
#log_fatal(source, message) ⇒ Object
33 34 35 |
# File 'lib/topographer/importer/logger/base.rb', line 33 def log_fatal(source, ) @fatal_errors << Topographer::Importer::Logger::FatalErrorEntry.new(source, ) end |
#log_import(log_entry) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/topographer/importer/logger/base.rb', line 17 def log_import(log_entry) if log_entry.success? log_success(log_entry) else log_failure(log_entry) end end |
#log_success(log_entry) ⇒ Object
25 26 27 |
# File 'lib/topographer/importer/logger/base.rb', line 25 def log_success(log_entry) raise NotImplementedError end |
#save ⇒ Object
65 66 67 |
# File 'lib/topographer/importer/logger/base.rb', line 65 def save raise NotImplementedError end |
#successes ⇒ Object
9 10 11 |
# File 'lib/topographer/importer/logger/base.rb', line 9 def successes raise NotImplementedError end |
#successful_imports ⇒ Object
37 38 39 |
# File 'lib/topographer/importer/logger/base.rb', line 37 def successful_imports raise NotImplementedError end |
#total_imports ⇒ Object
49 50 51 |
# File 'lib/topographer/importer/logger/base.rb', line 49 def total_imports (successful_imports + failed_imports) end |