daff 1.3.26 → 1.3.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/daff.rb +2 -2
- data/lib/lib/coopy/coopy.rb +191 -159
- data/lib/lib/coopy/csv.rb +5 -5
- data/lib/lib/coopy/diff_summary.rb +1 -0
- data/lib/lib/coopy/table_diff.rb +11 -7
- data/lib/lib/coopy/terminal_diff_render.rb +10 -6
- data/lib/lib/rb/boot.rb +2 -2
- data/lib/lib/type.rb +2 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcecf9714f4f125b4335e3113fb57bbf96b1db9b
|
4
|
+
data.tar.gz: 101dab4d573f812ec2faf2dee8d3cca85cb9b5e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eab198c780357ddd7c3e7a27393b07cd36ed2815c3d39eadec1919f6365052b9f44b44fe3db8fd9f73dce1959109578f056e329dbbdaade832c60b7aa50df499
|
7
|
+
data.tar.gz: afae043f38fab30472f802d16f6eedae1a8920654baf039de88bdb4fa16f0e9c222691938da13ff6def39fe05543eab5528928091f7125c3bd2461ac74c6114e
|
data/lib/daff.rb
CHANGED
@@ -16,14 +16,14 @@ def haxe_me(source_name)
|
|
16
16
|
end
|
17
17
|
old_get = instance_method(:[]) rescue nil
|
18
18
|
define_method(:[]) do |x|
|
19
|
-
return old_get.bind(self).(x) if x.is_a?(
|
19
|
+
return old_get.bind(self).(x) if x.is_a?(0.class)
|
20
20
|
tag = _haxe_vars_[x]
|
21
21
|
return instance_variable_get(tag) if tag
|
22
22
|
method x
|
23
23
|
end
|
24
24
|
old_set = instance_method(:[]=) rescue nil
|
25
25
|
define_method(:[]=) do |x,y|
|
26
|
-
return old_set.bind(self).(x,y) if x.is_a?(
|
26
|
+
return old_set.bind(self).(x,y) if x.is_a?(0.class)
|
27
27
|
instance_variable_set(_haxe_vars_[x],y)
|
28
28
|
end
|
29
29
|
define_method(:haxe_name) do
|
data/lib/lib/coopy/coopy.rb
CHANGED
@@ -26,6 +26,8 @@ module Coopy
|
|
26
26
|
attr_accessor :fragment
|
27
27
|
attr_accessor :flags
|
28
28
|
attr_accessor :cache_txt
|
29
|
+
attr_accessor :fail_if_diff
|
30
|
+
attr_accessor :diffs_found
|
29
31
|
attr_accessor :mv
|
30
32
|
|
31
33
|
def init
|
@@ -43,6 +45,8 @@ module Coopy
|
|
43
45
|
@fragment = false
|
44
46
|
@flags = nil
|
45
47
|
@cache_txt = nil
|
48
|
+
@fail_if_diff = false
|
49
|
+
@diffs_found = false
|
46
50
|
end
|
47
51
|
|
48
52
|
def check_format(name)
|
@@ -297,6 +301,10 @@ module Coopy
|
|
297
301
|
td.hilite_with_nesting(os)
|
298
302
|
use_color = self.use_color(flags,output)
|
299
303
|
self.save_tables(output,os,use_color,true)
|
304
|
+
if @fail_if_diff
|
305
|
+
summary = td.get_summary
|
306
|
+
@diffs_found = true if summary.different
|
307
|
+
end
|
300
308
|
end
|
301
309
|
|
302
310
|
public
|
@@ -688,182 +696,206 @@ module Coopy
|
|
688
696
|
@csv_eol_preference = ending
|
689
697
|
args.slice!(i,2)
|
690
698
|
break
|
699
|
+
elsif tag == "--fail-if-diff"
|
700
|
+
more = true
|
701
|
+
@fail_if_diff = true
|
702
|
+
args.slice!(i,1)
|
703
|
+
break
|
691
704
|
end
|
692
705
|
end
|
693
706
|
end
|
694
707
|
end
|
695
708
|
cmd = args[0]
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
709
|
+
ok = true
|
710
|
+
begin
|
711
|
+
if args.length < 2
|
712
|
+
if cmd == "version"
|
713
|
+
io.write_stdout(_hx_str(::Coopy::Coopy.version) + "\n")
|
714
|
+
return 0
|
715
|
+
end
|
716
|
+
if cmd == "git"
|
717
|
+
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")
|
718
|
+
io.write_stdout("\n")
|
719
|
+
io.write_stdout("Automatic setup\n")
|
720
|
+
io.write_stdout("---------------\n\n")
|
721
|
+
io.write_stdout("Run:\n")
|
722
|
+
io.write_stdout(" daff git csv\n")
|
723
|
+
io.write_stdout("\n")
|
724
|
+
io.write_stdout("Manual setup\n")
|
725
|
+
io.write_stdout("------------\n\n")
|
726
|
+
io.write_stdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n")
|
727
|
+
io.write_stdout(" *.csv diff=daff-csv\n")
|
728
|
+
io.write_stdout(" *.csv merge=daff-csv\n")
|
729
|
+
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")
|
730
|
+
io.write_stdout(" [diff \"daff-csv\"]\n")
|
731
|
+
io.write_stdout(" command = daff diff --git\n")
|
732
|
+
io.write_stderr("\n")
|
733
|
+
io.write_stdout(" [merge \"daff-csv\"]\n")
|
734
|
+
io.write_stdout(" name = daff tabular merge\n")
|
735
|
+
io.write_stdout(" driver = daff merge --output %A %O %A %B\n\n")
|
736
|
+
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. Add --no-color if your terminal does not support ANSI colors.")
|
737
|
+
io.write_stderr("\n")
|
738
|
+
return 0
|
739
|
+
end
|
740
|
+
if args.length < 1
|
741
|
+
io.write_stderr("daff can produce and apply tabular diffs.\n")
|
742
|
+
io.write_stderr("Call as:\n")
|
743
|
+
io.write_stderr(" daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n")
|
744
|
+
io.write_stderr(" daff [--output OUTPUT.html] a.csv b.csv\n")
|
745
|
+
io.write_stderr(" daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
746
|
+
io.write_stderr(" daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n")
|
747
|
+
io.write_stderr(" daff [--www] a.csv b.csv\n")
|
748
|
+
io.write_stderr(" daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n")
|
749
|
+
io.write_stderr(" daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
750
|
+
io.write_stderr(" daff trim [--output OUTPUT.csv] source.csv\n")
|
751
|
+
io.write_stderr(" daff render [--output OUTPUT.html] diff.csv\n")
|
752
|
+
io.write_stderr(" daff copy in.csv out.tsv\n")
|
753
|
+
io.write_stderr(" daff in.csv\n")
|
754
|
+
io.write_stderr(" daff git\n")
|
755
|
+
io.write_stderr(" daff version\n")
|
756
|
+
io.write_stderr("\n")
|
757
|
+
io.write_stderr("The --inplace option to patch and merge will result in modification of a.csv.\n")
|
758
|
+
io.write_stderr("\n")
|
759
|
+
io.write_stderr("If you need more control, here is the full list of flags:\n")
|
760
|
+
io.write_stderr(" daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n")
|
761
|
+
io.write_stderr(" --act ACT: show only a certain kind of change (update, insert, delete)\n")
|
762
|
+
io.write_stderr(" --all: do not prune unchanged rows or columns\n")
|
763
|
+
io.write_stderr(" --all-rows: do not prune unchanged rows\n")
|
764
|
+
io.write_stderr(" --all-columns: do not prune unchanged columns\n")
|
765
|
+
io.write_stderr(" --color: highlight changes with terminal colors (default in terminals)\n")
|
766
|
+
io.write_stderr(" --context NUM: show NUM rows of context\n")
|
767
|
+
io.write_stderr(" --fail-if-diff: return status is 0 if equal, 1 if different, 2 if problem\n")
|
768
|
+
io.write_stderr(" --id: specify column to use as primary key (repeat for multi-column key)\n")
|
769
|
+
io.write_stderr(" --ignore: specify column to ignore completely (can repeat)\n")
|
770
|
+
io.write_stderr(" --index: include row/columns numbers from original tables\n")
|
771
|
+
io.write_stderr(" --input-format [csv|tsv|ssv|psv|json]: set format to expect for input\n")
|
772
|
+
io.write_stderr(" --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n")
|
773
|
+
io.write_stderr(" --no-color: make sure terminal colors are not used\n")
|
774
|
+
io.write_stderr(" --ordered: assume row order is meaningful (default for CSV)\n")
|
775
|
+
io.write_stderr(" --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n")
|
776
|
+
io.write_stderr(" --padding [dense|sparse|smart]: set padding method for aligning columns\n")
|
777
|
+
io.write_stderr(" --table NAME: compare the named table, used with SQL sources\n")
|
778
|
+
io.write_stderr(" --unordered: assume row order is meaningless (default for json formats)\n")
|
779
|
+
io.write_stderr(" -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n")
|
780
|
+
io.write_stderr(" -i / --ignore-case: ignore differences in case\n")
|
781
|
+
io.write_stderr("\n")
|
782
|
+
io.write_stderr(" daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n")
|
783
|
+
io.write_stderr(" --css CSS.css: generate a suitable css file to go with the html\n")
|
784
|
+
io.write_stderr(" --fragment: generate just a html fragment rather than a page\n")
|
785
|
+
io.write_stderr(" --plain: do not use fancy utf8 characters to make arrows prettier\n")
|
786
|
+
io.write_stderr(" --www: send output to a browser\n")
|
787
|
+
return 1
|
788
|
+
end
|
700
789
|
end
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
io.write_stdout(" command = daff diff --git\n")
|
717
|
-
io.write_stderr("\n")
|
718
|
-
io.write_stdout(" [merge \"daff-csv\"]\n")
|
719
|
-
io.write_stdout(" name = daff tabular merge\n")
|
720
|
-
io.write_stdout(" driver = daff merge --output %A %O %A %B\n\n")
|
721
|
-
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. Add --no-color if your terminal does not support ANSI colors.")
|
722
|
-
io.write_stderr("\n")
|
723
|
-
return 0
|
790
|
+
cmd1 = args[0]
|
791
|
+
offset = 1
|
792
|
+
if !Lambda.has(["diff","patch","merge","trim","render","git","version","copy"],cmd1)
|
793
|
+
if (cmd1.index("--",nil || 0) || -1) == 0
|
794
|
+
cmd1 = "diff"
|
795
|
+
offset = 0
|
796
|
+
elsif (cmd1.index(".",nil || 0) || -1) != -1
|
797
|
+
if args.length == 2
|
798
|
+
cmd1 = "diff"
|
799
|
+
offset = 0
|
800
|
+
elsif args.length == 1
|
801
|
+
cmd1 = "copy"
|
802
|
+
offset = 0
|
803
|
+
end
|
804
|
+
end
|
724
805
|
end
|
725
|
-
if
|
726
|
-
|
727
|
-
|
728
|
-
io.write_stderr(" daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n")
|
729
|
-
io.write_stderr(" daff [--output OUTPUT.html] a.csv b.csv\n")
|
730
|
-
io.write_stderr(" daff [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
731
|
-
io.write_stderr(" daff [--output OUTPUT.ndjson] a.ndjson b.ndjson\n")
|
732
|
-
io.write_stderr(" daff [--www] a.csv b.csv\n")
|
733
|
-
io.write_stderr(" daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv\n")
|
734
|
-
io.write_stderr(" daff merge [--inplace] [--output OUTPUT.csv] parent.csv a.csv b.csv\n")
|
735
|
-
io.write_stderr(" daff trim [--output OUTPUT.csv] source.csv\n")
|
736
|
-
io.write_stderr(" daff render [--output OUTPUT.html] diff.csv\n")
|
737
|
-
io.write_stderr(" daff copy in.csv out.tsv\n")
|
738
|
-
io.write_stderr(" daff in.csv\n")
|
739
|
-
io.write_stderr(" daff git\n")
|
740
|
-
io.write_stderr(" daff version\n")
|
741
|
-
io.write_stderr("\n")
|
742
|
-
io.write_stderr("The --inplace option to patch and merge will result in modification of a.csv.\n")
|
743
|
-
io.write_stderr("\n")
|
744
|
-
io.write_stderr("If you need more control, here is the full list of flags:\n")
|
745
|
-
io.write_stderr(" daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n")
|
746
|
-
io.write_stderr(" --act ACT: show only a certain kind of change (update, insert, delete)\n")
|
747
|
-
io.write_stderr(" --all: do not prune unchanged rows or columns\n")
|
748
|
-
io.write_stderr(" --all-rows: do not prune unchanged rows\n")
|
749
|
-
io.write_stderr(" --all-columns: do not prune unchanged columns\n")
|
750
|
-
io.write_stderr(" --color: highlight changes with terminal colors (default in terminals)\n")
|
751
|
-
io.write_stderr(" --context NUM: show NUM rows of context\n")
|
752
|
-
io.write_stderr(" --id: specify column to use as primary key (repeat for multi-column key)\n")
|
753
|
-
io.write_stderr(" --ignore: specify column to ignore completely (can repeat)\n")
|
754
|
-
io.write_stderr(" --index: include row/columns numbers from original tables\n")
|
755
|
-
io.write_stderr(" --input-format [csv|tsv|ssv|psv|json]: set format to expect for input\n")
|
756
|
-
io.write_stderr(" --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n")
|
757
|
-
io.write_stderr(" --no-color: make sure terminal colors are not used\n")
|
758
|
-
io.write_stderr(" --ordered: assume row order is meaningful (default for CSV)\n")
|
759
|
-
io.write_stderr(" --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n")
|
760
|
-
io.write_stderr(" --padding [dense|sparse|smart]: set padding method for aligning columns\n")
|
761
|
-
io.write_stderr(" --table NAME: compare the named table, used with SQL sources\n")
|
762
|
-
io.write_stderr(" --unordered: assume row order is meaningless (default for json formats)\n")
|
763
|
-
io.write_stderr(" -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n")
|
764
|
-
io.write_stderr(" -i / --ignore-case: ignore differences in case\n")
|
765
|
-
io.write_stderr("\n")
|
766
|
-
io.write_stderr(" daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n")
|
767
|
-
io.write_stderr(" --css CSS.css: generate a suitable css file to go with the html\n")
|
768
|
-
io.write_stderr(" --fragment: generate just a html fragment rather than a page\n")
|
769
|
-
io.write_stderr(" --plain: do not use fancy utf8 characters to make arrows prettier\n")
|
770
|
-
io.write_stderr(" --www: send output to a browser\n")
|
771
|
-
return 1
|
806
|
+
if cmd1 == "git"
|
807
|
+
types = args.slice!(offset,args.length - offset)
|
808
|
+
return self.install_git_driver(io,types)
|
772
809
|
end
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
810
|
+
if git
|
811
|
+
ct = args.length - offset
|
812
|
+
if ct != 7 && ct != 9
|
813
|
+
io.write_stderr("Expected 7 or 9 parameters from git, but got " + _hx_str(ct) + "\n")
|
814
|
+
return 1
|
815
|
+
end
|
816
|
+
git_args = args.slice!(offset,ct)
|
817
|
+
args.slice!(0,args.length)
|
779
818
|
offset = 0
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
819
|
+
old_display_path = git_args[0]
|
820
|
+
new_display_path = git_args[0]
|
821
|
+
old_file = git_args[1]
|
822
|
+
new_file = git_args[4]
|
823
|
+
if ct == 9
|
824
|
+
io.write_stdout(git_args[8])
|
825
|
+
new_display_path = git_args[7]
|
787
826
|
end
|
827
|
+
io.write_stdout("--- a/" + _hx_str(old_display_path) + "\n")
|
828
|
+
io.write_stdout("+++ b/" + _hx_str(new_display_path) + "\n")
|
829
|
+
args.push(old_file)
|
830
|
+
args.push(new_file)
|
788
831
|
end
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
end
|
794
|
-
if git
|
795
|
-
ct = args.length - offset
|
796
|
-
if ct != 7 && ct != 9
|
797
|
-
io.write_stderr("Expected 7 or 9 parameters from git, but got " + _hx_str(ct) + "\n")
|
798
|
-
return 1
|
832
|
+
parent = nil
|
833
|
+
if args.length - offset >= 3
|
834
|
+
parent = self.load_table(args[offset])
|
835
|
+
offset+=1
|
799
836
|
end
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
new_display_path = git_args[7]
|
837
|
+
aname = args[offset]
|
838
|
+
a = self.load_table(aname)
|
839
|
+
b = nil
|
840
|
+
if args.length - offset >= 2
|
841
|
+
if cmd1 != "copy"
|
842
|
+
b = self.load_table(args[1 + offset])
|
843
|
+
else
|
844
|
+
output = args[1 + offset]
|
845
|
+
end
|
810
846
|
end
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
parent = nil
|
817
|
-
if args.length - offset >= 3
|
818
|
-
parent = self.load_table(args[offset])
|
819
|
-
offset+=1
|
820
|
-
end
|
821
|
-
aname = args[offset]
|
822
|
-
a = self.load_table(aname)
|
823
|
-
b = nil
|
824
|
-
if args.length - offset >= 2
|
825
|
-
if cmd1 != "copy"
|
826
|
-
b = self.load_table(args[1 + offset])
|
827
|
-
else
|
828
|
-
output = args[1 + offset]
|
847
|
+
@flags.diff_strategy = @strategy
|
848
|
+
if inplace
|
849
|
+
io.write_stderr("Please do not use --inplace when specifying an output.\n") if output != nil
|
850
|
+
output = aname
|
851
|
+
return 1
|
829
852
|
end
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
853
|
+
output = "-" if output == nil
|
854
|
+
if cmd1 == "diff"
|
855
|
+
if !@order_set
|
856
|
+
@flags.ordered = @order_preference
|
857
|
+
@flags.unchanged_context = 0 if !@flags.ordered
|
858
|
+
end
|
859
|
+
@flags.allow_nested_cells = @nested_output
|
860
|
+
if @fail_if_diff
|
861
|
+
begin
|
862
|
+
self.run_diff(parent,a,b,@flags,output)
|
863
|
+
rescue => e
|
864
|
+
e = hx_rescued(e)
|
865
|
+
return 2
|
866
|
+
end
|
867
|
+
return 1 if @diffs_found
|
868
|
+
else
|
869
|
+
self.run_diff(parent,a,b,@flags,output)
|
870
|
+
end
|
871
|
+
elsif cmd1 == "patch"
|
872
|
+
patcher = ::Coopy::HighlightPatch.new(a,b)
|
873
|
+
patcher.apply
|
874
|
+
self.save_table(output,a)
|
875
|
+
elsif cmd1 == "merge"
|
876
|
+
merger = ::Coopy::Merger.new(parent,a,b,@flags)
|
877
|
+
conflicts = merger.apply
|
878
|
+
ok = conflicts == 0
|
879
|
+
io.write_stderr(_hx_str(conflicts) + " conflict" + _hx_str((((conflicts > 1) ? "s" : ""))) + "\n") if conflicts > 0
|
880
|
+
self.save_table(output,a)
|
881
|
+
elsif cmd1 == "trim"
|
882
|
+
self.save_table(output,a)
|
883
|
+
elsif cmd1 == "render"
|
884
|
+
self.render_table(output,a)
|
885
|
+
elsif cmd1 == "copy"
|
886
|
+
os = ::Coopy::Tables.new(a)
|
887
|
+
os.add("untitled")
|
888
|
+
self.save_tables(output,os,self.use_color(@flags,output),false)
|
843
889
|
end
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
patcher.apply
|
849
|
-
self.save_table(output,a)
|
850
|
-
elsif cmd1 == "merge"
|
851
|
-
merger = ::Coopy::Merger.new(parent,a,b,@flags)
|
852
|
-
conflicts = merger.apply
|
853
|
-
ok = conflicts == 0
|
854
|
-
io.write_stderr(_hx_str(conflicts) + " conflict" + _hx_str((((conflicts > 1) ? "s" : ""))) + "\n") if conflicts > 0
|
855
|
-
self.save_table(output,a)
|
856
|
-
elsif cmd1 == "trim"
|
857
|
-
self.save_table(output,a)
|
858
|
-
elsif cmd1 == "render"
|
859
|
-
self.render_table(output,a)
|
860
|
-
elsif cmd1 == "copy"
|
861
|
-
os = ::Coopy::Tables.new(a)
|
862
|
-
os.add("untitled")
|
863
|
-
self.save_tables(output,os,self.use_color(@flags,output),false)
|
890
|
+
rescue => e1
|
891
|
+
e1 = hx_rescued(e1)
|
892
|
+
raise hx_raise(e1) if !@fail_if_diff
|
893
|
+
return 2
|
864
894
|
end
|
865
895
|
if ok
|
866
896
|
return 0
|
897
|
+
elsif @fail_if_diff
|
898
|
+
return 2
|
867
899
|
else
|
868
900
|
return 1
|
869
901
|
end
|
@@ -879,7 +911,7 @@ module Coopy
|
|
879
911
|
class << self
|
880
912
|
attr_accessor :version
|
881
913
|
end
|
882
|
-
@version = "1.3.
|
914
|
+
@version = "1.3.27"
|
883
915
|
|
884
916
|
def Coopy.diff_as_html(local,remote,flags = nil)
|
885
917
|
comp = ::Coopy::TableComparisonState.new
|
data/lib/lib/coopy/csv.rb
CHANGED
@@ -31,23 +31,23 @@ module Coopy
|
|
31
31
|
eol = @preferred_eol
|
32
32
|
eol = "\r\n" if eol == nil
|
33
33
|
result = ""
|
34
|
-
txt = ""
|
35
34
|
v = t.get_cell_view
|
36
35
|
stream = ::Coopy::TableStream.new(t)
|
37
36
|
w = stream.width
|
37
|
+
txts = Array.new
|
38
38
|
while(stream.fetch)
|
39
39
|
begin
|
40
40
|
_g = 0
|
41
41
|
while(_g < w)
|
42
42
|
x = _g
|
43
43
|
_g+=1
|
44
|
-
|
45
|
-
|
44
|
+
txts.push(@delim) if x > 0
|
45
|
+
txts.push(self.render_cell(v,stream.get_cell(x)))
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
txts.push(eol)
|
49
49
|
end
|
50
|
-
|
50
|
+
txts.join("")
|
51
51
|
end
|
52
52
|
|
53
53
|
def render_cell(v,d)
|
data/lib/lib/coopy/table_diff.rb
CHANGED
@@ -687,30 +687,33 @@ module Coopy
|
|
687
687
|
end
|
688
688
|
|
689
689
|
def check_meta(t,meta)
|
690
|
+
return false if meta == nil
|
691
|
+
return meta.get_width == 1 && meta.get_height == 1 if t == nil
|
690
692
|
return false if meta.get_width != t.get_width + 1
|
691
693
|
return false if meta.get_width == 0 || meta.get_height == 0
|
692
694
|
true
|
693
695
|
end
|
694
696
|
|
695
697
|
def get_meta_table(t)
|
696
|
-
|
698
|
+
if t == nil
|
699
|
+
result = ::Coopy::SimpleTable.new(1,1)
|
700
|
+
result.set_cell(0,0,"@")
|
701
|
+
return result
|
702
|
+
end
|
697
703
|
meta = t.get_meta
|
698
704
|
return nil if meta == nil
|
699
705
|
meta.as_table
|
700
706
|
end
|
701
707
|
|
702
708
|
def add_meta(output)
|
703
|
-
|
704
|
-
|
705
|
-
p_meta = nil
|
709
|
+
return false if @a == nil && @b == nil && @p == nil
|
710
|
+
return false if !@flags.show_meta
|
706
711
|
a_meta = self.get_meta_table(@a)
|
707
712
|
b_meta = self.get_meta_table(@b)
|
708
713
|
p_meta = self.get_meta_table(@p)
|
709
|
-
return false if a_meta == nil || b_meta == nil || p_meta == nil
|
710
714
|
return false if !self.check_meta(@a,a_meta)
|
711
715
|
return false if !self.check_meta(@b,b_meta)
|
712
716
|
return false if !self.check_meta(@p,p_meta)
|
713
|
-
return false if !@flags.show_meta
|
714
717
|
meta_diff = ::Coopy::SimpleTable.new(0,0)
|
715
718
|
meta_flags = ::Coopy::CompareFlags.new
|
716
719
|
meta_flags.add_primary_key("@@")
|
@@ -721,7 +724,7 @@ module Coopy
|
|
721
724
|
td = ::Coopy::TableDiff.new(meta_align,meta_flags)
|
722
725
|
td.preserve_columns = true
|
723
726
|
td.hilite(meta_diff)
|
724
|
-
if td.has_difference
|
727
|
+
if td.has_difference || td.has_schema_difference
|
725
728
|
h = output.get_height
|
726
729
|
dh = meta_diff.get_height
|
727
730
|
offset = nil
|
@@ -1176,6 +1179,7 @@ module Coopy
|
|
1176
1179
|
ds.row_count_final = @align.get_target.get_height - @align.get_target_header - 1
|
1177
1180
|
ds.col_count_initial = @align.get_source.get_width
|
1178
1181
|
ds.col_count_final = @align.get_target.get_width
|
1182
|
+
ds.different = @row_deletes + @row_inserts + @row_updates + @row_reorders + @col_deletes + @col_inserts + @col_updates + @col_renames + @col_reorders > 0
|
1179
1183
|
ds
|
1180
1184
|
end
|
1181
1185
|
|
@@ -46,7 +46,6 @@ module Coopy
|
|
46
46
|
result = ""
|
47
47
|
w = t.get_width
|
48
48
|
h = t.get_height
|
49
|
-
txt = ""
|
50
49
|
@t = t
|
51
50
|
@v = t.get_cell_view
|
52
51
|
@codes = {}
|
@@ -61,6 +60,7 @@ module Coopy
|
|
61
60
|
@codes["remove"] = "\x1B[31;1m"
|
62
61
|
sizes = nil
|
63
62
|
sizes = self.pick_sizes(t) if @align_columns
|
63
|
+
txts = Array.new
|
64
64
|
begin
|
65
65
|
_g = 0
|
66
66
|
while(_g < h)
|
@@ -80,13 +80,17 @@ module Coopy
|
|
80
80
|
while(_g2 < spaces)
|
81
81
|
i = _g2
|
82
82
|
_g2+=1
|
83
|
-
|
83
|
+
txts.push(" ")
|
84
84
|
at+=1
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
88
|
-
|
89
|
-
|
88
|
+
if x > 0
|
89
|
+
txts.push(@codes["minor"])
|
90
|
+
txts.push(@delim)
|
91
|
+
txts.push(@codes["done"])
|
92
|
+
end
|
93
|
+
txts.push(self.get_text(x,y,true))
|
90
94
|
if sizes != nil
|
91
95
|
bit = self.get_text(x,y,false)
|
92
96
|
at += bit.length
|
@@ -94,14 +98,14 @@ module Coopy
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
end
|
97
|
-
|
101
|
+
txts.push("\r\n")
|
98
102
|
end
|
99
103
|
end
|
100
104
|
@t = nil
|
101
105
|
@v = nil
|
102
106
|
@csv = nil
|
103
107
|
@codes = nil
|
104
|
-
|
108
|
+
txts.join("")
|
105
109
|
end
|
106
110
|
|
107
111
|
protected
|
data/lib/lib/rb/boot.rb
CHANGED
@@ -19,9 +19,9 @@ module Rb
|
|
19
19
|
def Boot.__instanceof(o,cl)
|
20
20
|
return false if cl == nil
|
21
21
|
if cl == Integer
|
22
|
-
return o.is_a?
|
22
|
+
return o.is_a? 0.class
|
23
23
|
elsif cl == Float
|
24
|
-
return o.is_a?(Float) || o.is_a?(
|
24
|
+
return o.is_a?(Float) || o.is_a?(0.class)
|
25
25
|
elsif cl == TrueClass
|
26
26
|
return ((o.is_a? TrueClass)||(o.is_a? FalseClass))
|
27
27
|
elsif cl == String
|
data/lib/lib/type.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.27
|
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:
|
12
|
+
date: 2018-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Diff and patch tables
|
15
15
|
email:
|
@@ -115,17 +115,17 @@ require_paths:
|
|
115
115
|
- lib
|
116
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.4.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=master)](https://travis-ci.org/paulfitz/daff)
|