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,37 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class Lambda
5
+
6
+ def Lambda.array(it)
7
+ a = Array.new
8
+ _it = Rb::RubyIterator.new(it)
9
+ while(_it.has_next) do
10
+ i = _it._next
11
+ a.push(i)
12
+ end
13
+ a
14
+ end
15
+
16
+ def Lambda.map(it,f)
17
+ l = List.new
18
+ _it = Rb::RubyIterator.new(it)
19
+ while(_it.has_next) do
20
+ x = _it._next
21
+ l.add((f).call(x))
22
+ end
23
+ l
24
+ end
25
+
26
+ def Lambda.has(it,elt)
27
+ _it = Rb::RubyIterator.new(it)
28
+ while(_it.has_next) do
29
+ x = _it._next
30
+ return true if x == elt
31
+ end
32
+ false
33
+ end
34
+
35
+ haxe_me ["Lambda"]
36
+ end
37
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class List
5
+
6
+ def initialize
7
+ @length = 0
8
+ end
9
+
10
+ # protected - in ruby this doesn't play well with static/inline methods
11
+
12
+ attr_accessor :h
13
+ attr_accessor :q
14
+
15
+ public
16
+
17
+ attr_accessor :length
18
+
19
+ def add(item)
20
+ x = [item]
21
+ if @h == nil
22
+ @h = x
23
+ else
24
+ @q[1] = x
25
+ end
26
+ @q = x
27
+ @length+=1
28
+ end
29
+
30
+ def iterator
31
+ ::X_List::ListIterator.new(@h)
32
+ end
33
+
34
+ haxe_me ["List"]
35
+ end
36
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ # This space left blank
5
+
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Rb
5
+ class Boot
6
+
7
+ # protected - in ruby this doesn't play well with static/inline methods
8
+
9
+ def Boot.__trace(v,i)
10
+ if i != nil
11
+ puts "#{v} #{i.inspect}"
12
+ else
13
+ puts v
14
+ end
15
+ end
16
+
17
+ public
18
+
19
+ def Boot.__instanceof(o,cl)
20
+ return false if cl == nil
21
+ if cl == Fixnum
22
+ return o.is_a? Fixnum
23
+ elsif cl == Float
24
+ return o.is_a?(Float) || o.is_a?(Fixnum)
25
+ elsif cl == TrueClass
26
+ return ((o.is_a? TrueClass)||(o.is_a? FalseClass))
27
+ elsif cl == String
28
+ return o.is_a? String
29
+ else
30
+ return true if cl == Object
31
+ return false if o == nil
32
+ return o.is_a?(cl)
33
+ end
34
+ end
35
+
36
+ haxe_me ["rb", "Boot"]
37
+ end
38
+
39
+ end
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Rb
5
+ class RubyIterator
6
+
7
+ def initialize(x)
8
+ if x.is_a?(Hash)
9
+ @ref = x.values.each
10
+ @at = 0
11
+ @len = x.size
12
+ elsif x.respond_to?("each")
13
+ @ref = x.each
14
+ @at = 0
15
+ @len = x.size
16
+ elsif x.respond_to?("iterator")
17
+ @ref = x.iterator
18
+ @at = -1
19
+ @at = -2 if !@ref.respond_to?("has_next")
20
+ else
21
+ @ref = x
22
+ @at = -2
23
+ end
24
+ end
25
+
26
+ protected
27
+
28
+ attr_accessor :ref
29
+ attr_accessor :at
30
+ attr_accessor :len
31
+
32
+ public
33
+
34
+ def has_next
35
+ return @ref[:has_next].call if @at == -1
36
+ return @ref[:has_next][:call].call if @at == -2
37
+ @at < @len
38
+ end
39
+
40
+ def _next
41
+ return @ref[:_next].call if @at == -1
42
+ return @ref[:_next][:call].call if @at == -2
43
+ @at+=1
44
+ @ref.next
45
+ end
46
+
47
+ haxe_me ["rb", "RubyIterator"]
48
+ end
49
+
50
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class Reflect
5
+
6
+ def Reflect.field(o,field)
7
+ begin
8
+ result = o[field]
9
+ result = o[field.to_sym] if result == nil
10
+ return result
11
+ rescue => e
12
+ e = hx_rescued(e)
13
+ return field
14
+ end
15
+ end
16
+
17
+ def Reflect.fields(o)
18
+ if o.respond_to?("attributes")
19
+ return o.attributes
20
+ else
21
+ return o.keys
22
+ end
23
+ end
24
+
25
+ def Reflect.is_function(f)
26
+ f.respond_to?("call")
27
+ end
28
+
29
+ def Reflect.compare(a,b)
30
+ if a == b
31
+ return 0
32
+ elsif a > b
33
+ return 1
34
+ else
35
+ return -1
36
+ end
37
+ end
38
+
39
+ haxe_me ["Reflect"]
40
+ end
41
+
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class Std
5
+
6
+ def Std._is(v,t)
7
+ ::Rb::Boot.__instanceof(v,t)
8
+ end
9
+
10
+ haxe_me ["Std"]
11
+ end
12
+
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class StringBuf
5
+
6
+ def initialize
7
+ @b = ""
8
+ end
9
+
10
+ # protected - in ruby this doesn't play well with static/inline methods
11
+
12
+ attr_accessor :b
13
+
14
+ public
15
+
16
+ attr_accessor :length
17
+ haxe_me ["StringBuf"]
18
+ end
19
+
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Sys
5
+ module Io
6
+ class FileHandle
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
+ CONSTRUCTS__ = []
14
+ def ==(a) (!a.nil?) && (a.respond_to? 'ISENUM__') && a.tag === @tag && a.index === @index && a.params == @params end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Sys
5
+ module Io
6
+ class FileOutput < ::Haxe::Io::Output
7
+
8
+ def initialize(f)
9
+ @__f = f
10
+ end
11
+
12
+ protected
13
+
14
+ attr_accessor :__f
15
+
16
+ public
17
+
18
+
19
+
20
+ def write_byte(c)
21
+ @__f.putc(c)
22
+ end
23
+
24
+
25
+ def write_bytes(b,p,l)
26
+ s = b.get_string(p,l)
27
+ r = @__f.write(s)
28
+ raise hx_raise(::Haxe::Io::Error.custom("An error occurred")) if r < l
29
+ r
30
+ end
31
+
32
+ haxe_me ["sys", "io", "FileOutput"]
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Sys
5
+ module Io
6
+ class HxFile
7
+
8
+ def HxFile.get_content(path)
9
+ IO.read(path)
10
+ end
11
+
12
+ def HxFile.save_content(path,content)
13
+ IO.write(path,content)
14
+ end
15
+
16
+ haxe_me ["sys", "io", "File"]
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class Type
5
+
6
+ def Type._typeof(v)
7
+ return ValueType.tnull if v == nil
8
+ begin
9
+ _g = v.class.to_s
10
+ case(_g)
11
+ when "TrueClass"
12
+ return ValueType.tbool
13
+ when "FalseClass"
14
+ return ValueType.tbool
15
+ when "String"
16
+ return ValueType.tclass(String)
17
+ when "Fixnum"
18
+ return ValueType.tint
19
+ when "Float"
20
+ return ValueType.tfloat
21
+ when "Proc"
22
+ return ValueType.tfunction
23
+ when "Array"
24
+ return ValueType.tclass(Array)
25
+ when "Hash"
26
+ return ValueType.tobject
27
+ else
28
+ return ValueType.tenum(v.class) if v.respond_to?("ISENUM__")
29
+ return ValueType.tclass(v.class) if v.respond_to?("class")
30
+ return ValueType.tunknown
31
+ end
32
+ end
33
+ end
34
+
35
+ haxe_me ["Type"]
36
+ end
37
+
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ class ValueType
5
+ ISENUM__ = true
6
+ attr_accessor :tag
7
+ attr_accessor :index
8
+ attr_accessor :params
9
+ def initialize(t,index,p = nil ) @tag = t; @index = index; @params = p; end
10
+
11
+ def ValueType.tbool() ValueType.new("TBool",3) end
12
+ def ValueType.tclass(c) ValueType.new("TClass",6,[c]) end
13
+ def ValueType.tenum(e) ValueType.new("TEnum",7,[e]) end
14
+ def ValueType.tfloat() ValueType.new("TFloat",2) end
15
+ def ValueType.tfunction() ValueType.new("TFunction",5) end
16
+ def ValueType.tint() ValueType.new("TInt",1) end
17
+ def ValueType.tnull() ValueType.new("TNull",0) end
18
+ def ValueType.tobject() ValueType.new("TObject",4) end
19
+ def ValueType.tunknown() ValueType.new("TUnknown",8) end
20
+ CONSTRUCTS__ = ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]
21
+ def ==(a) (!a.nil?) && (a.respond_to? 'ISENUM__') && a.tag === @tag && a.index === @index && a.params == @params end
22
+ end
23
+
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module X_List
5
+ class ListIterator
6
+
7
+ def initialize(head)
8
+ @head = head
9
+ @val = nil
10
+ end
11
+
12
+ # protected - in ruby this doesn't play well with static/inline methods
13
+
14
+ attr_accessor :head
15
+ attr_accessor :val
16
+
17
+ public
18
+
19
+ def has_next
20
+ @head != nil
21
+ end
22
+
23
+ def _next
24
+ @val = @head[0]
25
+ @head = @head[1]
26
+ @val
27
+ end
28
+
29
+ haxe_me ["_List", "ListIterator"]
30
+ end
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,235 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: everypolitician-daff
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.26
5
+ platform: ruby
6
+ authors:
7
+ - James Smith
8
+ - Paul Fitzpatrick
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-08-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Diff and patch tables
15
+ email:
16
+ - james@floppy.org.uk
17
+ - paul@robotrebuilt.com
18
+ executables:
19
+ - daff.rb
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - README.md
24
+ - bin/daff.rb
25
+ - lib/daff.rb
26
+ - lib/lib/coopy/alignment.rb
27
+ - lib/lib/coopy/cell_builder.rb
28
+ - lib/lib/coopy/cell_info.rb
29
+ - lib/lib/coopy/column_change.rb
30
+ - lib/lib/coopy/combined_table.rb
31
+ - lib/lib/coopy/combined_table_body.rb
32
+ - lib/lib/coopy/combined_table_head.rb
33
+ - lib/lib/coopy/compare_flags.rb
34
+ - lib/lib/coopy/compare_table.rb
35
+ - lib/lib/coopy/conflict_info.rb
36
+ - lib/lib/coopy/coopy.rb
37
+ - lib/lib/coopy/cross_match.rb
38
+ - lib/lib/coopy/csv.rb
39
+ - lib/lib/coopy/diff_render.rb
40
+ - lib/lib/coopy/diff_summary.rb
41
+ - lib/lib/coopy/flat_cell_builder.rb
42
+ - lib/lib/coopy/highlight_patch.rb
43
+ - lib/lib/coopy/highlight_patch_unit.rb
44
+ - lib/lib/coopy/index.rb
45
+ - lib/lib/coopy/index_item.rb
46
+ - lib/lib/coopy/index_pair.rb
47
+ - lib/lib/coopy/json_table.rb
48
+ - lib/lib/coopy/json_tables.rb
49
+ - lib/lib/coopy/merger.rb
50
+ - lib/lib/coopy/meta.rb
51
+ - lib/lib/coopy/mover.rb
52
+ - lib/lib/coopy/ndjson.rb
53
+ - lib/lib/coopy/nested_cell_builder.rb
54
+ - lib/lib/coopy/ordering.rb
55
+ - lib/lib/coopy/property_change.rb
56
+ - lib/lib/coopy/row.rb
57
+ - lib/lib/coopy/row_change.rb
58
+ - lib/lib/coopy/row_stream.rb
59
+ - lib/lib/coopy/simple_meta.rb
60
+ - lib/lib/coopy/simple_table.rb
61
+ - lib/lib/coopy/simple_view.rb
62
+ - lib/lib/coopy/sparse_sheet.rb
63
+ - lib/lib/coopy/sql_column.rb
64
+ - lib/lib/coopy/sql_compare.rb
65
+ - lib/lib/coopy/sql_database.rb
66
+ - lib/lib/coopy/sql_helper.rb
67
+ - lib/lib/coopy/sql_table.rb
68
+ - lib/lib/coopy/sql_table_name.rb
69
+ - lib/lib/coopy/sql_tables.rb
70
+ - lib/lib/coopy/sqlite_helper.rb
71
+ - lib/lib/coopy/table.rb
72
+ - lib/lib/coopy/table_comparison_state.rb
73
+ - lib/lib/coopy/table_diff.rb
74
+ - lib/lib/coopy/table_io.rb
75
+ - lib/lib/coopy/table_modifier.rb
76
+ - lib/lib/coopy/table_stream.rb
77
+ - lib/lib/coopy/table_view.rb
78
+ - lib/lib/coopy/tables.rb
79
+ - lib/lib/coopy/terminal_diff_render.rb
80
+ - lib/lib/coopy/unit.rb
81
+ - lib/lib/coopy/view.rb
82
+ - lib/lib/coopy/viterbi.rb
83
+ - lib/lib/haxe/ds/int_map.rb
84
+ - lib/lib/haxe/ds/string_map.rb
85
+ - lib/lib/haxe/format/json_parser.rb
86
+ - lib/lib/haxe/format/json_printer.rb
87
+ - lib/lib/haxe/imap.rb
88
+ - lib/lib/haxe/io/bytes.rb
89
+ - lib/lib/haxe/io/eof.rb
90
+ - lib/lib/haxe/io/error.rb
91
+ - lib/lib/haxe/io/output.rb
92
+ - lib/lib/hx_overrides.rb
93
+ - lib/lib/hx_sys.rb
94
+ - lib/lib/lambda.rb
95
+ - lib/lib/list.rb
96
+ - lib/lib/math.rb
97
+ - lib/lib/rb/boot.rb
98
+ - lib/lib/rb/ruby_iterator.rb
99
+ - lib/lib/reflect.rb
100
+ - lib/lib/std.rb
101
+ - lib/lib/string_buf.rb
102
+ - lib/lib/sys/io/file_handle.rb
103
+ - lib/lib/sys/io/file_output.rb
104
+ - lib/lib/sys/io/hx_file.rb
105
+ - lib/lib/type.rb
106
+ - lib/lib/value_type.rb
107
+ - lib/lib/x_list/list_iterator.rb
108
+ homepage: https://github.com/everypolitician/daff
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=master)](https://travis-ci.org/paulfitz/daff)
132
+ [![NPM version](https://badge.fury.io/js/daff.svg)](http://badge.fury.io/js/daff)
133
+ [![Gem Version](https://badge.fury.io/rb/daff.svg)](http://badge.fury.io/rb/daff)
134
+ [![PyPI version](https://badge.fury.io/py/daff.svg)](http://badge.fury.io/py/daff)
135
+ [![PHP version](https://badge.fury.io/ph/paulfitz%2Fdaff-php.svg)](http://badge.fury.io/ph/paulfitz%2Fdaff-php)
136
+ [![Bower version](https://badge.fury.io/bo/daff.svg)](http://badge.fury.io/bo/daff)
137
+ ![Badge count](http://img.shields.io/:badges-7/7-33aa33.svg) daff: data diff =============== This
138
+ is a library for comparing tables, producing a summary of their differences, and
139
+ using such a summary as a patch file. It is optimized for comparing tables that
140
+ share a common origin, in other words multiple versions of the "same" table. For
141
+ a live demo, see: > http://paulfitz.github.com/daff/ Install the library for your
142
+ favorite language: ````sh npm install daff -g # node/javascript pip install daff #
143
+ python gem install daff # ruby composer require paulfitz/daff-php # php install.packages(''daff'')
144
+ # R wrapper by Edwin de Jonge bower install daff # web/javascript ```` Other
145
+ translations are available here: > https://github.com/paulfitz/daff/releases Or
146
+ use the library to view csv diffs on github via a chrome extension: > https://github.com/theodi/csvhub The
147
+ diff format used by `daff` is specified here: > http://dataprotocols.org/tabular-diff-format/ This
148
+ library is a stripped down version of the coopy toolbox (see http://share.find.coop). To
149
+ compare tables from different origins, or with automatically generated IDs, or
150
+ other complications, check out the coopy toolbox. The program ----------- You
151
+ can run `daff`/`daff.py`/`daff.rb` as a utility program: ```` $ daff daff can produce
152
+ and apply tabular diffs. Call as: daff [--output OUTPUT.csv] a.csv b.csv daff [--output
153
+ OUTPUT.csv] parent.csv a.csv b.csv daff [--output OUTPUT.ndjson] a.ndjson b.ndjson
154
+ daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv daff merge [--inplace]
155
+ [--output OUTPUT.csv] parent.csv a.csv b.csv daff trim [--output OUTPUT.csv] source.csv
156
+ daff render [--output OUTPUT.html] diff.csv daff git daff version The --inplace
157
+ option to patch and merge will result in modification of a.csv. If you need more
158
+ control, here is the full list of flags: daff diff [--output OUTPUT.csv] [--context
159
+ NUM] [--all] [--act ACT] a.csv b.csv --context NUM: show NUM rows of context --all: do
160
+ not prune unchanged rows --act ACT: show only a certain kind of change (update,
161
+ insert, delete) daff diff --git path old-file old-hex old-mode new-file new-hex
162
+ new-mode --git: process arguments provided by git to diff drivers daff
163
+ render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv --css
164
+ CSS.css: generate a suitable css file to go with the html --fragment: generate
165
+ just a html fragment rather than a page --plain: do not use fancy utf8 characters
166
+ to make arrows prettier ```` Formats supported are CSV, TSV, and [ndjson](http://dataprotocols.org/ndjson/). Using
167
+ with git -------------- Run `daff git csv` to install daff as a diff and merge
168
+ handler for `*.csv` files in your repository. Run `daff git` for instructions on
169
+ doing this manually. Your CSV diffs and merges will get smarter, since git will
170
+ suddenly understand about rows and columns, not just lines: ![Example CSV diff](http://paulfitz.github.io/daff-doc/images/daff_vs_diff.png) The
171
+ library ----------- You can use `daff` as a library from any supported language. We
172
+ take here the example of Javascript. To use `daff` on a webpage, first include
173
+ `daff.js`: ```html <script src="daff.js"></script> ``` Or if using node outside
174
+ the browser: ```js var daff = require(''daff''); ``` For concreteness, assume we
175
+ have two versions of a table, `data1` and `data2`: ```js var data1 = [ [''Country'',''Capital''],
176
+ [''Ireland'',''Dublin''], [''France'',''Paris''], [''Spain'',''Barcelona''] ]; var
177
+ data2 = [ [''Country'',''Code'',''Capital''], [''Ireland'',''ie'',''Dublin''], [''France'',''fr'',''Paris''],
178
+ [''Spain'',''es'',''Madrid''], [''Germany'',''de'',''Berlin''] ]; ``` To make those
179
+ tables accessible to the library, we wrap them in `daff.TableView`: ```js var table1
180
+ = new daff.TableView(data1); var table2 = new daff.TableView(data2); ``` We can
181
+ now compute the alignment between the rows and columns in the two tables: ```js
182
+ var alignment = daff.compareTables(table1,table2).align(); ``` To produce a diff
183
+ from the alignment, we first need a table for the output: ```js var data_diff =
184
+ []; var table_diff = new daff.TableView(data_diff); ``` Using default options for
185
+ the diff: ```js var flags = new daff.CompareFlags(); var highlighter = new daff.TableDiff(alignment,flags);
186
+ highlighter.hilite(table_diff); ``` The diff is now in `data_diff` in highlighter
187
+ format, see specification here: > http://share.find.coop/doc/spec_hilite.html ```js
188
+ [ [ ''!'', '''', ''+++'', '''' ], [ ''@@'', ''Country'', ''Code'', ''Capital'' ],
189
+ [ ''+'', ''Ireland'', ''ie'', ''Dublin'' ], [ ''+'', ''France'', ''fr'', ''Paris''
190
+ ], [ ''->'', ''Spain'', ''es'', ''Barcelona->Madrid'' ], [ ''+++'', ''Germany'',
191
+ ''de'', ''Berlin'' ] ] ``` For visualization, you may want to convert this to a
192
+ HTML table with appropriate classes on cells so you can color-code inserts, deletes,
193
+ updates, etc. You can do this with: ```js var diff2html = new daff.DiffRender();
194
+ diff2html.render(table_diff); var table_diff_html = diff2html.html(); ``` For 3-way
195
+ differences (that is, comparing two tables given knowledge of a common ancestor)
196
+ use `daff.compareTables3` (give ancestor table as the first argument). Here is
197
+ how to apply that difference as a patch: ```js var patcher = new daff.HighlightPatch(table1,table_diff);
198
+ patcher.apply(); // table1 should now equal table2 ``` For other languages, you
199
+ should find sample code in the packages on the [Releases](https://github.com/paulfitz/daff/releases)
200
+ page. Supported languages ------------------- The `daff` library is written in
201
+ [Haxe](http://haxe.org/), which can be translated reasonably well into at least
202
+ the following languages: * Javascript * Python * Java * C# * C++ * Ruby (using
203
+ an [unofficial haxe target](https://github.com/paulfitz/haxe) developed for `daff`) *
204
+ PHP Some translations are done for you on the [Releases](https://github.com/paulfitz/daff/releases)
205
+ page. To make another translation, or to compile from source first follow the [Haxe
206
+ getting started tutorial](http://haxe.org/doc/start) for the language you care about. At
207
+ the time of writing, if you are on OSX, you should install haxe using `brew install
208
+ haxe --HEAD`. Then do one of: ``` make js make php make py make java make cs make
209
+ cpp ``` For each language, the `daff` library expects to be handed an interface
210
+ to tables you create, rather than creating them itself. This is to avoid inefficient
211
+ copies from one format to another. You''ll find a `SimpleTable` class you can use
212
+ if you find this awkward. Other possibilities: * There''s a daff wrapper for R
213
+ written by [Edwin de Jonge](https://github.com/edwindj), see https://github.com/edwindj/daff
214
+ and http://cran.r-project.org/web/packages/daff * There''s a hand-written ruby port
215
+ by [James Smith](https://github.com/Floppy), see https://github.com/theodi/coopy-ruby API
216
+ documentation ----------------- * You can browse the `daff` classes at http://paulfitz.github.io/daff-doc/ Sponsors
217
+ -------- <img src="http://datacommons.coop/images/the_zen_of_venn.png" alt="the
218
+ zen of venn" height="100"> The [Data Commons Co-op](http://datacommons.coop), "perhaps
219
+ the geekiest of all cooperative organizations on the planet," has given great moral
220
+ support during the development of `daff`. Donate a multiple of `42.42` in your currency
221
+ to let them know you care: [http://datacommons.coop/donate/](http://datacommons.coop/donate/) Reading
222
+ material ---------------- * http://dataprotocols.org/tabular-diff-format/ : a specification
223
+ of the diff format we use. * http://theodi.org/blog/csvhub-github-diffs-for-csv-files
224
+ : using this library with github. * https://github.com/ropensci/unconf/issues/19
225
+ : a thread about diffing data in which daff shows up in at least four guises (see
226
+ if you can spot them all). * http://theodi.org/blog/adapting-git-simple-data : using
227
+ this library with gitlab. * http://okfnlabs.org/blog/2013/08/08/diffing-and-patching-data.html
228
+ : a summary of where the library came from. * http://blog.okfn.org/2013/07/02/git-and-github-for-data/
229
+ : a post about storing small data in git/github. * http://blog.ouseful.info/2013/08/27/diff-or-chop-github-csv-data-files-and-openrefine/
230
+ : counterpoint - a post discussing tracked-changes rather than diffs. * http://blog.byronjsmith.com/makefile-shortcuts.html
231
+ : a tutorial on using `make` for data, with daff in the mix. "Since git considers
232
+ changes on a per-line basis, looking at diffs of comma-delimited and tab-delimited
233
+ files can get obnoxious. The program daff fixes this problem." ## License daff
234
+ is distributed under the MIT License.'
235
+ test_files: []