daff 1.2.6 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -6
  3. data/bin/daff.rb +0 -0
  4. data/lib/daff.rb +6 -0
  5. data/lib/lib/coopy/alignment.rb +146 -169
  6. data/lib/lib/coopy/cell_builder.rb +1 -1
  7. data/lib/lib/coopy/cell_info.rb +2 -1
  8. data/lib/lib/coopy/column_change.rb +16 -0
  9. data/lib/lib/coopy/compare_flags.rb +33 -5
  10. data/lib/lib/coopy/compare_table.rb +219 -99
  11. data/lib/lib/coopy/coopy.rb +205 -99
  12. data/lib/lib/coopy/csv.rb +17 -22
  13. data/lib/lib/coopy/diff_render.rb +16 -8
  14. data/lib/lib/coopy/flat_cell_builder.rb +11 -8
  15. data/lib/lib/coopy/highlight_patch.rb +363 -63
  16. data/lib/lib/coopy/highlight_patch_unit.rb +1 -1
  17. data/lib/lib/coopy/index.rb +21 -8
  18. data/lib/lib/coopy/index_item.rb +7 -3
  19. data/lib/lib/coopy/index_pair.rb +13 -10
  20. data/lib/lib/coopy/merger.rb +3 -3
  21. data/lib/lib/coopy/meta.rb +17 -0
  22. data/lib/lib/coopy/mover.rb +7 -5
  23. data/lib/lib/coopy/ndjson.rb +2 -2
  24. data/lib/lib/coopy/nested_cell_builder.rb +7 -7
  25. data/lib/lib/coopy/ordering.rb +6 -2
  26. data/lib/lib/coopy/property_change.rb +16 -0
  27. data/lib/lib/coopy/row.rb +1 -0
  28. data/lib/lib/coopy/row_change.rb +42 -0
  29. data/lib/lib/coopy/row_stream.rb +11 -0
  30. data/lib/lib/coopy/simple_table.rb +84 -30
  31. data/lib/lib/coopy/simple_view.rb +8 -8
  32. data/lib/lib/coopy/sparse_sheet.rb +1 -1
  33. data/lib/lib/coopy/sql_column.rb +22 -10
  34. data/lib/lib/coopy/sql_compare.rb +397 -85
  35. data/lib/lib/coopy/sql_database.rb +2 -0
  36. data/lib/lib/coopy/sql_helper.rb +5 -0
  37. data/lib/lib/coopy/sql_table.rb +122 -19
  38. data/lib/lib/coopy/sql_table_name.rb +1 -1
  39. data/lib/lib/coopy/sqlite_helper.rb +250 -3
  40. data/lib/lib/coopy/table.rb +1 -0
  41. data/lib/lib/coopy/table_diff.rb +643 -464
  42. data/lib/lib/coopy/table_io.rb +19 -6
  43. data/lib/lib/coopy/table_modifier.rb +1 -1
  44. data/lib/lib/coopy/table_stream.rb +102 -0
  45. data/lib/lib/coopy/terminal_diff_render.rb +4 -3
  46. data/lib/lib/coopy/unit.rb +22 -2
  47. data/lib/lib/coopy/viterbi.rb +4 -4
  48. data/lib/lib/haxe/ds/int_map.rb +1 -1
  49. data/lib/lib/haxe/ds/string_map.rb +1 -1
  50. data/lib/lib/haxe/format/json_parser.rb +1 -1
  51. data/lib/lib/haxe/format/json_printer.rb +1 -1
  52. data/lib/lib/haxe/io/bytes.rb +2 -2
  53. data/lib/lib/haxe/io/eof.rb +1 -1
  54. data/lib/lib/haxe/io/output.rb +1 -1
  55. data/lib/lib/hx_overrides.rb +1 -1
  56. data/lib/lib/hx_sys.rb +9 -5
  57. data/lib/lib/lambda.rb +3 -3
  58. data/lib/lib/list.rb +1 -1
  59. data/lib/lib/rb/ruby_iterator.rb +2 -2
  60. data/lib/lib/reflect.rb +1 -1
  61. data/lib/lib/sys/io/file_output.rb +1 -1
  62. data/lib/lib/sys/io/hx_file.rb +1 -1
  63. data/lib/lib/x_list/list_iterator.rb +2 -2
  64. metadata +29 -25
  65. data/lib/lib/coopy/table_text.rb +0 -26
  66. data/lib/lib/haxe/io/bytes_buffer.rb +0 -19
  67. data/lib/lib/haxe/io/bytes_input.rb +0 -13
  68. data/lib/lib/haxe/io/bytes_output.rb +0 -33
  69. data/lib/lib/haxe/io/input.rb +0 -11
