Class: DatabaseConsistency::Writers::Simple::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/database_consistency/writers/simple/base.rb

Overview

:nodoc:

Constant Summary collapse

COLORS =
{
  blue: "\e[34m",
  yellow: "\e[33m",
  green: "\e[32m",
  red: "\e[31m"
}.freeze
COLOR_BY_STATUS =
{
  ok: :green,
  warning: :yellow,
  fail: :red
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report, config:) ⇒ Base

Returns a new instance of Base.



30
31
32
33
# File 'lib/database_consistency/writers/simple/base.rb', line 30

def initialize(report, config:)
  @report = report
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



28
29
30
# File 'lib/database_consistency/writers/simple/base.rb', line 28

def config
  @config
end

#reportObject (readonly)

Returns the value of attribute report.



28
29
30
# File 'lib/database_consistency/writers/simple/base.rb', line 28

def report
  @report
end

Class Method Details

.with(text) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/database_consistency/writers/simple/base.rb', line 20

def self.with(text)
  Class.new(self) do
    define_method :template do
      text
    end
  end
end

Instance Method Details

#msgObject



35
36
37
# File 'lib/database_consistency/writers/simple/base.rb', line 35

def msg
  [report.checker_name, status_text, key_text, message_text].compact.join(' ').strip
end

#unique_keyObject



39
40
41
# File 'lib/database_consistency/writers/simple/base.rb', line 39

def unique_key
  { class: self.class }.merge(unique_attributes)
end