Class: NcsNavigator::Warehouse::Comparator

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ncs_navigator/warehouse/comparator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_a, config_b, options = {}) ⇒ Comparator

Returns a new instance of Comparator.



14
15
16
17
18
19
20
21
22
23
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 14

def initialize(config_a, config_b, options={})
  @a = config_a; @b = config_b
  @level = options[:level] ||= 1

  shell.clear_line_and_say "Connecting to warehouse A..."
  DatabaseInitializer.new(@a).set_up_repository(:reporting, 'a')
  shell.clear_line_and_say "Connecting to warehouse B..."
  DatabaseInitializer.new(@b).set_up_repository(:reporting, 'b')
  shell.clear_line_and_say ''
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



10
11
12
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 10

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



10
11
12
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 10

def b
  @b
end

#levelObject (readonly)

Returns the value of attribute level.



9
10
11
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 9

def level
  @level
end

Instance Method Details

#compareObject



25
26
27
28
29
30
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 25

def compare
  shell.say_line "Running level #{level} compare..."
  count_diff if level >= 1
  id_diff if level >= 2
  content_diff if level >= 3
end

#content_diffObject



43
44
45
46
47
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 43

def content_diff
  @content_diffs = collect_differences(
    ContentDiff, models.collect { |m| [m, list_shared_ids(m)] }.select { |m, shared| shared })
  shell_summarize_differences(ContentDiff, @content_diffs)
end

#count_diffObject



32
33
34
35
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 32

def count_diff
  @count_diffs = collect_differences(CountDiff, models.collect { |m| [m] })
  shell_summarize_differences(CountDiff, @count_diffs)
end

#id_diffObject



37
38
39
40
41
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 37

def id_diff
  @id_diffs = collect_differences(
    IdDiff, models.select { |m| no_zero_counts?(m) }.collect { |m| [m] })
  shell_summarize_differences(IdDiff, @id_diffs)
end