@@ -29,7 +29,7 @@ module Coopy
29
29
  attr_accessor :patch_row
30
30
 
31
31
  def to_s
32
- return _hx_str(@code) + " patchRow " + _hx_str(@patch_row) + " sourceRows " + _hx_str(@source_prev_row) + "," + _hx_str(@source_row) + "," + _hx_str(@source_next_row) + " destRow " + _hx_str(@dest_row)
32
+ "(" + _hx_str(@code) + " patch " + _hx_str(@patch_row) + " source " + _hx_str(@source_prev_row) + ":" + _hx_str(@source_row) + ":" + _hx_str(@source_next_row) + "+" + _hx_str(@source_row_offset) + " dest " + _hx_str(@dest_row) + ")"
33
33
  end
34
34
 
35
35
  haxe_me ["coopy", "HighlightPatchUnit"]
@@ -10,6 +10,7 @@ module Coopy
10
10
  @keys = Array.new
11
11
  @top_freq = 0
12
12
  @height = 0
13
+ @hdr = 0
13
14
  end
14
15
 
15
16
  attr_accessor :items
@@ -22,6 +23,7 @@ module Coopy
22
23
  attr_accessor :cols
23
24
  attr_accessor :v
24
25
  attr_accessor :indexed_table
26
+ attr_accessor :hdr
25
27
 
26
28
  public
27
29
 
@@ -29,8 +31,9 @@ module Coopy
29
31
  @cols.push(i)
30
32
  end
31
33
 
32
- def index_table(t)
34
+ def index_table(t,hdr)
33
35
  @indexed_table = t
36
+ @hdr = hdr
34
37
  @keys[t.get_height - 1] = nil if @keys.length != t.get_height && t.get_height > 0
35
38
  begin
36
39
  _g1 = 0
@@ -61,7 +64,12 @@ module Coopy
61
64
  end
62
65
 
63
66
  def to_key(t,i)
64
- wide = ""
67
+ wide = nil
68
+ if i < @hdr
69
+ wide = "_"
70
+ else
71
+ wide = ""
72
+ end
65
73
  @v = t.get_cell_view if @v == nil
66
74
  begin
67
75
  _g1 = 0
@@ -71,16 +79,21 @@ module Coopy
71
79
  _g1+=1
72
80
  d = t.get_cell(@cols[k],i)
73
81
  txt = @v.to_s(d)
74
- next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
75
82
  wide += " // " if k > 0
83
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
76
84
  wide += txt
77
85
  end
78
86
  end
79
- return wide
87
+ wide
80
88
  end
81
89
 
82
90
  def to_key_by_content(row)
83
- wide = ""
91
+ wide = nil
92
+ if row.is_preamble
93
+ wide = "_"
94
+ else
95
+ wide = ""
96
+ end
84
97
  begin
85
98
  _g1 = 0
86
99
  _g = @cols.length
@@ -88,16 +101,16 @@ module Coopy
88
101
  k = _g1
89
102
  _g1+=1
90
103
  txt = row.get_row_string(@cols[k])
91
- next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
92
104
  wide += " // " if k > 0
105
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
93
106
  wide += txt
94
107
  end
