daff 1.1.2

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 (62) hide show
  1. data/bin/daff.rb +3 -0
  2. data/lib/daff.rb +95 -0
  3. data/lib/lib/coopy/alignment.rb +409 -0
  4. data/lib/lib/coopy/bag.rb +10 -0
  5. data/lib/lib/coopy/cell_info.rb +29 -0
  6. data/lib/lib/coopy/change.rb +48 -0
  7. data/lib/lib/coopy/change_type.rb +21 -0
  8. data/lib/lib/coopy/compare.rb +98 -0
  9. data/lib/lib/coopy/compare_flags.rb +46 -0
  10. data/lib/lib/coopy/compare_table.rb +402 -0
  11. data/lib/lib/coopy/coopy.rb +414 -0
  12. data/lib/lib/coopy/cross_match.rb +16 -0
  13. data/lib/lib/coopy/csv.rb +181 -0
  14. data/lib/lib/coopy/diff_render.rb +254 -0
  15. data/lib/lib/coopy/highlight_patch.rb +651 -0
  16. data/lib/lib/coopy/highlight_patch_unit.rb +37 -0
  17. data/lib/lib/coopy/index.rb +101 -0
  18. data/lib/lib/coopy/index_item.rb +20 -0
  19. data/lib/lib/coopy/index_pair.rb +87 -0
  20. data/lib/lib/coopy/mover.rb +195 -0
  21. data/lib/lib/coopy/ordering.rb +49 -0
  22. data/lib/lib/coopy/report.rb +23 -0
  23. data/lib/lib/coopy/row.rb +9 -0
  24. data/lib/lib/coopy/simple_cell.rb +23 -0
  25. data/lib/lib/coopy/simple_table.rb +242 -0
  26. data/lib/lib/coopy/simple_view.rb +41 -0
  27. data/lib/lib/coopy/sparse_sheet.rb +50 -0
  28. data/lib/lib/coopy/table.rb +17 -0
  29. data/lib/lib/coopy/table_comparison_state.rb +32 -0
  30. data/lib/lib/coopy/table_diff.rb +738 -0
  31. data/lib/lib/coopy/table_io.rb +33 -0
  32. data/lib/lib/coopy/table_modifier.rb +39 -0
  33. data/lib/lib/coopy/table_text.rb +25 -0
  34. data/lib/lib/coopy/unit.rb +70 -0
  35. data/lib/lib/coopy/view.rb +14 -0
  36. data/lib/lib/coopy/viewed_datum.rb +37 -0
  37. data/lib/lib/coopy/viterbi.rb +172 -0
  38. data/lib/lib/coopy/workspace.rb +22 -0
  39. data/lib/lib/haxe/ds/int_map.rb +14 -0
  40. data/lib/lib/haxe/ds/string_map.rb +14 -0
  41. data/lib/lib/haxe/format/json_parser.rb +264 -0
  42. data/lib/lib/haxe/format/json_printer.rb +239 -0
  43. data/lib/lib/haxe/io/bytes.rb +33 -0
  44. data/lib/lib/haxe/io/eof.rb +17 -0
  45. data/lib/lib/haxe/io/error.rb +21 -0
  46. data/lib/lib/haxe/io/output.rb +40 -0
  47. data/lib/lib/haxe/log.rb +16 -0
  48. data/lib/lib/hx_overrides.rb +18 -0
  49. data/lib/lib/imap.rb +6 -0
  50. data/lib/lib/lambda.rb +36 -0
  51. data/lib/lib/list.rb +42 -0
  52. data/lib/lib/rb/boot.rb +19 -0
  53. data/lib/lib/rb/ruby_iterator.rb +49 -0
  54. data/lib/lib/reflect.rb +29 -0
  55. data/lib/lib/string_buf.rb +14 -0
  56. data/lib/lib/sys.rb +19 -0
  57. data/lib/lib/sys/io/file.rb +19 -0
  58. data/lib/lib/sys/io/file_handle.rb +17 -0
  59. data/lib/lib/sys/io/file_output.rb +35 -0
  60. data/lib/lib/type.rb +32 -0
  61. data/lib/lib/value_type.rb +22 -0
  62. metadata +181 -0
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class HighlightPatchUnit
6
+
7
+ def initialize
8
+ @add = false
9
+ @rem = false
10
+ @update = false
11
+ @source_row = -1
12
+ @source_row_offset = 0
13
+ @source_prev_row = -1
14
+ @source_next_row = -1
15
+ @dest_row = -1
16
+ @patch_row = -1
17
+ @code = ""
18
+ end
19
+
20
+ attr_accessor :add
21
+ attr_accessor :rem
22
+ attr_accessor :update
23
+ attr_accessor :code
24
+ attr_accessor :source_row
25
+ attr_accessor :source_row_offset
26
+ attr_accessor :source_prev_row
27
+ attr_accessor :source_next_row
28
+ attr_accessor :dest_row
29
+ attr_accessor :patch_row
30
+
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)
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class Index
6
+
7
+ def initialize
8
+ @items = {}
9
+ @cols = Array.new
10
+ @keys = Array.new
11
+ @top_freq = 0
12
+ @height = 0
13
+ end
14
+
15
+ attr_accessor :items
16
+ attr_accessor :keys
17
+ attr_accessor :top_freq
18
+ attr_accessor :height
19
+
20
+ protected
21
+
22
+ attr_accessor :cols
23
+ attr_accessor :v
24
+ attr_accessor :indexed_table
25
+
26
+ public
27
+
28
+ def add_column(i)
29
+ @cols.push(i)
30
+ end
31
+
32
+ def index_table(t)
33
+ @indexed_table = t
34
+ begin
35
+ _g1 = 0
36
+ _g = t.get_height
37
+ while(_g1 < _g)
38
+ i = _g1
39
+ _g1+=1
40
+ key = nil
41
+ if @keys.length > i
42
+ key = @keys[i]
43
+ else
44
+ key = self.to_key(t,i)
45
+ @keys.push(key)
46
+ end
47
+ item = @items[key]
48
+ if item == nil
49
+ item = ::Coopy::IndexItem.new
50
+ @items[key] = item
51
+ end
52
+ ct = item.add(i)
53
+ @top_freq = ct if ct > @top_freq
54
+ end
55
+ end
56
+ @height = t.get_height
57
+ end
58
+
59
+ def to_key(t,i)
60
+ wide = ""
61
+ @v = t.get_cell_view if @v == nil
62
+ begin
63
+ _g1 = 0
64
+ _g = @cols.length
65
+ while(_g1 < _g)
66
+ k = _g1
67
+ _g1+=1
68
+ d = t.get_cell(@cols[k],i)
69
+ txt = @v.to_s(d)
70
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
71
+ wide += " // " if k > 0
72
+ wide += txt
73
+ end
74
+ end
75
+ return wide
76
+ end
77
+
78
+ def to_key_by_content(row)
79
+ wide = ""
80
+ begin
81
+ _g1 = 0
82
+ _g = @cols.length
83
+ while(_g1 < _g)
84
+ k = _g1
85
+ _g1+=1
86
+ txt = row.get_row_string(@cols[k])
87
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
88
+ wide += " // " if k > 0
89
+ wide += txt
90
+ end
91
+ end
92
+ return wide
93
+ end
94
+
95
+ def get_table
96
+ return @indexed_table
97
+ end
98
+
99
+ end
100
+
101
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class IndexItem
6
+
7
+ def initialize
8
+ end
9
+
10
+ attr_accessor :lst
11
+
12
+ def add(i)
13
+ @lst = Array.new if @lst == nil
14
+ @lst.push(i)
15
+ return @lst.length
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class IndexPair
6
+
7
+ def initialize
8
+ @ia = ::Coopy::Index.new
9
+ @ib = ::Coopy::Index.new
10
+ @quality = 0
11
+ end
12
+
13
+ protected
14
+
15
+ attr_accessor :ia
16
+ attr_accessor :ib
17
+ attr_accessor :quality
18
+
19
+ public
20
+
21
+ def add_column(i)
22
+ @ia.add_column(i)
23
+ @ib.add_column(i)
24
+ end
25
+
26
+ def add_columns(ca,cb)
27
+ @ia.add_column(ca)
28
+ @ib.add_column(cb)
29
+ end
30
+
31
+ def index_tables(a,b)
32
+ @ia.index_table(a)
33
+ @ib.index_table(b)
34
+ good = 0
35
+ _it = ::Rb::RubyIterator.new(@ia.items.keys)
36
+ while(_it.has_next) do
37
+ key = _it._next
38
+ item_a = @ia.items[key]
39
+ spot_a = item_a.lst.length
40
+ item_b = @ib.items[key]
41
+ spot_b = 0
42
+ spot_b = item_b.lst.length if item_b != nil
43
+ good+=1 if spot_a == 1 && spot_b == 1
44
+ end
45
+ @quality = good / lambda{|_this_| b1 = a.get_height
46
+ _r2 = [1.0,b1].max}.call(self)
47
+ end
48
+
49
+ protected
50
+
51
+ def query_by_key(ka)
52
+ result = ::Coopy::CrossMatch.new
53
+ result.item_a = @ia.items[ka]
54
+ result.item_b = @ib.items[ka]
55
+ result.spot_a = result.spot_b = 0
56
+ if ka != ""
57
+ result.spot_a = result.item_a.lst.length if result.item_a != nil
58
+ result.spot_b = result.item_b.lst.length if result.item_b != nil
59
+ end
60
+ return result
61
+ end
62
+
63
+ public
64
+
65
+ def query_by_content(row)
66
+ result = ::Coopy::CrossMatch.new
67
+ ka = @ia.to_key_by_content(row)
68
+ return self.query_by_key(ka)
69
+ end
70
+
71
+ def query_local(row)
72
+ ka = @ia.to_key(@ia.get_table,row)
73
+ return self.query_by_key(ka)
74
+ end
75
+
76
+ def get_top_freq
77
+ return @ib.top_freq if @ib.top_freq > @ia.top_freq
78
+ return @ia.top_freq
79
+ end
80
+
81
+ def get_quality
82
+ return @quality
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class Mover
6
+
7
+ def initialize
8
+ end
9
+
10
+ def Mover.move_units(units)
11
+ isrc = Array.new
12
+ idest = Array.new
13
+ len = units.length
14
+ ltop = -1
15
+ rtop = -1
16
+ in_src = {}
17
+ in_dest = {}
18
+ begin
19
+ _g = 0
20
+ while(_g < len)
21
+ i = _g
22
+ _g+=1
23
+ unit = units[i]
24
+ if unit.l >= 0 && unit.r >= 0
25
+ ltop = unit.l if ltop < unit.l
26
+ rtop = unit.r if rtop < unit.r
27
+ begin
28
+ in_src[unit.l] = i
29
+ i
30
+ end
31
+ begin
32
+ in_dest[unit.r] = i
33
+ i
34
+ end
35
+ end
36
+ end
37
+ end
38
+ v = nil
39
+ begin
40
+ _g1 = 0
41
+ _g2 = ltop + 1
42
+ while(_g1 < _g2)
43
+ i1 = _g1
44
+ _g1+=1
45
+ v = in_src[i1]
46
+ isrc.push(v) if v != nil
47
+ end
48
+ end
49
+ begin
50
+ _g11 = 0
51
+ _g3 = rtop + 1
52
+ while(_g11 < _g3)
53
+ i2 = _g11
54
+ _g11+=1
55
+ v = in_dest[i2]
56
+ idest.push(v) if v != nil
57
+ end
58
+ end
59
+ return ::Coopy::Mover.move_without_extras(isrc,idest)
60
+ end
61
+
62
+ def Mover.move_with_extras(isrc,idest)
63
+ len = isrc.length
64
+ len2 = idest.length
65
+ in_src = {}
66
+ in_dest = {}
67
+ begin
68
+ _g = 0
69
+ while(_g < len)
70
+ i = _g
71
+ _g+=1
72
+ begin
73
+ in_src[isrc[i]] = i
74
+ i
75
+ end
76
+ end
77
+ end
78
+ begin
79
+ _g1 = 0
80
+ while(_g1 < len2)
81
+ i1 = _g1
82
+ _g1+=1
83
+ begin
84
+ in_dest[idest[i1]] = i1
85
+ i1
86
+ end
87
+ end
88
+ end
89
+ src = Array.new
90
+ dest = Array.new
91
+ v = nil
92
+ begin
93
+ _g2 = 0
94
+ while(_g2 < len)
95
+ i2 = _g2
96
+ _g2+=1
97
+ v = isrc[i2]
98
+ src.push(v) if in_dest.include?(v)
99
+ end
100
+ end
101
+ begin
102
+ _g3 = 0
103
+ while(_g3 < len2)
104
+ i3 = _g3
105
+ _g3+=1
106
+ v = idest[i3]
107
+ dest.push(v) if in_src.include?(v)
108
+ end
109
+ end
110
+ return ::Coopy::Mover.move_without_extras(src,dest)
111
+ end
112
+
113
+ def Mover.move_without_extras(src,dest)
114
+ return nil if src.length != dest.length
115
+ return [] if src.length <= 1
116
+ len = src.length
117
+ in_src = {}
118
+ blk_len = {}
119
+ blk_src_loc = {}
120
+ blk_dest_loc = {}
121
+ begin
122
+ _g = 0
123
+ while(_g < len)
124
+ i = _g
125
+ _g+=1
126
+ begin
127
+ in_src[src[i]] = i
128
+ i
129
+ end
130
+ end
131
+ end
132
+ ct = 0
133
+ in_cursor = -2
134
+ out_cursor = 0
135
+ _next = nil
136
+ blk = -1
137
+ v = nil
138
+ while(out_cursor < len)
139
+ v = dest[out_cursor]
140
+ _next = in_src[v]
141
+ if _next != in_cursor + 1
142
+ blk = v
143
+ ct = 1
144
+ blk_src_loc[blk] = _next
145
+ blk_dest_loc[blk] = out_cursor
146
+ else
147
+ ct+=1
148
+ end
149
+ blk_len[blk] = ct
150
+ in_cursor = _next
151
+ out_cursor+=1
152
+ end
153
+ blks = Array.new
154
+ _it = ::Rb::RubyIterator.new(blk_len.keys)
155
+ while(_it.has_next) do
156
+ k = _it._next
157
+ blks.push(k)
158
+ end
159
+ blks.sort {|a,b|
160
+ return blk_len[b] - blk_len[a]
161
+ }
162
+ moved = Array.new
163
+ while(blks.length > 0)
164
+ blk1 = blks.shift
165
+ blen = blks.length
166
+ ref_src_loc = blk_src_loc[blk1]
167
+ ref_dest_loc = blk_dest_loc[blk1]
168
+ i1 = blen - 1
169
+ while(i1 >= 0)
170
+ blki = blks[i1]
171
+ blki_src_loc = blk_src_loc[blki]
172
+ to_left_src = blki_src_loc < ref_src_loc
173
+ to_left_dest = blk_dest_loc[blki] < ref_dest_loc
174
+ if to_left_src != to_left_dest
175
+ ct1 = blk_len[blki]
176
+ begin
177
+ _g1 = 0
178
+ while(_g1 < ct1)
179
+ j = _g1
180
+ _g1+=1
181
+ moved.push(src[blki_src_loc])
182
+ blki_src_loc+=1
183
+ end
184
+ end
185
+ blks.slice!(i1,1)
186
+ end
187
+ i1-=1
188
+ end
189
+ end
190
+ return moved
191
+ end
192
+
193
+ end
194
+
195
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class Ordering
6
+
7
+ def initialize
8
+ @order = Array.new
9
+ @ignore_parent = false
10
+ end
11
+
12
+ protected
13
+
14
+ attr_accessor :order
15
+ attr_accessor :ignore_parent
16
+
17
+ public
18
+
19
+ def add(l,r,p = -2)
20
+ p = -2 if @ignore_parent
21
+ @order.push(::Coopy::Unit.new(l,r,p))
22
+ end
23
+
24
+ def get_list
25
+ return @order
26
+ end
27
+
28
+ def to_s
29
+ txt = ""
30
+ begin
31
+ _g1 = 0
32
+ _g = @order.length
33
+ while(_g1 < _g)
34
+ i = _g1
35
+ _g1+=1
36
+ txt += ", " if i > 0
37
+ txt += @order[i].to_s
38
+ end
39
+ end
40
+ return txt
41
+ end
42
+
43
+ def ignore_parent
44
+ @ignore_parent = true
45
+ end
46
+
47
+ end
48
+
49
+ end