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,38 @@
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
+ "(" + _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
+ end
34
+
35
+ haxe_me ["coopy", "HighlightPatchUnit"]
36
+ end
37
+
38
+ end
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class Index
6
+
7
+ def initialize(flags)
8
+ @items = {}
9
+ @cols = Array.new
10
+ @keys = Array.new
11
+ @top_freq = 0
12
+ @height = 0
13
+ @hdr = 0
14
+ @ignore_whitespace = false
15
+ @ignore_case = false
16
+ if flags != nil
17
+ @ignore_whitespace = flags.ignore_whitespace
18
+ @ignore_case = flags.ignore_case
19
+ end
20
+ end
21
+
22
+ attr_accessor :items
23
+ attr_accessor :keys
24
+ attr_accessor :top_freq
25
+ attr_accessor :height
26
+
27
+ protected
28
+
29
+ attr_accessor :cols
30
+ attr_accessor :v
31
+ attr_accessor :indexed_table
32
+ attr_accessor :hdr
33
+ attr_accessor :ignore_whitespace
34
+ attr_accessor :ignore_case
35
+
36
+ public
37
+
38
+ def add_column(i)
39
+ @cols.push(i)
40
+ end
41
+
42
+ def index_table(t,hdr)
43
+ @indexed_table = t
44
+ @hdr = hdr
45
+ @keys[t.get_height - 1] = nil if @keys.length != t.get_height && t.get_height > 0
46
+ begin
47
+ _g1 = 0
48
+ _g = t.get_height
49
+ while(_g1 < _g)
50
+ i = _g1
51
+ _g1+=1
52
+ key = @keys[i]
53
+ if key == nil
54
+ key = self.to_key(t,i)
55
+ @keys[i] = key
56
+ end
57
+ item = @items[key]
58
+ if item == nil
59
+ item = ::Coopy::IndexItem.new
60
+ @items[key] = item
61
+ end
62
+ ct = nil
63
+ begin
64
+ item.lst = Array.new if item.lst == nil
65
+ item.lst.push(i)
66
+ ct = item.lst.length
67
+ end
68
+ @top_freq = ct if ct > @top_freq
69
+ end
70
+ end
71
+ @height = t.get_height
72
+ end
73
+
74
+ def to_key(t,i)
75
+ wide = nil
76
+ if i < @hdr
77
+ wide = "_"
78
+ else
79
+ wide = ""
80
+ end
81
+ @v = t.get_cell_view if @v == nil
82
+ begin
83
+ _g1 = 0
84
+ _g = @cols.length
85
+ while(_g1 < _g)
86
+ k = _g1
87
+ _g1+=1
88
+ d = t.get_cell(@cols[k],i)
89
+ txt = @v.to_s(d)
90
+ txt = txt.strip if @ignore_whitespace
91
+ txt = txt.downcase if @ignore_case
92
+ wide += " // " if k > 0
93
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
94
+ wide += txt
95
+ end
96
+ end
97
+ wide
98
+ end
99
+
100
+ def to_key_by_content(row)
101
+ wide = nil
102
+ if row.is_preamble
103
+ wide = "_"
104
+ else
105
+ wide = ""
106
+ end
107
+ begin
108
+ _g1 = 0
109
+ _g = @cols.length
110
+ while(_g1 < _g)
111
+ k = _g1
112
+ _g1+=1
113
+ txt = row.get_row_string(@cols[k])
114
+ txt = txt.strip if @ignore_whitespace
115
+ txt = txt.downcase if @ignore_case
116
+ wide += " // " if k > 0
117
+ next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
118
+ wide += txt
119
+ end
120
+ end
121
+ wide
122
+ end
123
+
124
+ def get_table
125
+ @indexed_table
126
+ end
127
+
128
+ haxe_me ["coopy", "Index"]
129
+ end
130
+
131
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class IndexItem
6
+
7
+ def initialize
8
+ end
9
+
10
+ # protected - in ruby this doesn't play well with static/inline methods
11
+
12
+ attr_accessor :lst
13
+
14
+ public
15
+
16
+ def add(i)
17
+ @lst = Array.new if @lst == nil
18
+ @lst.push(i)
19
+ @lst.length
20
+ end
21
+
22
+ def length
23
+ @lst.length
24
+ end
25
+
26
+ def value
27
+ @lst[0]
28
+ end
29
+
30
+ def as_list
31
+ @lst
32
+ end
33
+
34
+ haxe_me ["coopy", "IndexItem"]
35
+ end
36
+
37
+ end
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class IndexPair
6
+
7
+ def initialize(flags)
8
+ @flags = flags
9
+ @ia = ::Coopy::Index.new(flags)
10
+ @ib = ::Coopy::Index.new(flags)
11
+ @quality = 0
12
+ @hdr = 0
13
+ end
14
+
15
+ protected
16
+
17
+ attr_accessor :ia
18
+ attr_accessor :ib
19
+ attr_accessor :hdr
20
+ attr_accessor :quality
21
+ attr_accessor :flags
22
+
23
+ public
24
+
25
+ def add_columns(ca,cb)
26
+ @ia.add_column(ca)
27
+ @ib.add_column(cb)
28
+ end
29
+
30
+ def index_tables(a,b,hdr)
31
+ @ia.index_table(a,hdr)
32
+ @ib.index_table(b,hdr)
33
+ @hdr = hdr
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
+ 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
+ self.query_by_key(ka)
69
+ end
70
+
71
+ def query_local(row)
72
+ ka = @ia.to_key(@ia.get_table,row)
73
+ self.query_by_key(ka)
74
+ end
75
+
76
+ def local_key(row)
77
+ @ia.to_key(@ia.get_table,row)
78
+ end
79
+
80
+ def remote_key(row)
81
+ @ib.to_key(@ib.get_table,row)
82
+ end
83
+
84
+ def get_top_freq
85
+ return @ib.top_freq if @ib.top_freq > @ia.top_freq
86
+ @ia.top_freq
87
+ end
88
+
89
+ def get_quality
90
+ @quality
91
+ end
92
+
93
+ haxe_me ["coopy", "IndexPair"]
94
+ end
95
+
96
+ end
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Coopy
5
+ class JsonTable
6
+
7
+ def initialize(data,name)
8
+ @data = data
9
+ @columns = Reflect.field(data,"columns")
10
+ @rows = Reflect.field(data,"rows")
11
+ @w = @columns.length
12
+ @h = @rows.length
13
+ @idx2col = {}
14
+ begin
15
+ _g1 = 0
16
+ _g = @columns.length
17
+ while(_g1 < _g)
18
+ idx = _g1
19
+ _g1+=1
20
+ begin
21
+ v = @columns[idx]
22
+ @idx2col[idx] = v
23
+ v
24
+ end
25
+ end
26
+ end
27
+ @name = name
28
+ end
29
+
30
+ protected
31
+
32
+ attr_accessor :w
33
+ attr_accessor :h
34
+ attr_accessor :columns
35
+ attr_accessor :rows
36
+ attr_accessor :data
37
+ attr_accessor :idx2col
38
+ attr_accessor :name
39
+
40
+ public
41
+
42
+ def get_table
43
+ self
44
+ end
45
+
46
+ def height() get_height end
47
+ def height=(__v) @height = __v end
48
+ def width() get_width end
49
+ def width=(__v) @width = __v end
50
+
51
+ def get_width
52
+ @w
53
+ end
54
+
55
+ def get_height
56
+ @h + 1
57
+ end
58
+
59
+ def get_cell(x,y)
60
+ return @idx2col[x] if y == 0
61
+ Reflect.field(@rows[y - 1],@idx2col[x])
62
+ end
63
+
64
+ def set_cell(x,y,c)
65
+ puts "JsonTable is read-only"
66
+ end
67
+
68
+ def to_s
69
+ ""
70
+ end
71
+
72
+ def get_cell_view
73
+ ::Coopy::SimpleView.new
74
+ end
75
+
76
+ def is_resizable
77
+ false
78
+ end
79
+
80
+ def resize(w,h)
81
+ false
82
+ end
83
+
84
+ def clear
85
+ end
86
+
87
+ def insert_or_delete_rows(fate,hfate)
88
+ false
89
+ end
90
+
91
+ def insert_or_delete_columns(fate,wfate)
92
+ false
93
+ end
94
+
95
+ def trim_blank
96
+ false
97
+ end
98
+
99
+ def get_data
100
+ nil
101
+ end
102
+
103
+ def clone
104
+ nil
105
+ end
106
+
107
+ def set_meta(meta)
108
+ end
109
+
110
+ def get_meta
111
+ self
112
+ end
113
+
114
+ def create
115
+ nil
116
+ end
117
+
118
+ def alter_columns(columns)
119
+ false
120
+ end
121
+
122
+ def change_row(rc)
123
+ false
124
+ end
125
+
126
+ def apply_flags(flags)
127
+ false
128
+ end
129
+
130
+ def as_table
131
+ nil
132
+ end
133
+
134
+ def clone_meta(table = nil)
135
+ nil
136
+ end
137
+
138
+ def use_for_column_changes
139
+ false
140
+ end
141
+
142
+ def use_for_row_changes
143
+ false
144
+ end
145
+
146
+ def get_row_stream
147
+ nil
148
+ end
149
+
150
+ def is_nested
151
+ false
152
+ end
153
+
154
+ def is_sql
155
+ false
156
+ end
157
+
158
+ def get_name
159
+ @name
160
+ end
161
+
162
+ haxe_me ["coopy", "JsonTable"]
163
+ end
164
+
165
+ end