daff 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/lib/coopy/coopy.rb +350 -160
- data/lib/lib/coopy/table_io.rb +18 -0
- data/lib/lib/sys.rb +46 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -19,9 +19,9 @@ Download the code for your preferred language here:
|
|
19
19
|
|
20
20
|
For certain languages you can use the command-line:
|
21
21
|
````sh
|
22
|
-
npm install daff
|
23
|
-
pip3 install daff
|
24
|
-
gem install daff
|
22
|
+
npm install daff -g # node/javascript
|
23
|
+
pip3 install daff # python3
|
24
|
+
gem install daff # ruby
|
25
25
|
````
|
26
26
|
|
27
27
|
Or use the library to view csv diffs on github via a chrome extension:
|
data/lib/lib/coopy/coopy.rb
CHANGED
@@ -71,151 +71,184 @@ module Coopy
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
def Coopy.compare_tables(local,remote)
|
77
|
-
ct = ::Coopy::CompareTable.new
|
78
|
-
comp = ::Coopy::TableComparisonState.new
|
79
|
-
comp.a = local
|
80
|
-
comp.b = remote
|
81
|
-
ct.attach(comp)
|
82
|
-
return ct
|
83
|
-
end
|
84
|
-
|
85
|
-
def Coopy.compare_tables3(parent,local,remote)
|
86
|
-
ct = ::Coopy::CompareTable.new
|
87
|
-
comp = ::Coopy::TableComparisonState.new
|
88
|
-
comp.p = parent
|
89
|
-
comp.a = local
|
90
|
-
comp.b = remote
|
91
|
-
ct.attach(comp)
|
92
|
-
return ct
|
93
|
-
end
|
74
|
+
attr_accessor :status
|
75
|
+
attr_accessor :daff_cmd
|
94
76
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
report.clear
|
117
|
-
compare.compare(d1,d2,d3,report)
|
118
|
-
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 60, class_name: "coopy.Coopy", method_name: "randomTests"})
|
119
|
-
d1 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(20))
|
120
|
-
report.clear
|
121
|
-
compare.compare(d1,d2,d3,report)
|
122
|
-
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 64, class_name: "coopy.Coopy", method_name: "randomTests"})
|
123
|
-
comp = ::Coopy::TableComparisonState.new
|
124
|
-
ct = ::Coopy::CompareTable.new
|
125
|
-
comp.a = st
|
126
|
-
comp.b = st
|
127
|
-
ct.attach(comp)
|
128
|
-
::Haxe::Log._trace.call("comparing tables",{ file_name: "Coopy.hx", line_number: 72, class_name: "coopy.Coopy", method_name: "randomTests"})
|
129
|
-
t1 = ::Coopy::SimpleTable.new(3,2)
|
130
|
-
t2 = ::Coopy::SimpleTable.new(3,2)
|
131
|
-
t3 = ::Coopy::SimpleTable.new(3,2)
|
132
|
-
dt1 = ::Coopy::ViewedDatum.new(t1,::Coopy::SimpleView.new)
|
133
|
-
dt2 = ::Coopy::ViewedDatum.new(t2,::Coopy::SimpleView.new)
|
134
|
-
dt3 = ::Coopy::ViewedDatum.new(t3,::Coopy::SimpleView.new)
|
135
|
-
compare.compare(dt1,dt2,dt3,report)
|
136
|
-
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 80, class_name: "coopy.Coopy", method_name: "randomTests"})
|
137
|
-
t3.set_cell(1,1,::Coopy::SimpleCell.new("hello"))
|
138
|
-
compare.compare(dt1,dt2,dt3,report)
|
139
|
-
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 83, class_name: "coopy.Coopy", method_name: "randomTests"})
|
140
|
-
t1.set_cell(1,1,::Coopy::SimpleCell.new("hello"))
|
141
|
-
compare.compare(dt1,dt2,dt3,report)
|
142
|
-
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 86, class_name: "coopy.Coopy", method_name: "randomTests"})
|
143
|
-
v = ::Coopy::Viterbi.new
|
144
|
-
td = ::Coopy::TableDiff.new(nil,nil)
|
145
|
-
idx = ::Coopy::Index.new
|
146
|
-
dr = ::Coopy::DiffRender.new
|
147
|
-
cf = ::Coopy::CompareFlags.new
|
148
|
-
hp = ::Coopy::HighlightPatch.new(nil,nil)
|
149
|
-
csv = ::Coopy::Csv.new
|
150
|
-
tm = ::Coopy::TableModifier.new(nil)
|
151
|
-
return 0
|
77
|
+
def command(io,cmd,args)
|
78
|
+
r = 0
|
79
|
+
r = io.command(cmd,args) if io.async
|
80
|
+
if r != 999
|
81
|
+
io.write_stdout("$ " + _hx_str(cmd))
|
82
|
+
begin
|
83
|
+
_g = 0
|
84
|
+
while(_g < args.length)
|
85
|
+
arg = args[_g]
|
86
|
+
_g+=1
|
87
|
+
io.write_stdout(" ")
|
88
|
+
spaced = (arg.index(" ",nil || 0) || -1) >= 0
|
89
|
+
io.write_stdout("\"") if spaced
|
90
|
+
io.write_stdout(arg)
|
91
|
+
io.write_stdout("\"") if spaced
|
92
|
+
end
|
93
|
+
end
|
94
|
+
io.write_stdout("\n")
|
95
|
+
end
|
96
|
+
r = io.command(cmd,args) if !io.async
|
97
|
+
return r
|
152
98
|
end
|
153
99
|
|
154
|
-
|
155
|
-
return nil if x == nil
|
156
|
-
return ::Coopy::SimpleCell.new(x)
|
157
|
-
end
|
100
|
+
public
|
158
101
|
|
159
|
-
def
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
end
|
102
|
+
def install_git_driver(io,formats)
|
103
|
+
r = 0
|
104
|
+
if @status == nil
|
105
|
+
@status = {}
|
106
|
+
@daff_cmd = ""
|
107
|
+
end
|
108
|
+
key = "hello"
|
109
|
+
if !@status.include?(key)
|
110
|
+
io.write_stdout("Setting up git to use daff on")
|
111
|
+
begin
|
112
|
+
_g = 0
|
113
|
+
while(_g < formats.length)
|
114
|
+
format = formats[_g]
|
115
|
+
_g+=1
|
116
|
+
io.write_stdout(" *." + _hx_str(format))
|
117
|
+
end
|
118
|
+
end
|
119
|
+
io.write_stdout(" files\n")
|
120
|
+
@status[key] = r
|
121
|
+
end
|
122
|
+
key = "can_run_git"
|
123
|
+
if !@status.include?(key)
|
124
|
+
r = self.command(io,"git",["--version"])
|
125
|
+
return r if r == 999
|
126
|
+
@status[key] = r
|
127
|
+
if r != 0
|
128
|
+
io.write_stderr("! Cannot run git, aborting\n")
|
129
|
+
return 1
|
130
|
+
end
|
131
|
+
io.write_stdout("- Can run git\n")
|
132
|
+
end
|
133
|
+
daffs = ["daff","daff.rb","daff.py"]
|
134
|
+
if @daff_cmd == ""
|
135
|
+
begin
|
136
|
+
_g1 = 0
|
137
|
+
while(_g1 < daffs.length)
|
138
|
+
daff = daffs[_g1]
|
139
|
+
_g1+=1
|
140
|
+
key1 = "can_run_" + _hx_str(daff)
|
141
|
+
if !@status.include?(key1)
|
142
|
+
r = self.command(io,daff,["version"])
|
143
|
+
return r if r == 999
|
144
|
+
@status[key1] = r
|
145
|
+
if r == 0
|
146
|
+
@daff_cmd = daff
|
147
|
+
io.write_stdout("- Can run " + _hx_str(daff) + " as \"" + _hx_str(daff) + "\"\n")
|
148
|
+
break
|
207
149
|
end
|
208
150
|
end
|
209
151
|
end
|
210
152
|
end
|
153
|
+
if @daff_cmd == ""
|
154
|
+
io.write_stderr("! Cannot find daff, is it in your path?\n")
|
155
|
+
return 1
|
156
|
+
end
|
211
157
|
end
|
212
|
-
|
213
|
-
|
158
|
+
begin
|
159
|
+
_g2 = 0
|
160
|
+
while(_g2 < formats.length)
|
161
|
+
format1 = formats[_g2]
|
162
|
+
_g2+=1
|
163
|
+
key = "have_diff_driver_" + _hx_str(format1)
|
164
|
+
if !@status.include?(key)
|
165
|
+
r = self.command(io,"git",["config","--global","--get","diff.daff-" + _hx_str(format1) + ".command"])
|
166
|
+
return r if r == 999
|
167
|
+
@status[key] = r
|
168
|
+
end
|
169
|
+
have_diff_driver = @status[key] == 0
|
170
|
+
key = "add_diff_driver_" + _hx_str(format1)
|
171
|
+
if !@status.include?(key)
|
172
|
+
if !have_diff_driver
|
173
|
+
r = self.command(io,"git",["config","--global","diff.daff-" + _hx_str(format1) + ".command",_hx_str(@daff_cmd) + " diff --git"])
|
174
|
+
return r if r == 999
|
175
|
+
io.write_stdout("- Added diff driver for " + _hx_str(format1) + "\n")
|
176
|
+
else
|
177
|
+
r = 0
|
178
|
+
io.write_stdout("- Already have diff driver for " + _hx_str(format1) + ", not touching it\n")
|
179
|
+
end
|
180
|
+
@status[key] = r
|
181
|
+
end
|
182
|
+
key = "have_merge_driver_" + _hx_str(format1)
|
183
|
+
if !@status.include?(key)
|
184
|
+
r = self.command(io,"git",["config","--global","--get","merge.daff-" + _hx_str(format1) + ".driver"])
|
185
|
+
return r if r == 999
|
186
|
+
@status[key] = r
|
187
|
+
end
|
188
|
+
have_merge_driver = @status[key] == 0
|
189
|
+
key = "name_merge_driver_" + _hx_str(format1)
|
190
|
+
if !@status.include?(key)
|
191
|
+
if !have_merge_driver
|
192
|
+
r = self.command(io,"git",["config","--global","merge.daff-" + _hx_str(format1) + ".name","daff tabular " + _hx_str(format1) + " merge"])
|
193
|
+
return r if r == 999
|
194
|
+
else
|
195
|
+
r = 0
|
196
|
+
end
|
197
|
+
@status[key] = r
|
198
|
+
end
|
199
|
+
key = "add_merge_driver_" + _hx_str(format1)
|
200
|
+
if !@status.include?(key)
|
201
|
+
if !have_merge_driver
|
202
|
+
r = self.command(io,"git",["config","--global","merge.daff-" + _hx_str(format1) + ".driver",_hx_str(@daff_cmd) + " merge --output %A %O %A %B"])
|
203
|
+
return r if r == 999
|
204
|
+
io.write_stdout("- Added merge driver for " + _hx_str(format1) + "\n")
|
205
|
+
else
|
206
|
+
r = 0
|
207
|
+
io.write_stdout("- Already have merge driver for " + _hx_str(format1) + ", not touching it\n")
|
208
|
+
end
|
209
|
+
@status[key] = r
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
if !io.exists(".git/config")
|
214
|
+
io.write_stderr("! This next part needs to happen in a git repository.\n")
|
215
|
+
io.write_stderr("! Please run again from the root of a git repository.\n")
|
216
|
+
return 1
|
217
|
+
end
|
218
|
+
attr = ".gitattributes"
|
219
|
+
txt = ""
|
220
|
+
post = ""
|
221
|
+
if !io.exists(attr)
|
222
|
+
io.write_stdout("- No .gitattributes file\n")
|
223
|
+
else
|
224
|
+
io.write_stdout("- You have a .gitattributes file\n")
|
225
|
+
txt = io.get_content(attr)
|
226
|
+
end
|
227
|
+
need_update = false
|
228
|
+
begin
|
229
|
+
_g3 = 0
|
230
|
+
while(_g3 < formats.length)
|
231
|
+
format2 = formats[_g3]
|
232
|
+
_g3+=1
|
233
|
+
if (txt.index("*." + _hx_str(format2),nil || 0) || -1) >= 0
|
234
|
+
io.write_stderr("- Your .gitattributes file already mentions *." + _hx_str(format2) + "\n")
|
235
|
+
else
|
236
|
+
post += "*." + _hx_str(format2) + " diff=daff-" + _hx_str(format2) + "\n"
|
237
|
+
post += "*." + _hx_str(format2) + " merge=daff-" + _hx_str(format2) + "\n"
|
238
|
+
io.write_stdout("- Placing the following lines in .gitattributes:\n")
|
239
|
+
io.write_stdout(post)
|
240
|
+
txt += "\n" if txt != "" && !need_update
|
241
|
+
txt += post
|
242
|
+
need_update = true
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
io.save_content(attr,txt) if need_update
|
247
|
+
io.write_stdout("- Done!\n")
|
248
|
+
return 0
|
214
249
|
end
|
215
250
|
|
216
|
-
|
217
|
-
|
218
|
-
def Coopy.coopyhx(io)
|
251
|
+
def coopyhx(io)
|
219
252
|
args = io.args
|
220
253
|
return ::Coopy::Coopy.random_tests if args[0] == "--test"
|
221
254
|
more = true
|
@@ -293,6 +326,34 @@ module Coopy
|
|
293
326
|
end
|
294
327
|
cmd = args[0]
|
295
328
|
if args.length < 2
|
329
|
+
if cmd == "version"
|
330
|
+
io.write_stdout(_hx_str(::Coopy::Coopy.version) + "\n")
|
331
|
+
return 0
|
332
|
+
end
|
333
|
+
if cmd == "git"
|
334
|
+
io.write_stdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n")
|
335
|
+
io.write_stdout("\n")
|
336
|
+
io.write_stdout("Automatic setup\n")
|
337
|
+
io.write_stdout("---------------\n\n")
|
338
|
+
io.write_stdout("Run:\n")
|
339
|
+
io.write_stdout(" daff git csv\n")
|
340
|
+
io.write_stdout("\n")
|
341
|
+
io.write_stdout("Manual setup\n")
|
342
|
+
io.write_stdout("------------\n\n")
|
343
|
+
io.write_stdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n")
|
344
|
+
io.write_stdout(" *.csv diff=daff-csv\n")
|
345
|
+
io.write_stdout(" *.csv merge=daff-csv\n")
|
346
|
+
io.write_stdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n")
|
347
|
+
io.write_stdout(" [diff \"daff-csv\"]\n")
|
348
|
+
io.write_stdout(" command = daff diff --git\n")
|
349
|
+
io.write_stderr("\n")
|
350
|
+
io.write_stdout(" [merge \"daff-csv\"]\n")
|
351
|
+
io.write_stdout(" name = daff tabular merge\n")
|
352
|
+
io.write_stdout(" driver = daff merge --output %A %O %A %B\n\n")
|
353
|
+
io.write_stderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it.")
|
354
|
+
io.write_stderr("\n")
|
355
|
+
return 0
|
356
|
+
end
|
296
357
|
io.write_stderr("daff can produce and apply tabular diffs.\n")
|
297
358
|
io.write_stderr("Call as:\n")
|
298
359
|
io.write_stderr(" daff [--output OUTPUT.csv] a.csv b.csv\n")
|
@@ -302,7 +363,8 @@ module Coopy
|
|
302
363
|
io.write_stderr(" daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
303
364
|
io.write_stderr(" daff trim [--output OUTPUT.csv] source.csv\n")
|
304
365
|
io.write_stderr(" daff render [--output OUTPUT.html] diff.csv\n")
|
305
|
-
io.write_stderr(" daff git
|
366
|
+
io.write_stderr(" daff git\n")
|
367
|
+
io.write_stderr(" daff version\n")
|
306
368
|
io.write_stderr("\n")
|
307
369
|
io.write_stderr("The --inplace option to patch and merge will result in modification of a.csv.\n")
|
308
370
|
io.write_stderr("\n")
|
@@ -323,7 +385,7 @@ module Coopy
|
|
323
385
|
end
|
324
386
|
cmd1 = args[0]
|
325
387
|
offset = 1
|
326
|
-
if !Lambda.has(["diff","patch","merge","trim","render","git"],cmd1)
|
388
|
+
if !Lambda.has(["diff","patch","merge","trim","render","git","version"],cmd1)
|
327
389
|
if (cmd1.index(".",nil || 0) || -1) != -1 || (cmd1.index("--",nil || 0) || -1) == 0
|
328
390
|
cmd1 = "diff"
|
329
391
|
offset = 0
|
@@ -331,28 +393,7 @@ module Coopy
|
|
331
393
|
end
|
332
394
|
if cmd1 == "git"
|
333
395
|
types = args.slice!(offset,args.length - offset)
|
334
|
-
|
335
|
-
io.write_stdout("\n")
|
336
|
-
io.write_stdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n")
|
337
|
-
begin
|
338
|
-
_g2 = 0
|
339
|
-
while(_g2 < types.length)
|
340
|
-
t = types[_g2]
|
341
|
-
_g2+=1
|
342
|
-
io.write_stdout(" *." + _hx_str(t) + " diff=daff-diff\n")
|
343
|
-
io.write_stdout(" *." + _hx_str(t) + " merge=daff-merge\n")
|
344
|
-
end
|
345
|
-
end
|
346
|
-
io.write_stdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n")
|
347
|
-
io.write_stdout(" [merge \"daff-merge\"]\n")
|
348
|
-
io.write_stdout(" name = daff tabular merge\n")
|
349
|
-
io.write_stdout(" driver = daff merge --output %A %O %A %B\n\n")
|
350
|
-
io.write_stdout(" [diff \"daff-diff\"]\n")
|
351
|
-
io.write_stdout(" command = daff diff --git\n")
|
352
|
-
io.write_stderr("\n")
|
353
|
-
io.write_stderr("Make sure you can run daff from the command-line as just \"daff\" - if not,\nreplace \"daff\" in the driver and command lines above with the correct way\nto call it.")
|
354
|
-
io.write_stderr("\n")
|
355
|
-
return 0
|
396
|
+
return self.install_git_driver(io,types)
|
356
397
|
end
|
357
398
|
if git
|
358
399
|
ct = args.length - offset
|
@@ -423,9 +464,158 @@ module Coopy
|
|
423
464
|
end
|
424
465
|
end
|
425
466
|
|
467
|
+
|
468
|
+
class << self
|
469
|
+
attr_accessor :version
|
470
|
+
end
|
471
|
+
@version = "1.1.6"
|
472
|
+
|
473
|
+
def Coopy.compare_tables(local,remote)
|
474
|
+
ct = ::Coopy::CompareTable.new
|
475
|
+
comp = ::Coopy::TableComparisonState.new
|
476
|
+
comp.a = local
|
477
|
+
comp.b = remote
|
478
|
+
ct.attach(comp)
|
479
|
+
return ct
|
480
|
+
end
|
481
|
+
|
482
|
+
def Coopy.compare_tables3(parent,local,remote)
|
483
|
+
ct = ::Coopy::CompareTable.new
|
484
|
+
comp = ::Coopy::TableComparisonState.new
|
485
|
+
comp.p = parent
|
486
|
+
comp.a = local
|
487
|
+
comp.b = remote
|
488
|
+
ct.attach(comp)
|
489
|
+
return ct
|
490
|
+
end
|
491
|
+
|
492
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
493
|
+
|
494
|
+
def Coopy.random_tests
|
495
|
+
st = ::Coopy::SimpleTable.new(15,6)
|
496
|
+
tab = st
|
497
|
+
::Haxe::Log._trace.call("table size is " + _hx_str(tab.get_width) + "x" + _hx_str(tab.get_height),{ file_name: "Coopy.hx", line_number: 44, class_name: "coopy.Coopy", method_name: "randomTests"})
|
498
|
+
tab.set_cell(3,4,::Coopy::SimpleCell.new(33))
|
499
|
+
::Haxe::Log._trace.call("element is " + _hx_str(lambda{ s = tab.get_cell(3,4)
|
500
|
+
_r = s.to_s}.call()),{ file_name: "Coopy.hx", line_number: 46, class_name: "coopy.Coopy", method_name: "randomTests"})
|
501
|
+
compare = ::Coopy::Compare.new
|
502
|
+
d1 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(10))
|
503
|
+
d2 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(10))
|
504
|
+
d3 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(20))
|
505
|
+
report = ::Coopy::Report.new
|
506
|
+
compare.compare(d1,d2,d3,report)
|
507
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 54, class_name: "coopy.Coopy", method_name: "randomTests"})
|
508
|
+
d2 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(50))
|
509
|
+
report.clear
|
510
|
+
compare.compare(d1,d2,d3,report)
|
511
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 58, class_name: "coopy.Coopy", method_name: "randomTests"})
|
512
|
+
d2 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(20))
|
513
|
+
report.clear
|
514
|
+
compare.compare(d1,d2,d3,report)
|
515
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 62, class_name: "coopy.Coopy", method_name: "randomTests"})
|
516
|
+
d1 = ::Coopy::ViewedDatum.get_simple_view(::Coopy::SimpleCell.new(20))
|
517
|
+
report.clear
|
518
|
+
compare.compare(d1,d2,d3,report)
|
519
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 66, class_name: "coopy.Coopy", method_name: "randomTests"})
|
520
|
+
comp = ::Coopy::TableComparisonState.new
|
521
|
+
ct = ::Coopy::CompareTable.new
|
522
|
+
comp.a = st
|
523
|
+
comp.b = st
|
524
|
+
ct.attach(comp)
|
525
|
+
::Haxe::Log._trace.call("comparing tables",{ file_name: "Coopy.hx", line_number: 74, class_name: "coopy.Coopy", method_name: "randomTests"})
|
526
|
+
t1 = ::Coopy::SimpleTable.new(3,2)
|
527
|
+
t2 = ::Coopy::SimpleTable.new(3,2)
|
528
|
+
t3 = ::Coopy::SimpleTable.new(3,2)
|
529
|
+
dt1 = ::Coopy::ViewedDatum.new(t1,::Coopy::SimpleView.new)
|
530
|
+
dt2 = ::Coopy::ViewedDatum.new(t2,::Coopy::SimpleView.new)
|
531
|
+
dt3 = ::Coopy::ViewedDatum.new(t3,::Coopy::SimpleView.new)
|
532
|
+
compare.compare(dt1,dt2,dt3,report)
|
533
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 82, class_name: "coopy.Coopy", method_name: "randomTests"})
|
534
|
+
t3.set_cell(1,1,::Coopy::SimpleCell.new("hello"))
|
535
|
+
compare.compare(dt1,dt2,dt3,report)
|
536
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 85, class_name: "coopy.Coopy", method_name: "randomTests"})
|
537
|
+
t1.set_cell(1,1,::Coopy::SimpleCell.new("hello"))
|
538
|
+
compare.compare(dt1,dt2,dt3,report)
|
539
|
+
::Haxe::Log._trace.call("report is " + _hx_str(report.to_s),{ file_name: "Coopy.hx", line_number: 88, class_name: "coopy.Coopy", method_name: "randomTests"})
|
540
|
+
v = ::Coopy::Viterbi.new
|
541
|
+
td = ::Coopy::TableDiff.new(nil,nil)
|
542
|
+
idx = ::Coopy::Index.new
|
543
|
+
dr = ::Coopy::DiffRender.new
|
544
|
+
cf = ::Coopy::CompareFlags.new
|
545
|
+
hp = ::Coopy::HighlightPatch.new(nil,nil)
|
546
|
+
csv = ::Coopy::Csv.new
|
547
|
+
tm = ::Coopy::TableModifier.new(nil)
|
548
|
+
return 0
|
549
|
+
end
|
550
|
+
|
551
|
+
def Coopy.cell_for(x)
|
552
|
+
return nil if x == nil
|
553
|
+
return ::Coopy::SimpleCell.new(x)
|
554
|
+
end
|
555
|
+
|
556
|
+
def Coopy.json_to_table(json)
|
557
|
+
output = nil
|
558
|
+
begin
|
559
|
+
_g = 0
|
560
|
+
_g1 = Reflect.fields(json)
|
561
|
+
while(_g < _g1.length)
|
562
|
+
name = _g1[_g]
|
563
|
+
_g+=1
|
564
|
+
t = Reflect.field(json,name)
|
565
|
+
columns = Reflect.field(t,"columns")
|
566
|
+
next if columns == nil
|
567
|
+
rows = Reflect.field(t,"rows")
|
568
|
+
next if rows == nil
|
569
|
+
output = ::Coopy::SimpleTable.new(columns.length,rows.length)
|
570
|
+
has_hash = false
|
571
|
+
has_hash_known = false
|
572
|
+
begin
|
573
|
+
_g3 = 0
|
574
|
+
_g2 = rows.length
|
575
|
+
while(_g3 < _g2)
|
576
|
+
i = _g3
|
577
|
+
_g3+=1
|
578
|
+
row = rows[i]
|
579
|
+
if !has_hash_known
|
580
|
+
has_hash = true if Reflect.fields(row).length == columns.length
|
581
|
+
has_hash_known = true
|
582
|
+
end
|
583
|
+
if !has_hash
|
584
|
+
lst = row
|
585
|
+
begin
|
586
|
+
_g5 = 0
|
587
|
+
_g4 = columns.length
|
588
|
+
while(_g5 < _g4)
|
589
|
+
j = _g5
|
590
|
+
_g5+=1
|
591
|
+
val = lst[j]
|
592
|
+
output.set_cell(j,i,::Coopy::Coopy.cell_for(val))
|
593
|
+
end
|
594
|
+
end
|
595
|
+
else
|
596
|
+
_g51 = 0
|
597
|
+
_g41 = columns.length
|
598
|
+
while(_g51 < _g41)
|
599
|
+
j1 = _g51
|
600
|
+
_g51+=1
|
601
|
+
val1 = Reflect.field(row,columns[j1])
|
602
|
+
output.set_cell(j1,i,::Coopy::Coopy.cell_for(val1))
|
603
|
+
end
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|
607
|
+
end
|
608
|
+
end
|
609
|
+
output.trim_blank if output != nil
|
610
|
+
return output
|
611
|
+
end
|
612
|
+
|
613
|
+
public
|
614
|
+
|
426
615
|
def Coopy.main
|
427
616
|
io = ::Coopy::TableIO.new
|
428
|
-
|
617
|
+
coopy1 = ::Coopy::Coopy.new
|
618
|
+
return coopy1.coopyhx(io)
|
429
619
|
end
|
430
620
|
|
431
621
|
def Coopy.show(t)
|
@@ -452,7 +642,7 @@ module Coopy
|
|
452
642
|
txt += "\n"
|
453
643
|
end
|
454
644
|
end
|
455
|
-
::Haxe::Log._trace.call(txt,{ file_name: "Coopy.hx", line_number:
|
645
|
+
::Haxe::Log._trace.call(txt,{ file_name: "Coopy.hx", line_number: 615, class_name: "coopy.Coopy", method_name: "show"})
|
456
646
|
end
|
457
647
|
|
458
648
|
def Coopy.jsonify(t)
|
data/lib/lib/coopy/table_io.rb
CHANGED
@@ -28,6 +28,24 @@ module Coopy
|
|
28
28
|
HxSys.stderr.write_string(txt)
|
29
29
|
end
|
30
30
|
|
31
|
+
def command(cmd,args)
|
32
|
+
begin
|
33
|
+
return HxSys.command(cmd,args)
|
34
|
+
rescue => e
|
35
|
+
return 1
|
36
|
+
end
|
37
|
+
return 1
|
38
|
+
end
|
39
|
+
|
40
|
+
def async
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
def exists(path)
|
45
|
+
return File.exist?(path)
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
|
31
49
|
end
|
32
50
|
|
33
51
|
end
|
data/lib/lib/sys.rb
CHANGED
@@ -7,6 +7,52 @@
|
|
7
7
|
return ARGV
|
8
8
|
end
|
9
9
|
|
10
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
11
|
+
|
12
|
+
def HxSys.escape_argument(arg)
|
13
|
+
ok = true
|
14
|
+
begin
|
15
|
+
_g1 = 0
|
16
|
+
_g = arg.length
|
17
|
+
while(_g1 < _g)
|
18
|
+
i = _g1
|
19
|
+
_g1+=1
|
20
|
+
_g2 = (arg[i].ord rescue nil)
|
21
|
+
case(_g2)
|
22
|
+
when 32,34
|
23
|
+
ok = false
|
24
|
+
when 0,13,10
|
25
|
+
arg = arg[0,i]
|
26
|
+
end if _g2 != nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return arg if ok
|
30
|
+
return "\"" + _hx_str(arg.split("\"").join("\\\"")) + "\""
|
31
|
+
end
|
32
|
+
|
33
|
+
public
|
34
|
+
|
35
|
+
def HxSys.command(cmd,args = nil)
|
36
|
+
if args != nil
|
37
|
+
cmd = HxSys.escape_argument(cmd)
|
38
|
+
begin
|
39
|
+
_g = 0
|
40
|
+
while(_g < args.length)
|
41
|
+
a = args[_g]
|
42
|
+
_g+=1
|
43
|
+
cmd += " " + _hx_str(HxSys.escape_argument(a))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
result = nil
|
48
|
+
if system(cmd)
|
49
|
+
result = 0
|
50
|
+
else
|
51
|
+
result = 1
|
52
|
+
end
|
53
|
+
return result
|
54
|
+
end
|
55
|
+
|
10
56
|
def HxSys.stdout
|
11
57
|
return ::Sys::Io::FileOutput.new(STDOUT)
|
12
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-07-
|
13
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: Diff and patch tables
|
16
16
|
email:
|
@@ -117,8 +117,8 @@ summary: ! '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=mast
|
|
117
117
|
for comparing tables that share a common origin, in other words multiple versions
|
118
118
|
of the "same" table. For a live demo, see: > http://paulfitz.github.com/daff/ Download
|
119
119
|
the code for your preferred language here: > https://github.com/paulfitz/daff/releases For
|
120
|
-
certain languages you can use the command-line: ````sh npm install daff
|
121
|
-
pip3 install daff
|
120
|
+
certain languages you can use the command-line: ````sh npm install daff -g # node/javascript
|
121
|
+
pip3 install daff # python3 gem install daff # ruby ```` Or use the library
|
122
122
|
to view csv diffs on github via a chrome extension: > https://github.com/theodi/csvhub The
|
123
123
|
diff format used by `daff` is specified here: > http://dataprotocols.org/tabular-diff-format/ This
|
124
124
|
library is a stripped down version of the coopy toolbox (see http://share.find.coop). To
|