daff 1.2.6 → 1.3.1
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.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/bin/daff.rb +0 -0
- data/lib/daff.rb +6 -0
- data/lib/lib/coopy/alignment.rb +146 -169
- data/lib/lib/coopy/cell_builder.rb +1 -1
- data/lib/lib/coopy/cell_info.rb +2 -1
- data/lib/lib/coopy/column_change.rb +16 -0
- data/lib/lib/coopy/compare_flags.rb +33 -5
- data/lib/lib/coopy/compare_table.rb +219 -99
- data/lib/lib/coopy/coopy.rb +205 -99
- data/lib/lib/coopy/csv.rb +17 -22
- data/lib/lib/coopy/diff_render.rb +16 -8
- data/lib/lib/coopy/flat_cell_builder.rb +11 -8
- data/lib/lib/coopy/highlight_patch.rb +363 -63
- data/lib/lib/coopy/highlight_patch_unit.rb +1 -1
- data/lib/lib/coopy/index.rb +21 -8
- data/lib/lib/coopy/index_item.rb +7 -3
- data/lib/lib/coopy/index_pair.rb +13 -10
- data/lib/lib/coopy/merger.rb +3 -3
- data/lib/lib/coopy/meta.rb +17 -0
- data/lib/lib/coopy/mover.rb +7 -5
- data/lib/lib/coopy/ndjson.rb +2 -2
- data/lib/lib/coopy/nested_cell_builder.rb +7 -7
- data/lib/lib/coopy/ordering.rb +6 -2
- data/lib/lib/coopy/property_change.rb +16 -0
- data/lib/lib/coopy/row.rb +1 -0
- data/lib/lib/coopy/row_change.rb +42 -0
- data/lib/lib/coopy/row_stream.rb +11 -0
- data/lib/lib/coopy/simple_table.rb +84 -30
- data/lib/lib/coopy/simple_view.rb +8 -8
- data/lib/lib/coopy/sparse_sheet.rb +1 -1
- data/lib/lib/coopy/sql_column.rb +22 -10
- data/lib/lib/coopy/sql_compare.rb +397 -85
- data/lib/lib/coopy/sql_database.rb +2 -0
- data/lib/lib/coopy/sql_helper.rb +5 -0
- data/lib/lib/coopy/sql_table.rb +122 -19
- data/lib/lib/coopy/sql_table_name.rb +1 -1
- data/lib/lib/coopy/sqlite_helper.rb +250 -3
- data/lib/lib/coopy/table.rb +1 -0
- data/lib/lib/coopy/table_diff.rb +643 -464
- data/lib/lib/coopy/table_io.rb +19 -6
- data/lib/lib/coopy/table_modifier.rb +1 -1
- data/lib/lib/coopy/table_stream.rb +102 -0
- data/lib/lib/coopy/terminal_diff_render.rb +4 -3
- data/lib/lib/coopy/unit.rb +22 -2
- data/lib/lib/coopy/viterbi.rb +4 -4
- data/lib/lib/haxe/ds/int_map.rb +1 -1
- data/lib/lib/haxe/ds/string_map.rb +1 -1
- data/lib/lib/haxe/format/json_parser.rb +1 -1
- data/lib/lib/haxe/format/json_printer.rb +1 -1
- data/lib/lib/haxe/io/bytes.rb +2 -2
- data/lib/lib/haxe/io/eof.rb +1 -1
- data/lib/lib/haxe/io/output.rb +1 -1
- data/lib/lib/hx_overrides.rb +1 -1
- data/lib/lib/hx_sys.rb +9 -5
- data/lib/lib/lambda.rb +3 -3
- data/lib/lib/list.rb +1 -1
- data/lib/lib/rb/ruby_iterator.rb +2 -2
- data/lib/lib/reflect.rb +1 -1
- data/lib/lib/sys/io/file_output.rb +1 -1
- data/lib/lib/sys/io/hx_file.rb +1 -1
- data/lib/lib/x_list/list_iterator.rb +2 -2
- metadata +29 -25
- data/lib/lib/coopy/table_text.rb +0 -26
- data/lib/lib/haxe/io/bytes_buffer.rb +0 -19
- data/lib/lib/haxe/io/bytes_input.rb +0 -13
- data/lib/lib/haxe/io/bytes_output.rb +0 -33
- data/lib/lib/haxe/io/input.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 469baec08599142e1445a291410b340d9b621c52
|
4
|
+
data.tar.gz: f9781651f9ca2650d61a1ba5632b2e8e40543b1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc0aa8b457f18094e9d8ed4c9835fee504ecc9875949a4c5e74057821eae741941bf98a75c9c295b520a2f22b1add61dd5099d63f900894bbe63c31cde47888
|
7
|
+
data.tar.gz: 5a510890fe93b6b2d7c771524fe25f811f48a3addb377f97f565aa1f6507caa4069b09900c32c6c26c4242bf83b80dea94d47685472f53f733e44eecdf9333a4
|
data/README.md
CHANGED
@@ -84,7 +84,7 @@ for `*.csv` files in your repository. Run `daff git` for instructions
|
|
84
84
|
on doing this manually. Your CSV diffs and merges will get smarter,
|
85
85
|
since git will suddenly understand about rows and columns, not just lines:
|
86
86
|
|
87
|
-

