Class: Coopy::TableDiff

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/coopy/table_diff.rb

Instance Method Summary collapse

Constructor Details

#initialize(align, flags) ⇒ TableDiff

Returns a new instance of TableDiff.



7
8
9
10
11
12
# File 'lib/lib/coopy/table_diff.rb', line 7

def initialize(align,flags)
  @align = align
  @flags = flags
  @builder = nil
  @preserve_columns = false
end

Instance Method Details

#has_difference ⇒ Object



989
990
991
# File 'lib/lib/coopy/table_diff.rb', line 989

def has_difference 
  @diff_found
end

#has_schema_difference ⇒ Object



993
994
995
# File 'lib/lib/coopy/table_diff.rb', line 993

def has_schema_difference 
  @schema_diff_found
end

#hilite(output) ⇒ Object



876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
# File 'lib/lib/coopy/table_diff.rb', line 876

def hilite(output)
  return false if !output.is_resizable
  if @builder == nil 
    if @flags.allow_nested_cells 
      @builder = ::Coopy::NestedCellBuilder.new
    else 
      @builder = ::Coopy::FlatCellBuilder.new(@flags)
    end
  end
  output.resize(0,0)
  output.clear
  self.reset
  self.setup_tables
  self.setup_columns
  self.setup_moves
  self.scan_activity
  self.scan_schema
  self.add_schema(output)
  self.add_header(output)
  self.add_meta(output)
  outer_reps_needed = nil
  if @flags.show_unchanged && @flags.show_unchanged_columns 
    outer_reps_needed = 1
  else 
    outer_reps_needed = 2
  end
  output_height = output.get_height
  output_height_init = output.get_height
  begin
    _g = 0
    while(_g < outer_reps_needed) 
      out = _g
      _g+=1
      if out == 1 
        self.refine_activity
        rows = self.count_active(@active_row) + output_height_init
        rows-=1 if @top_line_done
        output_height = output_height_init
        output.resize(@column_units.length + 1,rows) if rows > output.get_height
      end
      showed_dummy = false
      l = -1
      r = -1
      begin
        _g2 = 0
        _g1 = @row_units.length
        while(_g2 < _g1) 
          i = _g2
          _g2+=1
          unit = @row_units[i]
          reordered = false
          if @flags.ordered 
            reordered = true if @row_moves.include?(i)
            @show_rc_numbers = true if reordered
          end
          next if unit.r < 0 && unit.l < 0
          next if unit.r == 0 && unit.lp <= 0 && @top_line_done
          @publish = @flags.show_unchanged
          dummy = false
          if out == 1 
            @publish = @active_row[i] > 0
            dummy = @active_row[i] == 3
            next if dummy && showed_dummy
            next if !@publish
          end
          showed_dummy = false if !dummy
          at = output_height
          if @publish 
            output_height+=1
            output.resize(@column_units.length + 1,output_height) if output.get_height < output_height
          end
          if dummy 
            begin
              _g4 = 0
              _g3 = @column_units.length + 1
              while(_g4 < _g3) 
                j = _g4
                _g4+=1
                output.set_cell(j,at,@v.to_datum("..."))
              end
            end
            showed_dummy = true
            next
          end
          @have_addition = false
          skip = false
          @act = ""
          @act = ":" if reordered
          if unit.p < 0 && unit.l < 0 && unit.r >= 0 
            skip = true if !@allow_insert
            @act = "+++"
          end
          if (unit.p >= 0 || !@has_parent) && unit.l >= 0 && unit.r < 0 
            skip = true if !@allow_delete
            @act = "---"
          end
          if skip 
            if !@publish 
              @active_row[i] = -3 if @active_row != nil
            end
            next
          end
          self.scan_row(unit,output,at,i)
        end
      end
    end
  end
  self.check_rc_numbers(output.get_width,output.get_height)
  admin_w = self.add_rc_numbers(output)
  self.elide_columns(output,admin_w) if !@preserve_columns
  true
end

#set_cell_builder(builder) ⇒ Object



57
58
59
# File 'lib/lib/coopy/table_diff.rb', line 57

def set_cell_builder(builder)
  @builder = builder
end