everypolitician-daff 1.3.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +252 -0
- data/bin/daff.rb +3 -0
- data/lib/daff.rb +150 -0
- data/lib/lib/coopy/alignment.rb +307 -0
- data/lib/lib/coopy/cell_builder.rb +17 -0
- data/lib/lib/coopy/cell_info.rb +33 -0
- data/lib/lib/coopy/column_change.rb +16 -0
- data/lib/lib/coopy/combined_table.rb +127 -0
- data/lib/lib/coopy/combined_table_body.rb +151 -0
- data/lib/lib/coopy/combined_table_head.rb +103 -0
- data/lib/lib/coopy/compare_flags.rb +127 -0
- data/lib/lib/coopy/compare_table.rb +688 -0
- data/lib/lib/coopy/conflict_info.rb +23 -0
- data/lib/lib/coopy/coopy.rb +1065 -0
- data/lib/lib/coopy/cross_match.rb +17 -0
- data/lib/lib/coopy/csv.rb +290 -0
- data/lib/lib/coopy/diff_render.rb +339 -0
- data/lib/lib/coopy/diff_summary.rb +28 -0
- data/lib/lib/coopy/flat_cell_builder.rb +75 -0
- data/lib/lib/coopy/highlight_patch.rb +977 -0
- data/lib/lib/coopy/highlight_patch_unit.rb +38 -0
- data/lib/lib/coopy/index.rb +131 -0
- data/lib/lib/coopy/index_item.rb +37 -0
- data/lib/lib/coopy/index_pair.rb +96 -0
- data/lib/lib/coopy/json_table.rb +165 -0
- data/lib/lib/coopy/json_tables.rb +129 -0
- data/lib/lib/coopy/merger.rb +197 -0
- data/lib/lib/coopy/meta.rb +20 -0
- data/lib/lib/coopy/mover.rb +197 -0
- data/lib/lib/coopy/ndjson.rb +134 -0
- data/lib/lib/coopy/nested_cell_builder.rb +74 -0
- data/lib/lib/coopy/ordering.rb +54 -0
- data/lib/lib/coopy/property_change.rb +16 -0
- data/lib/lib/coopy/row.rb +11 -0
- data/lib/lib/coopy/row_change.rb +42 -0
- data/lib/lib/coopy/row_stream.rb +11 -0
- data/lib/lib/coopy/simple_meta.rb +314 -0
- data/lib/lib/coopy/simple_table.rb +345 -0
- data/lib/lib/coopy/simple_view.rb +70 -0
- data/lib/lib/coopy/sparse_sheet.rb +51 -0
- data/lib/lib/coopy/sql_column.rb +47 -0
- data/lib/lib/coopy/sql_compare.rb +605 -0
- data/lib/lib/coopy/sql_database.rb +21 -0
- data/lib/lib/coopy/sql_helper.rb +17 -0
- data/lib/lib/coopy/sql_table.rb +335 -0
- data/lib/lib/coopy/sql_table_name.rb +23 -0
- data/lib/lib/coopy/sql_tables.rb +128 -0
- data/lib/lib/coopy/sqlite_helper.rb +316 -0
- data/lib/lib/coopy/table.rb +24 -0
- data/lib/lib/coopy/table_comparison_state.rb +50 -0
- data/lib/lib/coopy/table_diff.rb +1185 -0
- data/lib/lib/coopy/table_io.rb +72 -0
- data/lib/lib/coopy/table_modifier.rb +40 -0
- data/lib/lib/coopy/table_stream.rb +102 -0
- data/lib/lib/coopy/table_view.rb +148 -0
- data/lib/lib/coopy/tables.rb +52 -0
- data/lib/lib/coopy/terminal_diff_render.rb +213 -0
- data/lib/lib/coopy/unit.rb +93 -0
- data/lib/lib/coopy/view.rb +20 -0
- data/lib/lib/coopy/viterbi.rb +177 -0
- data/lib/lib/haxe/ds/int_map.rb +19 -0
- data/lib/lib/haxe/ds/string_map.rb +19 -0
- data/lib/lib/haxe/format/json_parser.rb +265 -0
- data/lib/lib/haxe/format/json_printer.rb +240 -0
- data/lib/lib/haxe/imap.rb +10 -0
- data/lib/lib/haxe/io/bytes.rb +34 -0
- data/lib/lib/haxe/io/eof.rb +18 -0
- data/lib/lib/haxe/io/error.rb +22 -0
- data/lib/lib/haxe/io/output.rb +41 -0
- data/lib/lib/hx_overrides.rb +19 -0
- data/lib/lib/hx_sys.rb +74 -0
- data/lib/lib/lambda.rb +37 -0
- data/lib/lib/list.rb +36 -0
- data/lib/lib/math.rb +5 -0
- data/lib/lib/rb/boot.rb +39 -0
- data/lib/lib/rb/ruby_iterator.rb +50 -0
- data/lib/lib/reflect.rb +41 -0
- data/lib/lib/std.rb +12 -0
- data/lib/lib/string_buf.rb +19 -0
- data/lib/lib/sys/io/file_handle.rb +18 -0
- data/lib/lib/sys/io/file_output.rb +36 -0
- data/lib/lib/sys/io/hx_file.rb +20 -0
- data/lib/lib/type.rb +37 -0
- data/lib/lib/value_type.rb +23 -0
- data/lib/lib/x_list/list_iterator.rb +32 -0
- metadata +235 -0
@@ -0,0 +1,345 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SimpleTable
|
6
|
+
|
7
|
+
def initialize(w,h)
|
8
|
+
@data = {}
|
9
|
+
@w = w
|
10
|
+
@h = h
|
11
|
+
@meta = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
15
|
+
|
16
|
+
attr_accessor :data
|
17
|
+
attr_accessor :w
|
18
|
+
attr_accessor :h
|
19
|
+
attr_accessor :meta
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
def get_table
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def height() get_height end
|
28
|
+
def height=(__v) @height = __v end
|
29
|
+
def width() get_width end
|
30
|
+
def width=(__v) @width = __v end
|
31
|
+
|
32
|
+
def get_width
|
33
|
+
@w
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_height
|
37
|
+
@h
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_cell(x,y)
|
41
|
+
@data[x + y * @w]
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_cell(x,y,c)
|
45
|
+
value = c
|
46
|
+
begin
|
47
|
+
value1 = value
|
48
|
+
@data[x + y * @w] = value1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_s
|
53
|
+
::Coopy::SimpleTable.table_to_string(self)
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_cell_view
|
57
|
+
::Coopy::SimpleView.new
|
58
|
+
end
|
59
|
+
|
60
|
+
def is_resizable
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
def resize(w,h)
|
65
|
+
@w = w
|
66
|
+
@h = h
|
67
|
+
true
|
68
|
+
end
|
69
|
+
|
70
|
+
def clear
|
71
|
+
@data = {}
|
72
|
+
end
|
73
|
+
|
74
|
+
def insert_or_delete_rows(fate,hfate)
|
75
|
+
data2 = {}
|
76
|
+
begin
|
77
|
+
_g1 = 0
|
78
|
+
_g = fate.length
|
79
|
+
while(_g1 < _g)
|
80
|
+
i = _g1
|
81
|
+
_g1+=1
|
82
|
+
j = fate[i]
|
83
|
+
if j != -1
|
84
|
+
_g3 = 0
|
85
|
+
_g2 = @w
|
86
|
+
while(_g3 < _g2)
|
87
|
+
c = _g3
|
88
|
+
_g3+=1
|
89
|
+
idx = i * @w + c
|
90
|
+
if @data.include?(idx)
|
91
|
+
value = @data[idx]
|
92
|
+
begin
|
93
|
+
value1 = value
|
94
|
+
data2[j * @w + c] = value1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
@h = hfate
|
102
|
+
@data = data2
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
def insert_or_delete_columns(fate,wfate)
|
107
|
+
data2 = {}
|
108
|
+
begin
|
109
|
+
_g1 = 0
|
110
|
+
_g = fate.length
|
111
|
+
while(_g1 < _g)
|
112
|
+
i = _g1
|
113
|
+
_g1+=1
|
114
|
+
j = fate[i]
|
115
|
+
if j != -1
|
116
|
+
_g3 = 0
|
117
|
+
_g2 = @h
|
118
|
+
while(_g3 < _g2)
|
119
|
+
r = _g3
|
120
|
+
_g3+=1
|
121
|
+
idx = r * @w + i
|
122
|
+
if @data.include?(idx)
|
123
|
+
value = @data[idx]
|
124
|
+
begin
|
125
|
+
value1 = value
|
126
|
+
data2[r * wfate + j] = value1
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
@w = wfate
|
134
|
+
@data = data2
|
135
|
+
true
|
136
|
+
end
|
137
|
+
|
138
|
+
def trim_blank
|
139
|
+
return true if @h == 0
|
140
|
+
h_test = @h
|
141
|
+
h_test = 3 if h_test >= 3
|
142
|
+
view = self.get_cell_view
|
143
|
+
space = view.to_datum("")
|
144
|
+
more = true
|
145
|
+
while(more)
|
146
|
+
begin
|
147
|
+
_g1 = 0
|
148
|
+
_g = self.get_width
|
149
|
+
while(_g1 < _g)
|
150
|
+
i = _g1
|
151
|
+
_g1+=1
|
152
|
+
c = self.get_cell(i,@h - 1)
|
153
|
+
if !(view.equals(c,space) || c == nil)
|
154
|
+
more = false
|
155
|
+
break
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
@h-=1 if more
|
160
|
+
end
|
161
|
+
more = true
|
162
|
+
nw = @w
|
163
|
+
while(more)
|
164
|
+
break if @w == 0
|
165
|
+
begin
|
166
|
+
_g2 = 0
|
167
|
+
while(_g2 < h_test)
|
168
|
+
i1 = _g2
|
169
|
+
_g2+=1
|
170
|
+
c1 = self.get_cell(nw - 1,i1)
|
171
|
+
if !(view.equals(c1,space) || c1 == nil)
|
172
|
+
more = false
|
173
|
+
break
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
nw-=1 if more
|
178
|
+
end
|
179
|
+
return true if nw == @w
|
180
|
+
data2 = {}
|
181
|
+
begin
|
182
|
+
_g3 = 0
|
183
|
+
while(_g3 < nw)
|
184
|
+
i2 = _g3
|
185
|
+
_g3+=1
|
186
|
+
begin
|
187
|
+
_g21 = 0
|
188
|
+
_g11 = @h
|
189
|
+
while(_g21 < _g11)
|
190
|
+
r = _g21
|
191
|
+
_g21+=1
|
192
|
+
idx = r * @w + i2
|
193
|
+
if @data.include?(idx)
|
194
|
+
value = @data[idx]
|
195
|
+
begin
|
196
|
+
value1 = value
|
197
|
+
data2[r * nw + i2] = value1
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
@w = nw
|
205
|
+
@data = data2
|
206
|
+
true
|
207
|
+
end
|
208
|
+
|
209
|
+
def get_data
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
def clone
|
214
|
+
result = ::Coopy::SimpleTable.new(self.get_width,self.get_height)
|
215
|
+
begin
|
216
|
+
_g1 = 0
|
217
|
+
_g = self.get_height
|
218
|
+
while(_g1 < _g)
|
219
|
+
i = _g1
|
220
|
+
_g1+=1
|
221
|
+
begin
|
222
|
+
_g3 = 0
|
223
|
+
_g2 = self.get_width
|
224
|
+
while(_g3 < _g2)
|
225
|
+
j = _g3
|
226
|
+
_g3+=1
|
227
|
+
result.set_cell(j,i,self.get_cell(j,i))
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
result.meta = @meta.clone_meta(result) if @meta != nil
|
233
|
+
result
|
234
|
+
end
|
235
|
+
|
236
|
+
def create
|
237
|
+
::Coopy::SimpleTable.new(self.get_width,self.get_height)
|
238
|
+
end
|
239
|
+
|
240
|
+
def set_meta(meta)
|
241
|
+
@meta = meta
|
242
|
+
end
|
243
|
+
|
244
|
+
def get_meta
|
245
|
+
@meta
|
246
|
+
end
|
247
|
+
|
248
|
+
def SimpleTable.table_to_string(tab)
|
249
|
+
meta = tab.get_meta
|
250
|
+
if meta != nil
|
251
|
+
stream = meta.get_row_stream
|
252
|
+
if stream != nil
|
253
|
+
x = ""
|
254
|
+
cols = stream.fetch_columns
|
255
|
+
begin
|
256
|
+
_g1 = 0
|
257
|
+
_g = cols.length
|
258
|
+
while(_g1 < _g)
|
259
|
+
i = _g1
|
260
|
+
_g1+=1
|
261
|
+
x += "," if i > 0
|
262
|
+
x += cols[i]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
x += "\n"
|
266
|
+
row = stream.fetch_row
|
267
|
+
while(row != nil)
|
268
|
+
begin
|
269
|
+
_g11 = 0
|
270
|
+
_g2 = cols.length
|
271
|
+
while(_g11 < _g2)
|
272
|
+
i1 = _g11
|
273
|
+
_g11+=1
|
274
|
+
x += "," if i1 > 0
|
275
|
+
begin
|
276
|
+
s = row[cols[i1]]
|
277
|
+
x += s.to_s
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
x += "\n"
|
282
|
+
row = stream.fetch_row
|
283
|
+
end
|
284
|
+
return x
|
285
|
+
end
|
286
|
+
end
|
287
|
+
x1 = ""
|
288
|
+
begin
|
289
|
+
_g12 = 0
|
290
|
+
_g3 = tab.get_height
|
291
|
+
while(_g12 < _g3)
|
292
|
+
i2 = _g12
|
293
|
+
_g12+=1
|
294
|
+
begin
|
295
|
+
_g31 = 0
|
296
|
+
_g21 = tab.get_width
|
297
|
+
while(_g31 < _g21)
|
298
|
+
j = _g31
|
299
|
+
_g31+=1
|
300
|
+
x1 += "," if j > 0
|
301
|
+
begin
|
302
|
+
s1 = tab.get_cell(j,i2)
|
303
|
+
x1 += s1.to_s
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
x1 += "\n"
|
308
|
+
end
|
309
|
+
end
|
310
|
+
x1
|
311
|
+
end
|
312
|
+
|
313
|
+
def SimpleTable.table_is_similar(tab1,tab2)
|
314
|
+
if tab1.get_height == -1 || tab2.get_height == -1
|
315
|
+
txt1 = ::Coopy::SimpleTable.table_to_string(tab1)
|
316
|
+
txt2 = ::Coopy::SimpleTable.table_to_string(tab2)
|
317
|
+
return txt1 == txt2
|
318
|
+
end
|
319
|
+
return false if tab1.get_width != tab2.get_width
|
320
|
+
return false if tab1.get_height != tab2.get_height
|
321
|
+
v = tab1.get_cell_view
|
322
|
+
begin
|
323
|
+
_g1 = 0
|
324
|
+
_g = tab1.get_height
|
325
|
+
while(_g1 < _g)
|
326
|
+
i = _g1
|
327
|
+
_g1+=1
|
328
|
+
begin
|
329
|
+
_g3 = 0
|
330
|
+
_g2 = tab1.get_width
|
331
|
+
while(_g3 < _g2)
|
332
|
+
j = _g3
|
333
|
+
_g3+=1
|
334
|
+
return false if !v.equals(tab1.get_cell(j,i),tab2.get_cell(j,i))
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
true
|
340
|
+
end
|
341
|
+
|
342
|
+
haxe_me ["coopy", "SimpleTable"]
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SimpleView
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_s(d)
|
11
|
+
return "" if d == nil
|
12
|
+
"" + _hx_str(d.to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def equals(d1,d2)
|
16
|
+
return true if d1 == nil && d2 == nil
|
17
|
+
return true if d1 == nil && "" + _hx_str(d2.to_s) == ""
|
18
|
+
return true if "" + _hx_str(d1.to_s) == "" && d2 == nil
|
19
|
+
"" + _hx_str(d1.to_s) == "" + _hx_str(d2.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_datum(x)
|
23
|
+
x
|
24
|
+
end
|
25
|
+
|
26
|
+
def make_hash
|
27
|
+
{}
|
28
|
+
end
|
29
|
+
|
30
|
+
def hash_set(h,str,d)
|
31
|
+
hh = h
|
32
|
+
begin
|
33
|
+
value = d
|
34
|
+
begin
|
35
|
+
value1 = value
|
36
|
+
hh[str] = value1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def hash_exists(h,str)
|
42
|
+
hh = h
|
43
|
+
hh.include?(str)
|
44
|
+
end
|
45
|
+
|
46
|
+
def hash_get(h,str)
|
47
|
+
hh = h
|
48
|
+
hh[str]
|
49
|
+
end
|
50
|
+
|
51
|
+
def is_hash(h)
|
52
|
+
h.respond_to? :keys
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_table(t)
|
56
|
+
Std._is(t,::Coopy::Table)
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_table(t)
|
60
|
+
t
|
61
|
+
end
|
62
|
+
|
63
|
+
def wrap_table(t)
|
64
|
+
t
|
65
|
+
end
|
66
|
+
|
67
|
+
haxe_me ["coopy", "SimpleView"]
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SparseSheet
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@h = @w = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
attr_accessor :h
|
14
|
+
attr_accessor :w
|
15
|
+
attr_accessor :row
|
16
|
+
attr_accessor :zero
|
17
|
+
|
18
|
+
public
|
19
|
+
|
20
|
+
def resize(w,h,zero)
|
21
|
+
@row = {}
|
22
|
+
self.non_destructive_resize(w,h,zero)
|
23
|
+
end
|
24
|
+
|
25
|
+
def non_destructive_resize(w,h,zero)
|
26
|
+
@w = w
|
27
|
+
@h = h
|
28
|
+
@zero = zero
|
29
|
+
end
|
30
|
+
|
31
|
+
def get(x,y)
|
32
|
+
cursor = @row[y]
|
33
|
+
return @zero if cursor == nil
|
34
|
+
val = cursor[x]
|
35
|
+
return @zero if val == nil
|
36
|
+
val
|
37
|
+
end
|
38
|
+
|
39
|
+
def set(x,y,val)
|
40
|
+
cursor = @row[y]
|
41
|
+
if cursor == nil
|
42
|
+
cursor = {}
|
43
|
+
@row[y] = cursor
|
44
|
+
end
|
45
|
+
cursor[x] = val
|
46
|
+
end
|
47
|
+
|
48
|
+
haxe_me ["coopy", "SparseSheet"]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|