95
108
  end
96
- return wide
109
+ wide
97
110
  end
98
111
 
99
112
  def get_table
100
- return @indexed_table
113
+ @indexed_table
101
114
  end
102
115
 
103
116
  haxe_me ["coopy", "Index"]
@@ -16,15 +16,19 @@ module Coopy
16
16
  def add(i)
17
17
  @lst = Array.new if @lst == nil
18
18
  @lst.push(i)
19
- return @lst.length
19
+ @lst.length
20
20
  end
21
21
 
22
22
  def length
23
- return @lst.length
23
+ @lst.length
24
24
  end
25
25
 
26
26
  def value
27
- return @lst[0]
27
+ @lst[0]
28
+ end
29
+
30
+ def as_list
31
+ @lst
28
32
  end
29
33
 
30
34
  haxe_me ["coopy", "IndexItem"]
@@ -8,12 +8,14 @@ module Coopy
8
8
  @ia = ::Coopy::Index.new
9
9
  @ib = ::Coopy::Index.new
10
10
  @quality = 0
11
+ @hdr = 0
11
12
  end
12
13
 
13
14
  protected
14
15
 
15
16
  attr_accessor :ia
16
17
  attr_accessor :ib
18
+ attr_accessor :hdr
17
19
  attr_accessor :quality
18
20
 
19
21
  public
@@ -23,9 +25,10 @@ module Coopy
23
25
  @ib.add_column(cb)
24
26
  end
25
27
 
26
- def index_tables(a,b)
27
- @ia.index_table(a)
28
- @ib.index_table(b)
28
+ def index_tables(a,b,hdr)
29
+ @ia.index_table(a,hdr)
30
+ @ib.index_table(b,hdr)
31
+ @hdr = hdr
29
32
  good = 0
30
33
  _it = ::Rb::RubyIterator.new(@ia.items.keys)
31
34
  while(_it.has_next) do
@@ -52,7 +55,7 @@ module Coopy
52
55
  result.spot_a = result.item_a.lst.length if result.item_a != nil
53
56
  result.spot_b = result.item_b.lst.length if result.item_b != nil
54
57
  end
55
- return result
58
+ result
56
59
  end
57
60
 
58
61
  public
@@ -60,29 +63,29 @@ module Coopy
60
63
  def query_by_content(row)
61
64
  result = ::Coopy::CrossMatch.new
62
65
  ka = @ia.to_key_by_content(row)
63
- return self.query_by_key(ka)
66
+ self.query_by_key(ka)
64
67
  end
65
68
 
66
69
  def query_local(row)
67
70
  ka = @ia.to_key(@ia.get_table,row)
68
- return self.query_by_key(ka)
71
+ self.query_by_key(ka)
69
72
  end
70
73
 
71
74
  def local_key(row)
72
- return @ia.to_key(@ia.get_table,row)
75
+ @ia.to_key(@ia.get_table,row)
73
76
  end
74
77
 
75
78
  def remote_key(row)
76
- return @ib.to_key(@ib.get_table,row)
79
+ @ib.to_key(@ib.get_table,row)
77
80
  end
78
81
 
79
82
  def get_top_freq
80
83
  return @ib.top_freq if @ib.top_freq > @ia.top_freq
81
- return @ia.top_freq
84
+ @ia.top_freq
82
85
  end
83
86
 
84
87
  def get_quality
85
- return @quality
88
+ @quality
86
89
  end
87
90
 
88
91
  haxe_me ["coopy", "IndexPair"]
@@ -75,7 +75,7 @@ module Coopy
75
75
  end
76
76
  end
77
77
  end
78
- return at
78
+ at
79
79
  end
80
80
 
81
81
  def shuffle_columns
@@ -171,13 +171,13 @@ module Coopy
171
171
  end
172
172
  end
173
173
  end
174
- return @conflicts
174
+ @conflicts
175
175
  end
176
176
 
