Class: Topographer::Importer::Logger::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/topographer/importer/logger/base.rb

Direct Known Subclasses

Simple

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

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_errorsObject (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_entriesObject



53
54
55
# File 'lib/topographer/importer/logger/base.rb', line 53

def all_entries
  (successes + failures + fatal_errors).sort {|a, b| a.timestamp <=> b.timestamp}
end

#entries?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/topographer/importer/logger/base.rb', line 45

def entries?
  total_imports > 0
end

#errors?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/topographer/importer/logger/base.rb', line 57

def errors?
  fatal_error? || failed_imports > 0
end

#failed_importsObject

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/topographer/importer/logger/base.rb', line 41

def failed_imports
  raise NotImplementedError
end

#failuresObject

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/topographer/importer/logger/base.rb', line 13

def failures
  raise NotImplementedError
end

#fatal_error?Boolean

Returns:

  • (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

Raises:

  • (NotImplementedError)


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, message)
  @fatal_errors << Topographer::Importer::Logger::FatalErrorEntry.new(source, message)
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

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/topographer/importer/logger/base.rb', line 25

def log_success(log_entry)
  raise NotImplementedError
end

#saveObject

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/topographer/importer/logger/base.rb', line 65

def save
  raise NotImplementedError
end

#successesObject

Raises:

  • (NotImplementedError)


9
10
11
# File 'lib/topographer/importer/logger/base.rb', line 9

def successes
  raise NotImplementedError
end

#successful_importsObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/topographer/importer/logger/base.rb', line 37

def successful_imports
  raise NotImplementedError
end

#total_importsObject



49
50
51
# File 'lib/topographer/importer/logger/base.rb', line 49

def total_imports
  (successful_imports + failed_imports)
end