everypolitician-daff 1.3.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +252 -0
  3. data/bin/daff.rb +3 -0
  4. data/lib/daff.rb +150 -0
  5. data/lib/lib/coopy/alignment.rb +307 -0
  6. data/lib/lib/coopy/cell_builder.rb +17 -0
  7. data/lib/lib/coopy/cell_info.rb +33 -0
  8. data/lib/lib/coopy/column_change.rb +16 -0
  9. data/lib/lib/coopy/combined_table.rb +127 -0
  10. data/lib/lib/coopy/combined_table_body.rb +151 -0
  11. data/lib/lib/coopy/combined_table_head.rb +103 -0
  12. data/lib/lib/coopy/compare_flags.rb +127 -0
  13. data/lib/lib/coopy/compare_table.rb +688 -0
  14. data/lib/lib/coopy/conflict_info.rb +23 -0
  15. data/lib/lib/coopy/coopy.rb +1065 -0
  16. data/lib/lib/coopy/cross_match.rb +17 -0
  17. data/lib/lib/coopy/csv.rb +290 -0
  18. data/lib/lib/coopy/diff_render.rb +339 -0
  19. data/lib/lib/coopy/diff_summary.rb +28 -0
  20. data/lib/lib/coopy/flat_cell_builder.rb +75 -0
  21. data/lib/lib/coopy/highlight_patch.rb +977 -0
  22. data/lib/lib/coopy/highlight_patch_unit.rb +38 -0
  23. data/lib/lib/coopy/index.rb +131 -0
  24. data/lib/lib/coopy/index_item.rb +37 -0
  25. data/lib/lib/coopy/index_pair.rb +96 -0
  26. data/lib/lib/coopy/json_table.rb +165 -0
  27. data/lib/lib/coopy/json_tables.rb +129 -0
  28. data/lib/lib/coopy/merger.rb +197 -0
  29. data/lib/lib/coopy/meta.rb +20 -0
  30. data/lib/lib/coopy/mover.rb +197 -0
  31. data/lib/lib/coopy/ndjson.rb +134 -0
  32. data/lib/lib/coopy/nested_cell_builder.rb +74 -0
  33. data/lib/lib/coopy/ordering.rb +54 -0
  34. data/lib/lib/coopy/property_change.rb +16 -0
  35. data/lib/lib/coopy/row.rb +11 -0
  36. data/lib/lib/coopy/row_change.rb +42 -0
  37. data/lib/lib/coopy/row_stream.rb +11 -0
  38. data/lib/lib/coopy/simple_meta.rb +314 -0
  39. data/lib/lib/coopy/simple_table.rb +345 -0
  40. data/lib/lib/coopy/simple_view.rb +70 -0
  41. data/lib/lib/coopy/sparse_sheet.rb +51 -0
  42. data/lib/lib/coopy/sql_column.rb +47 -0
  43. data/lib/lib/coopy/sql_compare.rb +605 -0
  44. data/lib/lib/coopy/sql_database.rb +21 -0
  45. data/lib/lib/coopy/sql_helper.rb +17 -0
  46. data/lib/lib/coopy/sql_table.rb +335 -0
  47. data/lib/lib/coopy/sql_table_name.rb +23 -0
  48. data/lib/lib/coopy/sql_tables.rb +128 -0
  49. data/lib/lib/coopy/sqlite_helper.rb +316 -0
  50. data/lib/lib/coopy/table.rb +24 -0
  51. data/lib/lib/coopy/table_comparison_state.rb +50 -0
  52. data/lib/lib/coopy/table_diff.rb +1185 -0
  53. data/lib/lib/coopy/table_io.rb +72 -0
  54. data/lib/lib/coopy/table_modifier.rb +40 -0
  55. data/lib/lib/coopy/table_stream.rb +102 -0
  56. data/lib/lib/coopy/table_view.rb +148 -0
  57. data/lib/lib/coopy/tables.rb +52 -0
  58. data/lib/lib/coopy/terminal_diff_render.rb +213 -0
  59. data/lib/lib/coopy/unit.rb +93 -0
  60. data/lib/lib/coopy/view.rb +20 -0
  61. data/lib/lib/coopy/viterbi.rb +177 -0
  62. data/lib/lib/haxe/ds/int_map.rb +19 -0
  63. data/lib/lib/haxe/ds/string_map.rb +19 -0
  64. data/lib/lib/haxe/format/json_parser.rb +265 -0
  65. data/lib/lib/haxe/format/json_printer.rb +240 -0
  66. data/lib/lib/haxe/imap.rb +10 -0
  67. data/lib/lib/haxe/io/bytes.rb +34 -0
  68. data/lib/lib/haxe/io/eof.rb +18 -0
  69. data/lib/lib/haxe/io/error.rb +22 -0
  70. data/lib/lib/haxe/io/output.rb +41 -0
  71. data/lib/lib/hx_overrides.rb +19 -0
  72. data/lib/lib/hx_sys.rb +74 -0
  73. data/lib/lib/lambda.rb +37 -0
  74. data/lib/lib/list.rb +36 -0
  75. data/lib/lib/math.rb +5 -0
  76. data/lib/lib/rb/boot.rb +39 -0
  77. data/lib/lib/rb/ruby_iterator.rb +50 -0
  78. data/lib/lib/reflect.rb +41 -0
  79. data/lib/lib/std.rb +12 -0
  80. data/lib/lib/string_buf.rb +19 -0
  81. data/lib/lib/sys/io/file_handle.rb +18 -0
  82. data/lib/lib/sys/io/file_output.rb +36 -0
  83. data/lib/lib/sys/io/hx_file.rb +20 -0
  84. data/lib/lib/type.rb +37 -0
  85. data/lib/lib/value_type.rb +23 -0
  86. data/lib/lib/x_list/list_iterator.rb +32 -0
  87. metadata +235 -0
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class SqlDatabase
6
+ def getColumns(name) puts "Abstract SqlDatabase.getColumns called" end
7
+ def getQuotedTableName(name) puts "Abstract SqlDatabase.getQuotedTableName called" end
8
+ def getQuotedColumnName(name) puts "Abstract SqlDatabase.getQuotedColumnName called" end
9
+ def begin(query,args = nil,order = nil) puts "Abstract SqlDatabase.begin called" end
10
+ def beginRow(name,row,order = nil) puts "Abstract SqlDatabase.beginRow called" end
11
+ def read() puts "Abstract SqlDatabase.read called" end
12
+ def get(index) puts "Abstract SqlDatabase.get called" end
13
+ def end() puts "Abstract SqlDatabase.end called" end
14
+ def width() puts "Abstract SqlDatabase.width called" end
15
+ def rowid() puts "Abstract SqlDatabase.rowid called" end
16
+ def getHelper() puts "Abstract SqlDatabase.getHelper called" end
17
+ def getNameForAttachment() puts "Abstract SqlDatabase.getNameForAttachment called" end
18
+ haxe_me ["coopy", "SqlDatabase"]
19
+ end
20
+
21
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class SqlHelper
6
+ def getTableNames(db) puts "Abstract SqlHelper.getTableNames called" end
7
+ def countRows(db,name) puts "Abstract SqlHelper.countRows called" end
8
+ def getRowIDs(db,name) puts "Abstract SqlHelper.getRowIDs called" end
9
+ def insert(db,name,vals) puts "Abstract SqlHelper.insert called" end
10
+ def delete(db,name,conds) puts "Abstract SqlHelper.delete called" end
11
+ def update(db,name,conds,vals) puts "Abstract SqlHelper.update called" end
12
+ def attach(db,tag,resource_name) puts "Abstract SqlHelper.attach called" end
13
+ def alterColumns(db,name,columns) puts "Abstract SqlHelper.alterColumns called" end
14
+ haxe_me ["coopy", "SqlHelper"]
15
+ end
16
+
17
+ end
@@ -0,0 +1,335 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class SqlTable
6
+
7
+ def initialize(db,name,helper = nil)
8
+ @db = db
9
+ @name = name
10
+ @helper = helper
11
+ @helper = db.get_helper if helper == nil
12
+ @cache = {}
13
+ @h = -1
14
+ @id2rid = nil
15
+ self.get_columns
16
+ end
17
+
18
+ protected
19
+
20
+ attr_accessor :db
21
+ attr_accessor :columns
22
+ attr_accessor :name
23
+ attr_accessor :quoted_table_name
24
+ attr_accessor :cache
25
+ attr_accessor :column_names
26
+ attr_accessor :h
27
+ attr_accessor :helper
28
+ attr_accessor :id2rid
29
+
30
+ def get_columns
31
+ return if @columns != nil
32
+ return if @db == nil
33
+ @columns = @db.get_columns(@name)
34
+ @column_names = Array.new
35
+ begin
36
+ _g = 0
37
+ _g1 = @columns
38
+ while(_g < _g1.length)
39
+ col = _g1[_g]
40
+ _g+=1
41
+ @column_names.push(col.get_name)
42
+ end
43
+ end
44
+ end
45
+
46
+ public
47
+
48
+ def get_primary_key
49
+ self.get_columns
50
+ result = Array.new
51
+ begin
52
+ _g = 0
53
+ _g1 = @columns
54
+ while(_g < _g1.length)
55
+ col = _g1[_g]
56
+ _g+=1
57
+ next if !col.is_primary_key
58
+ result.push(col.get_name)
59
+ end
60
+ end
61
+ result
62
+ end
63
+
64
+ def get_all_but_primary_key
65
+ self.get_columns
66
+ result = Array.new
67
+ begin
68
+ _g = 0
69
+ _g1 = @columns
70
+ while(_g < _g1.length)
71
+ col = _g1[_g]
72
+ _g+=1
73
+ next if col.is_primary_key
74
+ result.push(col.get_name)
75
+ end
76
+ end
77
+ result
78
+ end
79
+
80
+ def get_column_names
81
+ self.get_columns
82
+ @column_names
83
+ end
84
+
85
+ def get_quoted_table_name
86
+ return @quoted_table_name if @quoted_table_name != nil
87
+ @quoted_table_name = @db.get_quoted_table_name(@name)
88
+ @quoted_table_name
89
+ end
90
+
91
+ def get_quoted_column_name(name)
92
+ @db.get_quoted_column_name(name)
93
+ end
94
+
95
+ def get_cell(x,y)
96
+ if @h >= 0
97
+ y = y - 1
98
+ y = @id2rid[y] if y >= 0
99
+ elsif y == 0
100
+ y = -1
101
+ end
102
+ if y < 0
103
+ self.get_columns
104
+ return @columns[x].name
105
+ end
106
+ row = @cache[y]
107
+ if row == nil
108
+ row = {}
109
+ self.get_columns
110
+ @db.begin_row(@name,y,@column_names)
111
+ while(@db.read)
112
+ _g1 = 0
113
+ _g = self.get_width
114
+ while(_g1 < _g)
115
+ i = _g1
116
+ _g1+=1
117
+ begin
118
+ v = @db.get(i)
119
+ begin
120
+ value = v
121
+ row[i] = value
122
+ end
123
+ v
124
+ end
125
+ end
126
+ end
127
+ @db._end
128
+ begin
129
+ @cache[y] = row
130
+ row
131
+ end
132
+ end
133
+ begin
134
+ this1 = @cache[y]
135
+ this1.get(x)
136
+ end
137
+ end
138
+
139
+ def set_cell_cache(x,y,c)
140
+ row = @cache[y]
141
+ if row == nil
142
+ row = {}
143
+ self.get_columns
144
+ begin
145
+ @cache[y] = row
146
+ row
147
+ end
148
+ end
149
+ begin
150
+ v = c
151
+ begin
152
+ value = v
153
+ row[x] = value
154
+ end
155
+ v
156
+ end
157
+ end
158
+
159
+ def set_cell(x,y,c)
160
+ puts "SqlTable cannot set cells yet"
161
+ end
162
+
163
+ def get_cell_view
164
+ ::Coopy::SimpleView.new
165
+ end
166
+
167
+ def is_resizable
168
+ false
169
+ end
170
+
171
+ def resize(w,h)
172
+ false
173
+ end
174
+
175
+ def clear
176
+ end
177
+
178
+ def insert_or_delete_rows(fate,hfate)
179
+ false
180
+ end
181
+
182
+ def insert_or_delete_columns(fate,wfate)
183
+ false
184
+ end
185
+
186
+ def trim_blank
187
+ false
188
+ end
189
+
190
+ def height() get_height end
191
+ def height=(__v) @height = __v end
192
+ def width() get_width end
193
+ def width=(__v) @width = __v end
194
+
195
+ def get_width
196
+ self.get_columns
197
+ @columns.length
198
+ end
199
+
200
+ def get_height
201
+ return @h if @h >= 0
202
+ -1
203
+ end
204
+
205
+ def get_data
206
+ nil
207
+ end
208
+
209
+ def clone
210
+ nil
211
+ end
212
+
213
+ def create
214
+ nil
215
+ end
216
+
217
+ def get_meta
218
+ self
219
+ end
220
+
221
+ def alter_columns(columns)
222
+ result = @helper.alter_columns(@db,@name,columns)
223
+ @columns = nil
224
+ result
225
+ end
226
+
227
+ def change_row(rc)
228
+ if @helper == nil
229
+ puts "No sql helper"
230
+ return false
231
+ end
232
+ if rc.action == "+++"
233
+ return @helper.insert(@db,@name,rc.val)
234
+ elsif rc.action == "---"
235
+ return @helper._delete(@db,@name,rc.cond)
236
+ elsif rc.action == "->"
237
+ return @helper.update(@db,@name,rc.cond,rc.val)
238
+ end
239
+ false
240
+ end
241
+
242
+ def as_table
243
+ pct = 3
244
+ self.get_columns
245
+ w = @column_names.length
246
+ mt = ::Coopy::SimpleTable.new(w + 1,pct)
247
+ mt.set_cell(0,0,"@")
248
+ mt.set_cell(0,1,"type")
249
+ mt.set_cell(0,2,"key")
250
+ begin
251
+ _g = 0
252
+ while(_g < w)
253
+ x = _g
254
+ _g+=1
255
+ i = x + 1
256
+ mt.set_cell(i,0,@column_names[x])
257
+ mt.set_cell(i,1,@columns[x].type_value)
258
+ mt.set_cell(i,2,((@columns[x].primary) ? "primary" : ""))
259
+ end
260
+ end
261
+ mt
262
+ end
263
+
264
+ def use_for_column_changes
265
+ true
266
+ end
267
+
268
+ def use_for_row_changes
269
+ true
270
+ end
271
+
272
+ def clone_meta(table = nil)
273
+ nil
274
+ end
275
+
276
+ def apply_flags(flags)
277
+ false
278
+ end
279
+
280
+ def get_database
281
+ @db
282
+ end
283
+
284
+ def get_row_stream
285
+ self.get_columns
286
+ @db._begin("SELECT * FROM " + _hx_str(self.get_quoted_table_name) + " ORDER BY ?",[@db.rowid],@column_names)
287
+ self
288
+ end
289
+
290
+ def is_nested
291
+ false
292
+ end
293
+
294
+ def is_sql
295
+ true
296
+ end
297
+
298
+ def fetch_row
299
+ if @db.read
300
+ row = {}
301
+ begin
302
+ _g1 = 0
303
+ _g = @column_names.length
304
+ while(_g1 < _g)
305
+ i = _g1
306
+ _g1+=1
307
+ begin
308
+ v = @db.get(i)
309
+ begin
310
+ value = v
311
+ row[@column_names[i]] = value
312
+ end
313
+ v
314
+ end
315
+ end
316
+ end
317
+ return row
318
+ end
319
+ @db._end
320
+ nil
321
+ end
322
+
323
+ def fetch_columns
324
+ self.get_columns
325
+ @column_names
326
+ end
327
+
328
+ def get_name
329
+ @name.to_s
330
+ end
331
+
332
+ haxe_me ["coopy", "SqlTable"]
333
+ end
334
+
335
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class SqlTableName
6
+
7
+ def initialize(name = "",prefix = "")
8
+ @name = name
9
+ @prefix = prefix
10
+ end
11
+
12
+ attr_accessor :name
13
+ attr_accessor :prefix
14
+
15
+ def to_s
16
+ return @name if @prefix == ""
17
+ _hx_str(@prefix) + "." + _hx_str(@name)
18
+ end
19
+
20
+ haxe_me ["coopy", "SqlTableName"]
21
+ end
22
+
23
+ end
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class SqlTables
6
+
7
+ def initialize(db,flags)
8
+ @db = db
9
+ helper = @db.get_helper
10
+ names = helper.get_table_names(db)
11
+ allowed = nil
12
+ count = names.length
13
+ if flags.tables != nil
14
+ allowed = {}
15
+ begin
16
+ _g = 0
17
+ _g1 = flags.tables
18
+ while(_g < _g1.length)
19
+ name = _g1[_g]
20
+ _g+=1
21
+ allowed[name] = true
22
+ end
23
+ end
24
+ count = 0
25
+ begin
26
+ _g2 = 0
27
+ while(_g2 < names.length)
28
+ name1 = names[_g2]
29
+ _g2+=1
30
+ count+=1 if allowed.include?(name1)
31
+ end
32
+ end
33
+ end
34
+ @t = ::Coopy::SimpleTable.new(2,count + 1)
35
+ @t.set_cell(0,0,"name")
36
+ @t.set_cell(1,0,"table")
37
+ v = @t.get_cell_view
38
+ at = 1
39
+ begin
40
+ _g3 = 0
41
+ while(_g3 < names.length)
42
+ name2 = names[_g3]
43
+ _g3+=1
44
+ if allowed != nil
45
+ next if !allowed.include?(name2)
46
+ end
47
+ @t.set_cell(0,at,name2)
48
+ @t.set_cell(1,at,v.wrap_table(::Coopy::SqlTable.new(db,::Coopy::SqlTableName.new(name2))))
49
+ at+=1
50
+ end
51
+ end
52
+ end
53
+
54
+ protected
55
+
56
+ attr_accessor :db
57
+ attr_accessor :t
58
+ attr_accessor :flags
59
+
60
+ public
61
+
62
+ def height() get_height end
63
+ def height=(__v) @height = __v end
64
+ def width() get_width end
65
+ def width=(__v) @width = __v end
66
+
67
+ def get_cell(x,y)
68
+ @t.get_cell(x,y)
69
+ end
70
+
71
+ def set_cell(x,y,c)
72
+ end
73
+
74
+ def get_cell_view
75
+ @t.get_cell_view
76
+ end
77
+
78
+ def is_resizable
79
+ false
80
+ end
81
+
82
+ def resize(w,h)
83
+ false
84
+ end
85
+
86
+ def clear
87
+ end
88
+
89
+ def insert_or_delete_rows(fate,hfate)
90
+ false
91
+ end
92
+
93
+ def insert_or_delete_columns(fate,wfate)
94
+ false
95
+ end
96
+
97
+ def trim_blank
98
+ false
99
+ end
100
+
101
+ def get_width
102
+ @t.get_width
103
+ end
104
+
105
+ def get_height
106
+ @t.get_height
107
+ end
108
+
109
+ def get_data
110
+ nil
111
+ end
112
+
113
+ def clone
114
+ nil
115
+ end
116
+
117
+ def create
118
+ nil
119
+ end
120
+
121
+ def get_meta
122
+ ::Coopy::SimpleMeta.new(self,true,true)
123
+ end
124
+
125
+ haxe_me ["coopy", "SqlTables"]
126
+ end
127
+
128
+ end