177
177
  # protected - in ruby this doesn't play well with static/inline methods
178
178
 
179
179
  def Merger.make_conflicted_cell(view,pcell,lcell,rcell)
180
- return view.to_datum("((( " + _hx_str(view.to_s(pcell)) + " ))) " + _hx_str(view.to_s(lcell)) + " /// " + _hx_str(view.to_s(rcell)))
180
+ view.to_datum("((( " + _hx_str(view.to_s(pcell)) + " ))) " + _hx_str(view.to_s(lcell)) + " /// " + _hx_str(view.to_s(rcell)))
181
181
  end
182
182
 
183
183
  haxe_me ["coopy", "Merger"]
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class Meta
6
+ def alterColumns(columns) puts "Abstract Meta.alterColumns called" end
7
+ def changeRow(rc) puts "Abstract Meta.changeRow called" end
8
+ def applyFlags(flags) puts "Abstract Meta.applyFlags called" end
9
+ def asTable() puts "Abstract Meta.asTable called" end
10
+ def cloneMeta(table = nil) puts "Abstract Meta.cloneMeta called" end
11
+ def useForColumnChanges() puts "Abstract Meta.useForColumnChanges called" end
12
+ def useForRowChanges() puts "Abstract Meta.useForRowChanges called" end
13
+ def getRowStream() puts "Abstract Meta.getRowStream called" end
14
+ haxe_me ["coopy", "Meta"]
15
+ end
16
+
17
+ end
@@ -53,7 +53,7 @@ module Coopy
53
53
  idest.push(v) if v != nil
54
54
  end
55
55
  end
56
- return ::Coopy::Mover.move_without_extras(isrc,idest)
56
+ ::Coopy::Mover.move_without_extras(isrc,idest)
57
57
  end
58
58
 
59
59
  def Mover.move(isrc,idest)
@@ -104,7 +104,7 @@ module Coopy
104
104
  dest.push(v) if in_src.include?(v)
105
105
  end
106
106
  end
107
- return ::Coopy::Mover.move_without_extras(src,dest)
107
+ ::Coopy::Mover.move_without_extras(src,dest)
108
108
  end
109
109
 
110
110
  # protected - in ruby this doesn't play well with static/inline methods
@@ -155,8 +155,10 @@ module Coopy
155
155
  k = _it._next
156
156
  blks.push(k)
157
157
  end
