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,240 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ module Format
6
+ class JsonPrinter
7
+
8
+ def initialize(replacer,space)
9
+ @replacer = replacer
10
+ @indent = space
11
+ @pretty = space != nil
12
+ @nind = 0
13
+ @buf = StringBuf.new
14
+ end
15
+
16
+ # protected - in ruby this doesn't play well with static/inline methods
17
+
18
+ attr_accessor :buf
19
+ attr_accessor :replacer
20
+ attr_accessor :indent
21
+ attr_accessor :pretty
22
+ attr_accessor :nind
23
+
24
+ def write(k,v)
25
+ v = (@replacer).call(k,v) if @replacer != nil
26
+ begin
27
+ _g = Type._typeof(v)
28
+ case(_g.index)
29
+ when 8
30
+ @buf.b += "\"???\"".to_s
31
+ when 4
32
+ self.fields_string(v,Reflect.fields(v))
33
+ when 1
34
+ v1 = v
35
+ @buf.b += v1.to_s
36
+ when 2
37
+ v2 = nil
38
+ if lambda{|_this_| f = v
39
+ _r = f.to_f.finite?}.call(self)
40
+ v2 = v
41
+ else
42
+ v2 = "null"
43
+ end
44
+ @buf.b += v2.to_s
45
+ when 5
46
+ @buf.b += "\"<fun>\"".to_s
47
+ when 6
48
+ c = _g.params[0]
49
+ if c == String
50
+ self.quote(v)
51
+ elsif c == Array
52
+ v3 = v
53
+ @buf.b += [91].pack("U")
54
+ len = v3.length
55
+ last = len - 1
56
+ begin
57
+ _g1 = 0
58
+ while(_g1 < len)
59
+ i = _g1
60
+ _g1+=1
61
+ if i > 0
62
+ @buf.b += [44].pack("U")
63
+ else
64
+ @nind+=1
65
+ end
66
+ @buf.b += [10].pack("U") if @pretty
67
+ if @pretty
68
+ v4 = nil
69
+ begin
70
+ c1 = @indent
71
+ l = @nind * @indent.length
72
+ if c1.length == 0 || "".length >= l
73
+ v4 = ""
74
+ else
75
+ v4 = str_pad("",((l - "".length) / c1.length).ceil * c1.length + "".length,c1,__php__.call("STR_PAD_LEFT"))
76
+ end
77
+ end
78
+ @buf.b += v4.to_s
79
+ end
80
+ self.write(i,v3[i])
81
+ if i == last
82
+ @nind-=1
83
+ @buf.b += [10].pack("U") if @pretty
84
+ if @pretty
85
+ v5 = nil
86
+ begin
87
+ c2 = @indent
88
+ l1 = @nind * @indent.length
89
+ if c2.length == 0 || "".length >= l1
90
+ v5 = ""
91
+ else
92
+ v5 = str_pad("",((l1 - "".length) / c2.length).ceil * c2.length + "".length,c2,__php__.call("STR_PAD_LEFT"))
93
+ end
94
+ end
95
+ @buf.b += v5.to_s
96
+ end
97
+ end
98
+ end
99
+ end
100
+ @buf.b += [93].pack("U")
101
+ elsif c == ::Haxe::Ds::StringMap
102
+ v6 = v
103
+ o = { }
104
+ _it2 = ::Rb::RubyIterator.new(v6.keys)
105
+ while(_it2.has_next) do
106
+ k1 = _it2._next
107
+ value = v6[k1]
108
+ o[k1] = value
109
+ end
110
+ self.fields_string(o,Reflect.fields(o))
111
+ elsif c == Date
112
+ v7 = v
113
+ self.quote(HxOverrides.date_str(v7))
114
+ else
115
+ self.fields_string(v,Reflect.fields(v))
116
+ end
117
+ when 7
118
+ i1 = nil
119
+ begin
120
+ e = v
121
+ i1 = e.index
122
+ end
123
+ begin
124
+ v8 = i1
125
+ @buf.b += v8.to_s
126
+ end
127
+ when 3
128
+ v9 = v
129
+ @buf.b += v9.to_s
130
+ when 0
131
+ @buf.b += "null".to_s
132
+ end
133
+ end
134
+ end
135
+
136
+ def fields_string(v,fields)
137
+ @buf.b += [123].pack("U")
138
+ len = fields.length
139
+ last = len - 1
140
+ first = true
141
+ begin
142
+ _g = 0
143
+ while(_g < len)
144
+ i = _g
145
+ _g+=1
146
+ f = fields[i]
147
+ value = Reflect.field(v,f)
148
+ next if Reflect.is_function(value)
149
+ if first
150
+ @nind+=1
151
+ first = false
152
+ else
153
+ @buf.b += [44].pack("U")
154
+ end
155
+ @buf.b += [10].pack("U") if @pretty
156
+ if @pretty
157
+ v1 = nil
158
+ begin
159
+ c = @indent
160
+ l = @nind * @indent.length
161
+ if c.length == 0 || "".length >= l
162
+ v1 = ""
163
+ else
164
+ v1 = str_pad("",((l - "".length) / c.length).ceil * c.length + "".length,c,__php__.call("STR_PAD_LEFT"))
165
+ end
166
+ end
167
+ @buf.b += v1.to_s
168
+ end
169
+ self.quote(f)
170
+ @buf.b += [58].pack("U")
171
+ @buf.b += [32].pack("U") if @pretty
172
+ self.write(f,value)
173
+ if i == last
174
+ @nind-=1
175
+ @buf.b += [10].pack("U") if @pretty
176
+ if @pretty
177
+ v2 = nil
178
+ begin
179
+ c1 = @indent
180
+ l1 = @nind * @indent.length
181
+ if c1.length == 0 || "".length >= l1
182
+ v2 = ""
183
+ else
184
+ v2 = str_pad("",((l1 - "".length) / c1.length).ceil * c1.length + "".length,c1,__php__.call("STR_PAD_LEFT"))
185
+ end
186
+ end
187
+ @buf.b += v2.to_s
188
+ end
189
+ end
190
+ end
191
+ end
192
+ @buf.b += [125].pack("U")
193
+ end
194
+
195
+ def quote(s)
196
+ @buf.b += [34].pack("U")
197
+ i = 0
198
+ while(true)
199
+ c = nil
200
+ begin
201
+ index = i
202
+ i+=1
203
+ c = (s[index] || 0).ord
204
+ end
205
+ break if c == 0
206
+ case(c)
207
+ when 34
208
+ @buf.b += "\\\"".to_s
209
+ when 92
210
+ @buf.b += "\\\\".to_s
211
+ when 10
212
+ @buf.b += "\\n".to_s
213
+ when 13
214
+ @buf.b += "\\r".to_s
215
+ when 9
216
+ @buf.b += "\\t".to_s
217
+ when 8
218
+ @buf.b += "\\b".to_s
219
+ when 12
220
+ @buf.b += "\\f".to_s
221
+ else
222
+ @buf.b += [c].pack("U")
223
+ end
224
+ end
225
+ @buf.b += [34].pack("U")
226
+ end
227
+
228
+ public
229
+
230
+ def JsonPrinter._print(o,replacer = nil,space = nil)
231
+ printer = ::Haxe::Format::JsonPrinter.new(replacer,space)
232
+ printer.write("",o)
233
+ printer.buf.b
234
+ end
235
+
236
+ haxe_me ["haxe", "format", "JsonPrinter"]
237
+ end
238
+
239
+ end
240
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ class IMap
6
+ def get(k) puts "Abstract IMap.get called" end
7
+ haxe_me ["haxe", "IMap"]
8
+ end
9
+
10
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ module Io
6
+ class Bytes
7
+
8
+ def initialize(length,b)
9
+ @length = length
10
+ @b = b
11
+ end
12
+
13
+ attr_accessor :length
14
+
15
+ # protected - in ruby this doesn't play well with static/inline methods
16
+
17
+ attr_accessor :b
18
+
19
+ public
20
+
21
+ def get_string(pos,len)
22
+ raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > @length
23
+ @b.byteslice(pos,len)
24
+ end
25
+
26
+ def Bytes.of_string(s)
27
+ ::Haxe::Io::Bytes.new(s.bytesize,s)
28
+ end
29
+
30
+ haxe_me ["haxe", "io", "Bytes"]
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ module Io
6
+ class Eof
7
+
8
+ protected
9
+
10
+ def to_s
11
+ "Eof"
12
+ end
13
+
14
+ haxe_me ["haxe", "io", "Eof"]
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ module Io
6
+ class Error
7
+ ISENUM__ = true
8
+ attr_accessor :tag
9
+ attr_accessor :index
10
+ attr_accessor :params
11
+ def initialize(t,index,p = nil ) @tag = t; @index = index; @params = p; end
12
+
13
+ def Error.blocked() Error.new("Blocked",0) end
14
+ def Error.custom(e) Error.new("Custom",3,[e]) end
15
+ def Error.outside_bounds() Error.new("OutsideBounds",2) end
16
+ def Error.overflow() Error.new("Overflow",1) end
17
+ CONSTRUCTS__ = ["Blocked","Overflow","OutsideBounds","Custom"]
18
+ def ==(a) (!a.nil?) && (a.respond_to? 'ISENUM__') && a.tag === @tag && a.index === @index && a.params == @params end
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Haxe
5
+ module Io
6
+ class Output
7
+
8
+ def write_byte(c)
9
+ raise hx_raise("Not implemented")
10
+ end
11
+
12
+ def write_bytes(s,pos,len)
13
+ k = len
14
+ b = s.b
15
+ raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > s.length
16
+ while(k > 0)
17
+ self.write_byte(b[pos])
18
+ pos+=1
19
+ k-=1
20
+ end
21
+ len
22
+ end
23
+
24
+ def write_full_bytes(s,pos,len)
25
+ while(len > 0)
26
+ k = self.write_bytes(s,pos,len)
27
+ pos += k
28
+ len -= k
29
+ end
30
+ end
31
+
32
+ def write_string(s)
33
+ b = ::Haxe::Io::Bytes.of_string(s)
34
+ self.write_full_bytes(b,0,b.length)
35
+ end
36
+
37
+ haxe_me ["haxe", "io", "Output"]
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class HxOverrides
5
+
6
+ # protected - in ruby this doesn't play well with static/inline methods
7
+
8
+ def HxOverrides.date_str(date)
9
+ m = date.get_month + 1
10
+ d = date.get_date
11
+ h = date.get_hours
12
+ mi = date.get_minutes
13
+ s = date.get_seconds
14
+ _hx_str(date.get_full_year) + "-" + _hx_str((((m < 10) ? "0" + _hx_str(m) : "" + _hx_str(m)))) + "-" + _hx_str((((d < 10) ? "0" + _hx_str(d) : "" + _hx_str(d)))) + " " + _hx_str((((h < 10) ? "0" + _hx_str(h) : "" + _hx_str(h)))) + ":" + _hx_str((((mi < 10) ? "0" + _hx_str(mi) : "" + _hx_str(mi)))) + ":" + _hx_str((((s < 10) ? "0" + _hx_str(s) : "" + _hx_str(s))))
15
+ end
16
+
17
+ haxe_me ["HxOverrides"]
18
+ end
19
+
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class HxSys
5
+
6
+ def HxSys.args
7
+ ARGV
8
+ end
9
+
10
+ def HxSys.get_env(s)
11
+ getenv(s)
12
+ end
13
+
14
+ # protected - in ruby this doesn't play well with static/inline methods
15
+
16
+ def HxSys.escape_argument(arg)
17
+ ok = true
18
+ begin
19
+ _g1 = 0
20
+ _g = arg.length
21
+ while(_g1 < _g)
22
+ i = _g1
23
+ _g1+=1
24
+ _g2 = (arg[i].ord rescue nil)
25
+ case(_g2)
26
+ when 32,34
27
+ ok = false
28
+ when 0,13,10
29
+ arg = arg[0,i]
30
+ end if _g2 != nil
31
+ end
32
+ end
33
+ return arg if ok
34
+ "\"" + _hx_str(arg.split("\"").join("\\\"")) + "\""
35
+ end
36
+
37
+ public
38
+
39
+ def HxSys.command(cmd,args = nil)
40
+ if args != nil
41
+ cmd = HxSys.escape_argument(cmd)
42
+ begin
43
+ _g = 0
44
+ while(_g < args.length)
45
+ a = args[_g]
46
+ _g+=1
47
+ cmd += " " + _hx_str(HxSys.escape_argument(a))
48
+ end
49
+ end
50
+ end
51
+ result = nil
52
+ if system(cmd)
53
+ result = 0
54
+ else
55
+ result = 1
56
+ end
57
+ result
58
+ end
59
+
60
+ def HxSys.exit(code)
61
+ Kernel.exit(code)
62
+ end
63
+
64
+ def HxSys.stdout
65
+ ::Sys::Io::FileOutput.new(STDOUT)
66
+ end
67
+
68
+ def HxSys.stderr
69
+ ::Sys::Io::FileOutput.new(STDERR)
70
+ end
71
+
72
+ haxe_me ["Sys"]
73
+ end
74
+