Class: NcsNavigator::Warehouse::Comparator
- Inherits:
-
Object
- Object
- NcsNavigator::Warehouse::Comparator
- Extended by:
- Forwardable
- Defined in:
- lib/ncs_navigator/warehouse/comparator.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Instance Method Summary collapse
- #compare ⇒ Object
- #content_diff ⇒ Object
- #count_diff ⇒ Object
- #id_diff ⇒ Object
-
#initialize(config_a, config_b, options = {}) ⇒ Comparator
constructor
A new instance of Comparator.
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, ={}) @a = config_a; @b = config_b @level = [: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
#a ⇒ Object (readonly)
Returns the value of attribute a.
10 11 12 |
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 10 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
10 11 12 |
# File 'lib/ncs_navigator/warehouse/comparator.rb', line 10 def b @b end |
#level ⇒ Object (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
#compare ⇒ Object
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_diff ⇒ Object
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_diff ⇒ Object
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_diff ⇒ Object
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 |