|
88
88
|
|
89
89
|
The library
|
90
90
|
-----------
|
@@ -181,7 +181,6 @@ patcher.apply();
|
|
181
181
|
For other languages, you should find sample code in
|
182
182
|
the packages on the [Releases](https://github.com/paulfitz/daff/releases) page.
|
183
183
|
|
184
|
-
|
185
184
|
Supported languages
|
186
185
|
-------------------
|
187
186
|
|
@@ -198,10 +197,10 @@ can be translated reasonably well into at least the following languages:
|
|
198
197
|
|
199
198
|
Some translations are done for you on the
|
200
199
|
[Releases](https://github.com/paulfitz/daff/releases) page.
|
201
|
-
To make another translation,
|
202
|
-
follow the
|
203
|
-
|
204
|
-
|
200
|
+
To make another translation, or to compile from source
|
201
|
+
first follow the [Haxe getting started tutorial](http://haxe.org/doc/start) for the
|
202
|
+
language you care about. At the time of writing, if you are on OSX, you should
|
203
|
+
install haxe using `brew install haxe --HEAD`. Then do one of:
|
205
204
|
|
206
205
|
```
|
207
206
|
make js
|
@@ -236,6 +235,7 @@ Reading material
|
|
236
235
|
|
237
236
|
* http://dataprotocols.org/tabular-diff-format/ : a specification of the diff format we use.
|
238
237
|
* http://theodi.org/blog/csvhub-github-diffs-for-csv-files : using this library with github.
|
238
|
+
* https://github.com/ropensci/unconf/issues/19 : a thread about diffing data in which daff shows up in at least four guises (see if you can spot them all).
|
239
239
|
* http://theodi.org/blog/adapting-git-simple-data : using this library with gitlab.
|
240
240
|
* http://okfnlabs.org/blog/2013/08/08/diffing-and-patching-data.html : a summary of where the library came from.
|
241
241
|
* http://blog.okfn.org/2013/07/02/git-and-github-for-data/ : a post about storing small data in git/github.
|
data/bin/daff.rb
CHANGED
File without changes
|
data/lib/daff.rb
CHANGED
@@ -52,6 +52,7 @@ require_relative 'lib/type'
|
|
52
52
|
require_relative 'lib/coopy/alignment'
|
53
53
|
require_relative 'lib/coopy/cell_builder'
|
54
54
|
require_relative 'lib/coopy/cell_info'
|
55
|
+
require_relative 'lib/coopy/column_change'
|
55
56
|
require_relative 'lib/coopy/compare_flags'
|
56
57
|
require_relative 'lib/coopy/compare_table'
|
57
58
|
require_relative 'lib/coopy/coopy'
|
@@ -66,10 +67,14 @@ require_relative 'lib/coopy/index'
|
|
66
67
|
require_relative 'lib/coopy/index_item'
|
67
68
|
require_relative 'lib/coopy/index_pair'
|
68
69
|
require_relative 'lib/coopy/merger'
|
70
|
+
require_relative 'lib/coopy/meta'
|
69
71
|
require_relative 'lib/coopy/mover'
|
70
72
|
require_relative 'lib/coopy/ndjson'
|
71
73
|
require_relative 'lib/coopy/nested_cell_builder'
|
72
74
|
require_relative 'lib/coopy/ordering'
|
75
|
+
require_relative 'lib/coopy/property_change'
|
76
|
+
require_relative 'lib/coopy/row_change'
|
77
|
+
require_relative 'lib/coopy/row_stream'
|
73
78
|
require_relative 'lib/coopy/table'
|
74
79
|
require_relative 'lib/coopy/simple_table'
|
75
80
|
require_relative 'lib/coopy/view'
|
@@ -86,6 +91,7 @@ require_relative 'lib/coopy/table_comparison_state'
|
|
86
91
|
require_relative 'lib/coopy/table_diff'
|
87
92
|
require_relative 'lib/coopy/table_io'
|
88
93
|
require_relative 'lib/coopy/table_modifier'
|
94
|
+
require_relative 'lib/coopy/table_stream'
|
89
95
|
require_relative 'lib/coopy/terminal_diff_render'
|
90
96
|
require_relative 'lib/coopy/unit'
|
91
97
|
require_relative 'lib/coopy/viterbi'
|
data/lib/lib/coopy/alignment.rb
CHANGED
@@ -55,8 +55,8 @@ module Coopy
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def link(a,b)
|
58
|
-
@map_a2b[a] = b
|
59
|
-
@map_b2a[b] = a
|
58
|
+
@map_a2b[a] = b if a != -1
|
59
|
+
@map_b2a[b] = a if b != -1
|
60
60
|
@map_count+=1
|
61
61
|
end
|
62
62
|
|
@@ -66,23 +66,25 @@ module Coopy
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def get_index_columns
|
69
|
-
|
69
|
+
@index_columns
|
70
70
|
end
|
71
71
|
|
72
72
|
def a2b(a)
|
73
|
-
|
73
|
+
@map_a2b[a]
|
74
74
|
end
|
75
75
|
|
76
76
|
def b2a(b)
|
77
|
-
|
77
|
+
@map_b2a[b]
|
78
78
|
end
|
79
79
|
|
80
80
|
def count
|
81
|
-
|
81
|
+
@map_count
|
82
82
|
end
|
83
83
|
|
84
84
|
def to_s
|
85
|
-
|
85
|
+
result = "" + "not implemented yet" + " // " + "not implemented yet"
|
86
|
+
result += " (" + _hx_str(@reference.to_s) + ")" if @reference != nil
|
87
|
+
result
|
86
88
|
end
|
87
89
|
|
88
90
|
def to_order
|
@@ -93,7 +95,7 @@ module Coopy
|
|
93
95
|
end
|
94
96
|
@order_cache = self.to_order3 if @order_cache == nil
|
95
97
|
@order_cache_has_reference = true if @reference != nil
|
96
|
-
|
98
|
+
@order_cache
|
97
99
|
end
|
98
100
|
|
99
101
|
def add_to_order(l,r,p = -2)
|
@@ -103,201 +105,176 @@ module Coopy
|
|
103
105
|
end
|
104
106
|
|
105
107
|
def get_source
|
106
|
-
|
108
|
+
@ta
|
107
109
|
end
|
108
110
|
|
109
111
|
def get_target
|
110
|
-
|
112
|
+
@tb
|
111
113
|
end
|
112
114
|
|
113
115
|
def get_source_header
|
114
|
-
|
116
|
+
@ia
|
115
117
|
end
|
116
118
|
|
117
119
|
def get_target_header
|
118
|
-
|
120
|
+
@ib
|
119
121
|
end
|
120
122
|
|
121
123
|
protected
|
122
124
|
|
123
125
|
def to_order3
|
124
|
-
|
125
|
-
if
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
order = Array.new
|
127
|
+
if @reference == nil
|
128
|
+
_it = ::Rb::RubyIterator.new(@map_a2b.keys)
|
129
|
+
while(_it.has_next) do
|
130
|
+
k = _it._next
|
131
|
+
unit = ::Coopy::Unit.new
|
132
|
+
unit.l = k
|
133
|
+
unit.r = self.a2b(k)
|
134
|
+
order.push(unit)
|
135
|
+
end
|
136
|
+
_it2 = ::Rb::RubyIterator.new(@map_b2a.keys)
|
137
|
+
while(_it2.has_next) do
|
138
|
+
k1 = _it2._next
|
139
|
+
if self.b2a(k1) == -1
|
140
|
+
unit1 = ::Coopy::Unit.new
|
141
|
+
unit1.l = -1
|
142
|
+
unit1.r = k1
|
143
|
+
order.push(unit1)
|
136
144
|
end
|
137
145
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
vp = {}
|
148
|
-
vl = {}
|
149
|
-
vr = {}
|
150
|
-
begin
|
151
|
-
_g2 = 0
|
152
|
-
while(_g2 < hp)
|
153
|
-
i1 = _g2
|
154
|
-
_g2+=1
|
155
|
-
vp[i1] = i1
|
146
|
+
else
|
147
|
+
_it3 = ::Rb::RubyIterator.new(@map_a2b.keys)
|
148
|
+
while(_it3.has_next) do
|
149
|
+
k2 = _it3._next
|
150
|
+
unit2 = ::Coopy::Unit.new
|
151
|
+
unit2.p = k2
|
152
|
+
unit2.l = @reference.a2b(k2)
|
153
|
+
unit2.r = self.a2b(k2)
|
154
|
+
order.push(unit2)
|
156
155
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
156
|
+
_it4 = ::Rb::RubyIterator.new(@reference.map_b2a.keys)
|
157
|
+
while(_it4.has_next) do
|
158
|
+
k3 = _it4._next
|
159
|
+
if @reference.b2a(k3) == -1
|
160
|
+
unit3 = ::Coopy::Unit.new
|
161
|
+
unit3.p = -1
|
162
|
+
unit3.l = k3
|
163
|
+
unit3.r = -1
|
164
|
+
order.push(unit3)
|
165
|
+
end
|
164
166
|
end
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
167
|
+
_it5 = ::Rb::RubyIterator.new(@map_b2a.keys)
|
168
|
+
while(_it5.has_next) do
|
169
|
+
k4 = _it5._next
|
170
|
+
if self.b2a(k4) == -1
|
171
|
+
unit4 = ::Coopy::Unit.new
|
172
|
+
unit4.p = -1
|
173
|
+
unit4.l = -1
|
174
|
+
unit4.r = k4
|
175
|
+
order.push(unit4)
|
176
|
+
end
|
172
177
|
end
|
173
178
|
end
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
xp = 0 if xp >= hp
|
187
|
-
xl = 0 if xl >= hl
|
188
|
-
xr = 0 if xr >= hr
|
189
|
-
if xp < hp && ct_vp > 0
|
190
|
-
if self.a2b(xp) == nil && ref.a2b(xp) == nil
|
191
|
-
if vp.include?(xp)
|
192
|
-
order.add(-1,-1,xp)
|
193
|
-
prev = xp
|
194
|
-
vp.delete(xp)
|
195
|
-
ct_vp-=1
|
196
|
-
end
|
197
|
-
xp+=1
|
198
|
-
next
|
179
|
+
top = order.length
|
180
|
+
remotes = Array.new
|
181
|
+
locals = Array.new
|
182
|
+
begin
|
183
|
+
_g = 0
|
184
|
+
while(_g < top)
|
185
|
+
o = _g
|
186
|
+
_g+=1
|
187
|
+
if order[o].r >= 0
|
188
|
+
remotes.push(o)
|
189
|
+
else
|
190
|
+
locals.push(o)
|
199
191
|
end
|
200
192
|
end
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
193
|
+
end
|
194
|
+
remote_sort = lambda {|a,b|
|
195
|
+
order[a].r - order[b].r
|
196
|
+
}
|
197
|
+
local_sort = lambda {|a1,b1|
|
198
|
+
return 0 if a1 == b1
|
199
|
+
return order[a1].l - order[b1].l if order[a1].l >= 0 && order[b1].l >= 0
|
200
|
+
return 1 if order[a1].l >= 0
|
201
|
+
return -1 if order[b1].l >= 0
|
202
|
+
a1 - b1
|
203
|
+
}
|
204
|
+
if @reference != nil
|
205
|
+
remote_sort = lambda {|a2,b2|
|
206
|
+
return 0 if a2 == b2
|
207
|
+
o1 = order[a2].r - order[b2].r
|
208
|
+
if order[a2].p >= 0 && order[b2].p >= 0
|
209
|
+
o2 = order[a2].p - order[b2].p
|
210
|
+
return o1 if o1 * o2 < 0
|
211
|
+
o3 = order[a2].l - order[b2].l
|
212
|
+
return o3
|
213
213
|
end
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
if
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
214
|
+
o1
|
215
|
+
}
|
216
|
+
local_sort = lambda {|a3,b3|
|
217
|
+
return 0 if a3 == b3
|
218
|
+
if order[a3].l >= 0 && order[b3].l >= 0
|
219
|
+
o11 = order[a3].l - order[b3].l
|
220
|
+
if order[a3].p >= 0 && order[b3].p >= 0
|
221
|
+
o21 = order[a3].p - order[b3].p
|
222
|
+
return o11 if o11 * o21 < 0
|
223
|
+
return o21
|
222
224
|
end
|
223
|
-
xr+=1
|
224
|
-
next
|
225
225
|
end
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
226
|
+
return 1 if order[a3].l >= 0
|
227
|
+
return -1 if order[b3].l >= 0
|
228
|
+
a3 - b3
|
229
|
+
}
|
230
|
+
end
|
231
|
+
remotes.sort!{|a,b| remote_sort.call(a,b)}
|
232
|
+
locals.sort!{|a,b| local_sort.call(a,b)}
|
233
|
+
revised_order = Array.new
|
234
|
+
at_r = 0
|
235
|
+
at_l = 0
|
236
|
+
begin
|
237
|
+
_g1 = 0
|
238
|
+
while(_g1 < top)
|
239
|
+
o4 = _g1
|
240
|
+
_g1+=1
|
241
|
+
if at_r < remotes.length && at_l < locals.length
|
242
|
+
ur = order[remotes[at_r]]
|
243
|
+
ul = order[locals[at_l]]
|
244
|
+
if ul.l == -1 && ul.p >= 0 && ur.p >= 0
|
245
|
+
if ur.p > ul.p
|
246
|
+
revised_order.push(ul)
|
247
|
+
at_l+=1
|
248
|
+
next
|
249
|
+
end
|
250
|
+
elsif ur.l > ul.l
|
251
|
+
revised_order.push(ul)
|
252
|
+
at_l+=1
|
253
|
+
next
|
237
254
|
end
|
238
|
-
|
255
|
+
revised_order.push(ur)
|
256
|
+
at_r+=1
|
239
257
|
next
|
240
258
|
end
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
order.add(-1,xr,zr)
|
246
|
-
prev = zr
|
247
|
-
vp.delete(zr)
|
248
|
-
ct_vp-=1
|
249
|
-
vr.delete(xr)
|
250
|
-
ct_vr-=1
|
251
|
-
xp = zr + 1
|
252
|
-
end
|
253
|
-
xr+=1
|
259
|
+
if at_r < remotes.length
|
260
|
+
ur1 = order[remotes[at_r]]
|
261
|
+
revised_order.push(ur1)
|
262
|
+
at_r+=1
|
254
263
|
next
|
255
264
|
end
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
order.add(ref.a2b(zr),xr,zr)
|
261
|
-
prev = zr
|
262
|
-
vp.delete(zr)
|
263
|
-
ct_vp-=1
|
264
|
-
begin
|
265
|
-
key = ref.a2b(zr)
|
266
|
-
vl.delete(key)
|
267
|
-
end
|
268
|
-
ct_vl-=1
|
269
|
-
vr.delete(xr)
|
270
|
-
ct_vr-=1
|
271
|
-
xp = zr + 1
|
272
|
-
xl = ref.a2b(zr) + 1
|
273
|
-
end
|
274
|
-
xr+=1
|
275
|
-
next
|
276
|
-
else
|
277
|
-
if vl.include?(xl)
|
278
|
-
order.add(xl,self.a2b(zl),zl)
|
279
|
-
prev = zl
|
280
|
-
vp.delete(zl)
|
281
|
-
ct_vp-=1
|
282
|
-
vl.delete(xl)
|
283
|
-
ct_vl-=1
|
284
|
-
begin
|
285
|
-
key1 = self.a2b(zl)
|
286
|
-
vr.delete(key1)
|
287
|
-
end
|
288
|
-
ct_vr-=1
|
289
|
-
xp = zl + 1
|
290
|
-
xr = self.a2b(zl) + 1
|
291
|
-
end
|
292
|
-
xl+=1
|
265
|
+
if at_l < locals.length
|
266
|
+
ul1 = order[locals[at_l]]
|
267
|
+
revised_order.push(ul1)
|
268
|
+
at_l+=1
|
293
269
|
next
|
294
270
|
end
|
295
271
|
end
|
296
|
-
xp+=1
|
297
|
-
xl+=1
|
298
|
-
xr+=1
|
299
272
|
end
|
300
|
-
|
273
|
+
order = revised_order
|
274
|
+
result = ::Coopy::Ordering.new
|
275
|
+
result.set_list(order)
|
276
|
+
result.ignore_parent if @reference == nil
|
277
|
+
result
|
301
278
|
end
|
302
279
|
|
303
280
|
haxe_me ["coopy", "Alignment"]
|