daff 1.3.10 → 1.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lib/coopy/compare_flags.rb +2 -0
- data/lib/lib/coopy/coopy.rb +86 -64
- data/lib/lib/coopy/highlight_patch.rb +21 -3
- data/lib/lib/coopy/sqlite_helper.rb +1 -1
- data/lib/lib/coopy/table_io.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 739a1d0666d271b0dcda5352e570e60782fdcd46
|
4
|
+
data.tar.gz: 5b7b271027b61d93d375333ee64c8cb97cdb0e6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b95822bde10babe60ca996b60f8e15fdce5eb730172dfe3f63a1a67e688667aa1169df8dfc0517442bafe4aab83c650bf7e5e6692c02720e9fd4194304c852
|
7
|
+
data.tar.gz: 0e07ba411d6973e678603e95842fb4a63b6cccfdfd181722f81e51a2c47303a777cac01a55ffddc43323bdb6c4c67804dea235c12396adc51c2271621810a6ca
|
@@ -26,6 +26,7 @@ module Coopy
|
|
26
26
|
@count_like_a_spreadsheet = true
|
27
27
|
@ignore_whitespace = false
|
28
28
|
@ignore_case = false
|
29
|
+
@terminal_format = nil
|
29
30
|
end
|
30
31
|
|
31
32
|
attr_accessor :ordered
|
@@ -50,6 +51,7 @@ module Coopy
|
|
50
51
|
attr_accessor :count_like_a_spreadsheet
|
51
52
|
attr_accessor :ignore_whitespace
|
52
53
|
attr_accessor :ignore_case
|
54
|
+
attr_accessor :terminal_format
|
53
55
|
|
54
56
|
def filter(act,allow)
|
55
57
|
if @acts == nil
|
data/lib/lib/coopy/coopy.rb
CHANGED
@@ -25,6 +25,7 @@ module Coopy
|
|
25
25
|
attr_accessor :css_output
|
26
26
|
attr_accessor :fragment
|
27
27
|
attr_accessor :flags
|
28
|
+
attr_accessor :cache_txt
|
28
29
|
attr_accessor :mv
|
29
30
|
|
30
31
|
def init
|
@@ -36,45 +37,49 @@ module Coopy
|
|
36
37
|
@nested_output = false
|
37
38
|
@order_set = false
|
38
39
|
@order_preference = false
|
40
|
+
@strategy = nil
|
39
41
|
@pretty = true
|
40
42
|
@css_output = nil
|
41
43
|
@fragment = false
|
42
44
|
@flags = nil
|
45
|
+
@cache_txt = nil
|
43
46
|
end
|
44
47
|
|
45
48
|
def check_format(name)
|
46
49
|
return @format_preference if @extern_preference
|
47
50
|
ext = ""
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
51
|
+
if name != nil
|
52
|
+
pt = name.rindex(".",nil || 0) || -1
|
53
|
+
if pt >= 0
|
54
|
+
begin
|
55
|
+
_this = name[pt + 1..-1]
|
56
|
+
ext = _this.downcase
|
57
|
+
end
|
58
|
+
case(ext)
|
59
|
+
when "json"
|
60
|
+
@format_preference = "json"
|
61
|
+
when "ndjson"
|
62
|
+
@format_preference = "ndjson"
|
63
|
+
when "csv"
|
64
|
+
@format_preference = "csv"
|
65
|
+
@delim_preference = ","
|
66
|
+
when "tsv"
|
67
|
+
@format_preference = "csv"
|
68
|
+
@delim_preference = "\t"
|
69
|
+
when "ssv"
|
70
|
+
@format_preference = "csv"
|
71
|
+
@delim_preference = ";"
|
72
|
+
when "sqlite3"
|
73
|
+
@format_preference = "sqlite"
|
74
|
+
when "sqlite"
|
75
|
+
@format_preference = "sqlite"
|
76
|
+
when "html","htm"
|
77
|
+
@format_preference = "html"
|
78
|
+
when "www"
|
79
|
+
@format_preference = "www"
|
80
|
+
else
|
81
|
+
ext = ""
|
82
|
+
end
|
78
83
|
end
|
79
84
|
end
|
80
85
|
@nested_output = @format_preference == "json" || @format_preference == "ndjson"
|
@@ -192,7 +197,9 @@ module Coopy
|
|
192
197
|
end
|
193
198
|
|
194
199
|
def save_text(name,txt)
|
195
|
-
if name
|
200
|
+
if name == nil
|
201
|
+
@cache_txt += txt
|
202
|
+
elsif name != "-"
|
196
203
|
@io.save_content(name,txt)
|
197
204
|
else
|
198
205
|
@io.write_stdout(txt)
|
@@ -263,6 +270,24 @@ module Coopy
|
|
263
270
|
output
|
264
271
|
end
|
265
272
|
|
273
|
+
def run_diff(parent,a,b,flags,output)
|
274
|
+
ct = ::Coopy::Coopy.compare_tables3(parent,a,b,flags)
|
275
|
+
align = ct.align
|
276
|
+
td = ::Coopy::TableDiff.new(align,flags)
|
277
|
+
o = ::Coopy::SimpleTable.new(0,0)
|
278
|
+
os = ::Coopy::Tables.new(o)
|
279
|
+
td.hilite_with_nesting(os)
|
280
|
+
use_color = flags.terminal_format == "ansi"
|
281
|
+
if flags.terminal_format == nil
|
282
|
+
if (output == nil || output == "-") && (@output_format == "copy" || @output_format == "csv")
|
283
|
+
if @io != nil
|
284
|
+
use_color = @io.is_tty if @io.is_tty_known
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
self.save_tables(output,os,use_color)
|
289
|
+
end
|
290
|
+
|
266
291
|
public
|
267
292
|
|
268
293
|
def load_table(name)
|
@@ -472,16 +497,18 @@ module Coopy
|
|
472
497
|
|
473
498
|
public
|
474
499
|
|
475
|
-
def
|
500
|
+
def run(args,io = nil)
|
501
|
+
io = ::Coopy::TableIO.new if io == nil
|
502
|
+
if io == nil
|
503
|
+
puts "No system interface available"
|
504
|
+
return 1
|
505
|
+
end
|
476
506
|
self.init
|
477
|
-
|
478
|
-
return ::Coopy::Coopy.keep_around if args[0] == "--keep"
|
507
|
+
@io = io
|
479
508
|
more = true
|
480
509
|
output = nil
|
481
510
|
inplace = false
|
482
511
|
git = false
|
483
|
-
color = false
|
484
|
-
no_color = false
|
485
512
|
@flags = ::Coopy::CompareFlags.new
|
486
513
|
@flags.always_show_header = true
|
487
514
|
while(more)
|
@@ -570,12 +597,12 @@ module Coopy
|
|
570
597
|
break
|
571
598
|
elsif tag == "--color"
|
572
599
|
more = true
|
573
|
-
|
600
|
+
@flags.terminal_format = "ansi"
|
574
601
|
args.slice!(i,1)
|
575
602
|
break
|
576
603
|
elsif tag == "--no-color"
|
577
604
|
more = true
|
578
|
-
|
605
|
+
@flags.terminal_format = "plain"
|
579
606
|
args.slice!(i,1)
|
580
607
|
break
|
581
608
|
elsif tag == "--input-format"
|
@@ -744,19 +771,17 @@ module Coopy
|
|
744
771
|
args.push(old_file)
|
745
772
|
args.push(new_file)
|
746
773
|
end
|
747
|
-
tool = self
|
748
|
-
tool.io = io
|
749
774
|
parent = nil
|
750
775
|
if args.length - offset >= 3
|
751
|
-
parent =
|
776
|
+
parent = self.load_table(args[offset])
|
752
777
|
offset+=1
|
753
778
|
end
|
754
779
|
aname = args[offset]
|
755
|
-
a =
|
780
|
+
a = self.load_table(aname)
|
756
781
|
b = nil
|
757
782
|
if args.length - offset >= 2
|
758
783
|
if cmd1 != "copy"
|
759
|
-
b =
|
784
|
+
b = self.load_table(args[1 + offset])
|
760
785
|
else
|
761
786
|
output = args[1 + offset]
|
762
787
|
end
|
@@ -775,35 +800,23 @@ module Coopy
|
|
775
800
|
@flags.unchanged_context = 0 if !@flags.ordered
|
776
801
|
end
|
777
802
|
@flags.allow_nested_cells = @nested_output
|
778
|
-
|
779
|
-
align = ct1.align
|
780
|
-
td = ::Coopy::TableDiff.new(align,@flags)
|
781
|
-
o = ::Coopy::SimpleTable.new(0,0)
|
782
|
-
os = ::Coopy::Tables.new(o)
|
783
|
-
td.hilite_with_nesting(os)
|
784
|
-
use_color = color
|
785
|
-
if !(color || no_color)
|
786
|
-
if output == "-" && @output_format == "copy"
|
787
|
-
use_color = io.is_tty if io.is_tty_known
|
788
|
-
end
|
789
|
-
end
|
790
|
-
tool.save_tables(output,os,use_color)
|
803
|
+
self.run_diff(parent,a,b,@flags,output)
|
791
804
|
elsif cmd1 == "patch"
|
792
805
|
patcher = ::Coopy::HighlightPatch.new(a,b)
|
793
806
|
patcher.apply
|
794
|
-
|
807
|
+
self.save_table(output,a)
|
795
808
|
elsif cmd1 == "merge"
|
796
809
|
merger = ::Coopy::Merger.new(parent,a,b,@flags)
|
797
810
|
conflicts = merger.apply
|
798
811
|
ok = conflicts == 0
|
799
812
|
io.write_stderr(_hx_str(conflicts) + " conflict" + _hx_str((((conflicts > 1) ? "s" : ""))) + "\n") if conflicts > 0
|
800
|
-
|
813
|
+
self.save_table(output,a)
|
801
814
|
elsif cmd1 == "trim"
|
802
|
-
|
815
|
+
self.save_table(output,a)
|
803
816
|
elsif cmd1 == "render"
|
804
817
|
self.render_table(output,a)
|
805
818
|
elsif cmd1 == "copy"
|
806
|
-
|
819
|
+
self.save_table(output,a)
|
807
820
|
end
|
808
821
|
if ok
|
809
822
|
return 0
|
@@ -812,11 +825,17 @@ module Coopy
|
|
812
825
|
end
|
813
826
|
end
|
814
827
|
|
828
|
+
def coopyhx(io)
|
829
|
+
args = io.args
|
830
|
+
return ::Coopy::Coopy.keep_around if args[0] == "--keep"
|
831
|
+
self.run(args,io)
|
832
|
+
end
|
833
|
+
|
815
834
|
|
816
835
|
class << self
|
817
836
|
attr_accessor :version
|
818
837
|
end
|
819
|
-
@version = "1.3.
|
838
|
+
@version = "1.3.16"
|
820
839
|
|
821
840
|
def Coopy.diff_as_html(local,remote,flags = nil)
|
822
841
|
comp = ::Coopy::TableComparisonState.new
|
@@ -832,9 +851,12 @@ module Coopy
|
|
832
851
|
end
|
833
852
|
|
834
853
|
def Coopy.diff_as_ansi(local,remote,flags = nil)
|
835
|
-
|
836
|
-
|
837
|
-
|
854
|
+
tool = ::Coopy::Coopy.new(::Coopy::TableIO.new)
|
855
|
+
tool.cache_txt = ""
|
856
|
+
flags = ::Coopy::CompareFlags.new if flags == nil
|
857
|
+
tool.output_format = "csv"
|
858
|
+
tool.run_diff(flags.parent,local,remote,flags,nil)
|
859
|
+
tool.cache_txt
|
838
860
|
end
|
839
861
|
|
840
862
|
def Coopy.diff(local,remote,flags = nil)
|
@@ -294,6 +294,12 @@ module Coopy
|
|
294
294
|
@view.to_s(self.get_datum(c))
|
295
295
|
end
|
296
296
|
|
297
|
+
def get_string_null(c)
|
298
|
+
d = self.get_datum(c)
|
299
|
+
return nil if d == nil
|
300
|
+
@view.to_s(d)
|
301
|
+
end
|
302
|
+
|
297
303
|
def apply_meta
|
298
304
|
_g1 = @payload_col
|
299
305
|
_g = @payload_top
|
@@ -413,7 +419,7 @@ module Coopy
|
|
413
419
|
cact = @modifier[i]
|
414
420
|
next if cact == "..."
|
415
421
|
next if name == nil || name == ""
|
416
|
-
txt = self.
|
422
|
+
txt = @csv.parse_cell(self.get_string_null(i))
|
417
423
|
updated = false
|
418
424
|
if @row_info.updated
|
419
425
|
self.get_pre_string(txt)
|
@@ -427,8 +433,20 @@ module Coopy
|
|
427
433
|
end
|
428
434
|
end
|
429
435
|
if updated
|
430
|
-
|
431
|
-
|
436
|
+
begin
|
437
|
+
value = @csv.parse_cell(@cell_info.lvalue)
|
438
|
+
begin
|
439
|
+
value1 = value
|
440
|
+
rc.cond[name] = value1
|
441
|
+
end
|
442
|
+
end
|
443
|
+
begin
|
444
|
+
value2 = @csv.parse_cell(@cell_info.rvalue)
|
445
|
+
begin
|
446
|
+
value3 = value2
|
447
|
+
rc.val[name] = value3
|
448
|
+
end
|
449
|
+
end
|
432
450
|
elsif code == "+++"
|
433
451
|
rc.val[name] = txt if cact != "---"
|
434
452
|
elsif cact != "+++" && cact != "---"
|
data/lib/lib/coopy/table_io.rb
CHANGED
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.3.
|
4
|
+
version: 1.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Diff and patch tables
|
15
15
|
email:
|