158
- blks.sort {|a,b|
159
- return blk_len[b] - blk_len[a]
158
+ blks.sort! {|a,b|
159
+ diff = blk_len[b] - blk_len[a]
160
+ return diff if diff != 0
161
+ a - b
160
162
  }
161
163
  moved = Array.new
162
164
  while(blks.length > 0)
@@ -186,7 +188,7 @@ module Coopy
186
188
  i1-=1
187
189
  end
188
190
  end
189
- return moved
191
+ moved
190
192
  end
191
193
 
192
194
  haxe_me ["coopy", "Mover"]
@@ -38,7 +38,7 @@ module Coopy
38
38
  end
39
39
  end
40
40
  end
41
- return ::Haxe::Format::JsonPrinter._print(row,nil,nil)
41
+ ::Haxe::Format::JsonPrinter._print(row,nil,nil)
42
42
  end
43
43
 
44
44
  def render
@@ -58,7 +58,7 @@ module Coopy
58
58
  txt += "\n"
59
59
  end
60
60
  end
61
- return txt
61
+ txt
62
62
  end
63
63
 
64
64
  def add_row(r,txt)
@@ -14,7 +14,7 @@ module Coopy
14
14
  public
15
15
 
16
16
  def need_separator
17
- return false
17
+ false
18
18
  end
19
19
 
20
20
  def set_separator(separator)
@@ -31,7 +31,7 @@ module Coopy
31
31
  h = @view.make_hash
32
32
  @view.hash_set(h,"before",local)
33
33
  @view.hash_set(h,"after",remote)
34
- return h
34
+ h
35
35
  end
36
36
 
37
37
  def conflict(parent,local,remote)
@@ -39,23 +39,23 @@ module Coopy
39
39
  @view.hash_set(h,"before",parent)
40
40
  @view.hash_set(h,"ours",local)
41
41
  @view.hash_set(h,"theirs",remote)
42
- return h
42
+ h
43
43
  end
44
44
 
45
45
  def marker(label)
46
- return @view.to_datum(label)
46
+ @view.to_datum(label)
47
47
  end
48
48
 
49
49
  protected
50
50
 
51
51
  def neg_to_null(x)
52
52
  return nil if x < 0
53
- return x
53
+ x
54
54
  end
55
55
 
56
56
  public
57
57
 
58
- def links(unit)
58
+ def links(unit,row_like)
59
59
  h = @view.make_hash
60
60
  if unit.p >= -1
61
61
  @view.hash_set(h,"before",self.neg_to_null(unit.p))
@@ -65,7 +65,7 @@ module Coopy
65
65
  end
66
66
  @view.hash_set(h,"before",self.neg_to_null(unit.l))
67
67
  @view.hash_set(h,"after",self.neg_to_null(unit.r))
68
- return h
68
+ h
69
69
  end
70
70
 
71
71
  haxe_me ["coopy", "NestedCellBuilder"]
@@ -22,7 +22,11 @@ module Coopy
22
22
  end
23
23
 
24
24
  def get_list
25
- return @order
25
+ @order
26
+ end
27
+
28
+ def set_list(lst)
29
+ @order = lst
26
30
  end
27
31
 
28
32
  def to_s
@@ -37,7 +41,7 @@ module Coopy
37
41
  txt += @order[i].to_s
38
42
  end
39
43
  end
40
- return txt
44
+ txt
41
45
  end
42
46
 
43
47
  def ignore_parent
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class PropertyChange
6
+
7
+ def initialize
8
+ end
9
+
10
+ attr_accessor :prev_name
11
+ attr_accessor :name
12
+ attr_accessor :val
13
+ haxe_me ["coopy", "PropertyChange"]
14
+ end
15
+
16
+ end
@@ -4,6 +4,7 @@
4
4
  module Coopy
5
5
  class Row
6
6
  def getRowString(c) puts "Abstract Row.getRowString called" end
7
+ def isPreamble() puts "Abstract Row.isPreamble called" end
7
8
  haxe_me ["coopy", "Row"]
8
9
  end
9
10
 
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class RowChange
6
+
7
+ def initialize
8
+ end
9
+
10
+ attr_accessor :cond
11
+ attr_accessor :val
12
+ attr_accessor :conflicting_val
13
+ attr_accessor :conflicting_parent_val
14
+ attr_accessor :conflicted
15
+ attr_accessor :is_key
16
+ attr_accessor :action
17
+
18
+ protected
19
+
20
+ def show_map(m)
21
+ return "{}" if m == nil
22
+ txt = ""
23
+ _it = ::Rb::RubyIterator.new(m.keys)
24
+ while(_it.has_next) do
25
+ k = _it._next
26
+ txt += ", " if txt != ""
27
+ v = m[k]
28
+ txt += _hx_str(k) + "=" + _hx_str(v.to_s)
29
+ end
30
+ "{ " + _hx_str(txt) + " }"
31
+ end
32
+
33
+ public
34
+
35
+ def to_s
36
+ _hx_str(@action) + " " + _hx_str(self.show_map(@cond)) + " : " + _hx_str(self.show_map(@val))
37
+ end
38
+
39
+ haxe_me ["coopy", "RowChange"]
40
+ end
41
+
42
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class RowStream
6
+ def fetchColumns() puts "Abstract RowStream.fetchColumns called" end
7
+ def fetchRow() puts "Abstract RowStream.fetchRow called" end
8
+ haxe_me ["coopy", "RowStream"]
9
+ end
10
+
11
+ end