daff 1.2.3 → 1.2.4
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.
- data/README.md +4 -1
- data/lib/daff.rb +20 -7
- data/lib/lib/coopy/alignment.rb +6 -0
- data/lib/lib/coopy/cell_info.rb +1 -0
- data/lib/lib/coopy/compare_flags.rb +2 -0
- data/lib/lib/coopy/compare_table.rb +1 -1
- data/lib/lib/coopy/coopy.rb +80 -18
- data/lib/lib/coopy/csv.rb +1 -1
- data/lib/lib/coopy/diff_render.rb +61 -22
- data/lib/lib/coopy/flat_cell_builder.rb +1 -1
- data/lib/lib/coopy/highlight_patch.rb +8 -6
- data/lib/lib/coopy/mover.rb +1 -1
- data/lib/lib/coopy/ndjson.rb +134 -0
- data/lib/lib/coopy/nested_cell_builder.rb +74 -0
- data/lib/lib/coopy/simple_view.rb +29 -0
- data/lib/lib/coopy/sql_column.rb +35 -0
- data/lib/lib/coopy/sql_compare.rb +245 -0
- data/lib/lib/coopy/sql_database.rb +19 -0
- data/lib/lib/coopy/sql_helper.rb +12 -0
- data/lib/lib/coopy/sql_table.rb +216 -0
- data/lib/lib/coopy/sql_table_name.rb +23 -0
- data/lib/lib/coopy/sqlite_helper.rb +47 -0
- data/lib/lib/coopy/table_diff.rb +18 -6
- data/lib/lib/coopy/table_io.rb +5 -0
- data/lib/lib/coopy/terminal_diff_render.rb +8 -9
- data/lib/lib/coopy/view.rb +5 -0
- data/lib/lib/haxe/ds/int_map.rb +4 -0
- data/lib/lib/haxe/ds/string_map.rb +4 -0
- data/lib/lib/haxe/format/json_parser.rb +8 -8
- data/lib/lib/haxe/imap.rb +1 -0
- data/lib/lib/haxe/io/bytes.rb +1 -1
- data/lib/lib/haxe/io/bytes_output.rb +1 -1
- data/lib/lib/haxe/io/error.rb +1 -0
- data/lib/lib/haxe/io/output.rb +2 -2
- data/lib/lib/hx_overrides.rb +12 -0
- data/lib/lib/hx_sys.rb +1 -1
- data/lib/lib/rb/boot.rb +5 -1
- data/lib/lib/reflect.rb +1 -0
- data/lib/lib/sys/io/file_handle.rb +1 -0
- data/lib/lib/sys/io/file_output.rb +1 -1
- data/lib/lib/value_type.rb +1 -0
- metadata +36 -25
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SqlDatabase
|
6
|
+
def getColumns(name) puts "Abstract SqlDatabase.getColumns called" end
|
7
|
+
def getQuotedTableName(name) puts "Abstract SqlDatabase.getQuotedTableName called" end
|
8
|
+
def getQuotedColumnName(name) puts "Abstract SqlDatabase.getQuotedColumnName called" end
|
9
|
+
def begin(query,args = nil,order = nil) puts "Abstract SqlDatabase.begin called" end
|
10
|
+
def beginRow(name,row,order = nil) puts "Abstract SqlDatabase.beginRow called" end
|
11
|
+
def read() puts "Abstract SqlDatabase.read called" end
|
12
|
+
def get(index) puts "Abstract SqlDatabase.get called" end
|
13
|
+
def end() puts "Abstract SqlDatabase.end called" end
|
14
|
+
def width() puts "Abstract SqlDatabase.width called" end
|
15
|
+
def rowid() puts "Abstract SqlDatabase.rowid called" end
|
16
|
+
haxe_me
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SqlHelper
|
6
|
+
def getTableNames(db) puts "Abstract SqlHelper.getTableNames called" end
|
7
|
+
def countRows(db,name) puts "Abstract SqlHelper.countRows called" end
|
8
|
+
def getRowIDs(db,name) puts "Abstract SqlHelper.getRowIDs called" end
|
9
|
+
haxe_me
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SqlTable
|
6
|
+
|
7
|
+
def initialize(db,name,helper = nil)
|
8
|
+
@db = db
|
9
|
+
@name = name
|
10
|
+
@helper = helper
|
11
|
+
@cache = {}
|
12
|
+
@h = -1
|
13
|
+
@id2rid = nil
|
14
|
+
self.get_columns
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
attr_accessor :db
|
20
|
+
attr_accessor :columns
|
21
|
+
attr_accessor :name
|
22
|
+
attr_accessor :quoted_table_name
|
23
|
+
attr_accessor :cache
|
24
|
+
attr_accessor :column_names
|
25
|
+
attr_accessor :h
|
26
|
+
attr_accessor :helper
|
27
|
+
attr_accessor :id2rid
|
28
|
+
|
29
|
+
def get_columns
|
30
|
+
return if @columns != nil
|
31
|
+
return if @db == nil
|
32
|
+
@columns = @db.get_columns(@name)
|
33
|
+
@column_names = Array.new
|
34
|
+
begin
|
35
|
+
_g = 0
|
36
|
+
_g1 = @columns
|
37
|
+
while(_g < _g1.length)
|
38
|
+
col = _g1[_g]
|
39
|
+
_g+=1
|
40
|
+
@column_names.push(col.get_name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
public
|
46
|
+
|
47
|
+
def get_primary_key
|
48
|
+
self.get_columns
|
49
|
+
result = Array.new
|
50
|
+
begin
|
51
|
+
_g = 0
|
52
|
+
_g1 = @columns
|
53
|
+
while(_g < _g1.length)
|
54
|
+
col = _g1[_g]
|
55
|
+
_g+=1
|
56
|
+
next if !col.is_primary_key
|
57
|
+
result.push(col.get_name)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
return result
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_all_but_primary_key
|
64
|
+
self.get_columns
|
65
|
+
result = Array.new
|
66
|
+
begin
|
67
|
+
_g = 0
|
68
|
+
_g1 = @columns
|
69
|
+
while(_g < _g1.length)
|
70
|
+
col = _g1[_g]
|
71
|
+
_g+=1
|
72
|
+
next if col.is_primary_key
|
73
|
+
result.push(col.get_name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
return result
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_column_names
|
80
|
+
self.get_columns
|
81
|
+
return @column_names
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_quoted_table_name
|
85
|
+
return @quoted_table_name if @quoted_table_name != nil
|
86
|
+
@quoted_table_name = @db.get_quoted_table_name(@name)
|
87
|
+
return @quoted_table_name
|
88
|
+
end
|
89
|
+
|
90
|
+
def get_quoted_column_name(name)
|
91
|
+
return @db.get_quoted_column_name(name)
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_cell(x,y)
|
95
|
+
if @h >= 0
|
96
|
+
y = y - 1
|
97
|
+
y = @id2rid[y] if y >= 0
|
98
|
+
end
|
99
|
+
if y < 0
|
100
|
+
self.get_columns
|
101
|
+
return @columns[x].name
|
102
|
+
end
|
103
|
+
row = @cache[y]
|
104
|
+
if row == nil
|
105
|
+
row = {}
|
106
|
+
self.get_columns
|
107
|
+
@db.begin_row(@name,y,@column_names)
|
108
|
+
while(@db.read)
|
109
|
+
_g1 = 0
|
110
|
+
_g = self.get_width
|
111
|
+
while(_g1 < _g)
|
112
|
+
i = _g1
|
113
|
+
_g1+=1
|
114
|
+
begin
|
115
|
+
v = @db.get(i)
|
116
|
+
begin
|
117
|
+
value = v
|
118
|
+
row[i] = value
|
119
|
+
end
|
120
|
+
v
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
@db._end
|
125
|
+
begin
|
126
|
+
@cache[y] = row
|
127
|
+
row
|
128
|
+
end
|
129
|
+
end
|
130
|
+
begin
|
131
|
+
this1 = @cache[y]
|
132
|
+
return this1.get(x)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def set_cell_cache(x,y,c)
|
137
|
+
row = @cache[y]
|
138
|
+
if row == nil
|
139
|
+
row = {}
|
140
|
+
self.get_columns
|
141
|
+
begin
|
142
|
+
@cache[y] = row
|
143
|
+
row
|
144
|
+
end
|
145
|
+
end
|
146
|
+
begin
|
147
|
+
v = c
|
148
|
+
begin
|
149
|
+
value = v
|
150
|
+
row[x] = value
|
151
|
+
end
|
152
|
+
v
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def set_cell(x,y,c)
|
157
|
+
puts "SqlTable cannot set cells yet"
|
158
|
+
end
|
159
|
+
|
160
|
+
def get_cell_view
|
161
|
+
return ::Coopy::SimpleView.new
|
162
|
+
end
|
163
|
+
|
164
|
+
def is_resizable
|
165
|
+
return false
|
166
|
+
end
|
167
|
+
|
168
|
+
def resize(w,h)
|
169
|
+
return false
|
170
|
+
end
|
171
|
+
|
172
|
+
def clear
|
173
|
+
end
|
174
|
+
|
175
|
+
def insert_or_delete_rows(fate,hfate)
|
176
|
+
return false
|
177
|
+
end
|
178
|
+
|
179
|
+
def insert_or_delete_columns(fate,wfate)
|
180
|
+
return false
|
181
|
+
end
|
182
|
+
|
183
|
+
def trim_blank
|
184
|
+
return false
|
185
|
+
end
|
186
|
+
|
187
|
+
def height() get_height end
|
188
|
+
def height=(__v) @height = __v end
|
189
|
+
def width() get_width end
|
190
|
+
def width=(__v) @width = __v end
|
191
|
+
|
192
|
+
def get_width
|
193
|
+
self.get_columns
|
194
|
+
return @columns.length
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_height
|
198
|
+
return @h if @h >= 0
|
199
|
+
return -1 if @helper == nil
|
200
|
+
@id2rid = @helper.get_row_ids(@db,@name)
|
201
|
+
@h = @id2rid.length + 1
|
202
|
+
return @h
|
203
|
+
end
|
204
|
+
|
205
|
+
def get_data
|
206
|
+
return nil
|
207
|
+
end
|
208
|
+
|
209
|
+
def clone
|
210
|
+
return nil
|
211
|
+
end
|
212
|
+
|
213
|
+
haxe_me
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SqlTableName
|
6
|
+
|
7
|
+
def initialize(name = "",prefix = "")
|
8
|
+
@name = name
|
9
|
+
@prefix = prefix
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :name
|
13
|
+
attr_accessor :prefix
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
return @name if @prefix == ""
|
17
|
+
return _hx_str(@prefix) + "." + _hx_str(@name)
|
18
|
+
end
|
19
|
+
|
20
|
+
haxe_me
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class SqliteHelper
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_table_names(db)
|
11
|
+
q = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
|
12
|
+
return nil if !db._begin(q,nil,["name"])
|
13
|
+
names = Array.new
|
14
|
+
while(db.read)
|
15
|
+
names.push(db.get(0))
|
16
|
+
end
|
17
|
+
db._end
|
18
|
+
return names
|
19
|
+
end
|
20
|
+
|
21
|
+
def count_rows(db,name)
|
22
|
+
q = "SELECT COUNT(*) AS ct FROM " + _hx_str(db.get_quoted_table_name(name))
|
23
|
+
return -1 if !db._begin(q,nil,["ct"])
|
24
|
+
ct = -1
|
25
|
+
while(db.read)
|
26
|
+
ct = db.get(0)
|
27
|
+
end
|
28
|
+
db._end
|
29
|
+
return ct
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_row_ids(db,name)
|
33
|
+
result = Array.new
|
34
|
+
q = "SELECT ROWID AS r FROM " + _hx_str(db.get_quoted_table_name(name)) + " ORDER BY ROWID"
|
35
|
+
return nil if !db._begin(q,nil,["r"])
|
36
|
+
while(db.read)
|
37
|
+
c = db.get(0)
|
38
|
+
result.push(c)
|
39
|
+
end
|
40
|
+
db._end
|
41
|
+
return result
|
42
|
+
end
|
43
|
+
|
44
|
+
haxe_me
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/lib/lib/coopy/table_diff.rb
CHANGED
@@ -89,7 +89,7 @@ module Coopy
|
|
89
89
|
score+=1
|
90
90
|
end
|
91
91
|
end
|
92
|
-
str = "_" + _hx_str(str) if str
|
92
|
+
str = "_" + _hx_str(str) if HxOverrides.substr(str,score,nil) == _nil
|
93
93
|
return str
|
94
94
|
end
|
95
95
|
|
@@ -216,7 +216,13 @@ module Coopy
|
|
216
216
|
|
217
217
|
def hilite(output)
|
218
218
|
return false if !output.is_resizable
|
219
|
-
|
219
|
+
if @builder == nil
|
220
|
+
if @flags.allow_nested_cells
|
221
|
+
@builder = ::Coopy::NestedCellBuilder.new
|
222
|
+
else
|
223
|
+
@builder = ::Coopy::FlatCellBuilder.new
|
224
|
+
end
|
225
|
+
end
|
220
226
|
output.resize(0,0)
|
221
227
|
output.clear
|
222
228
|
row_map = {}
|
@@ -453,9 +459,9 @@ module Coopy
|
|
453
459
|
_g110+=1
|
454
460
|
cunit2 = column_units[j3]
|
455
461
|
if cunit2.r >= 0
|
456
|
-
output.set_cell(j3 + 1,at1,b.get_cell(cunit2.r,rb_header)) if b.get_height
|
462
|
+
output.set_cell(j3 + 1,at1,b.get_cell(cunit2.r,rb_header)) if b.get_height != 0
|
457
463
|
elsif cunit2.lp >= 0
|
458
|
-
output.set_cell(j3 + 1,at1,p.get_cell(cunit2.lp,rp_header)) if p.get_height
|
464
|
+
output.set_cell(j3 + 1,at1,p.get_cell(cunit2.lp,rp_header)) if p.get_height != 0
|
459
465
|
end
|
460
466
|
col_map[j3 + 1] = cunit2
|
461
467
|
end
|
@@ -698,7 +704,10 @@ module Coopy
|
|
698
704
|
i7 = _g114
|
699
705
|
_g114+=1
|
700
706
|
unit2 = row_map[i7]
|
701
|
-
|
707
|
+
if unit2 == nil
|
708
|
+
output.set_cell(0,i7,"")
|
709
|
+
next
|
710
|
+
end
|
702
711
|
output.set_cell(0,i7,@builder.links(unit2))
|
703
712
|
end
|
704
713
|
end
|
@@ -720,7 +729,10 @@ module Coopy
|
|
720
729
|
i9 = _g116
|
721
730
|
_g116+=1
|
722
731
|
unit3 = col_map[i9 - 1]
|
723
|
-
|
732
|
+
if unit3 == nil
|
733
|
+
output.set_cell(i9,0,"")
|
734
|
+
next
|
735
|
+
end
|
724
736
|
output.set_cell(i9,0,@builder.links(unit3))
|
725
737
|
end
|
726
738
|
end
|
data/lib/lib/coopy/table_io.rb
CHANGED
@@ -32,6 +32,7 @@ module Coopy
|
|
32
32
|
begin
|
33
33
|
return HxSys.command(cmd,args)
|
34
34
|
rescue => e
|
35
|
+
e = hx_rescued(e)
|
35
36
|
return 1
|
36
37
|
end
|
37
38
|
end
|
@@ -44,6 +45,10 @@ module Coopy
|
|
44
45
|
return File.exist?(path)
|
45
46
|
end
|
46
47
|
|
48
|
+
def open_sqlite_database(path)
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
|
47
52
|
haxe_me
|
48
53
|
end
|
49
54
|
|
@@ -11,7 +11,7 @@ module Coopy
|
|
11
11
|
protected
|
12
12
|
|
13
13
|
attr_accessor :codes
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :t
|
15
15
|
attr_accessor :csv
|
16
16
|
attr_accessor :v
|
17
17
|
attr_accessor :align_columns
|
@@ -28,8 +28,8 @@ module Coopy
|
|
28
28
|
w = t.get_width
|
29
29
|
h = t.get_height
|
30
30
|
txt = ""
|
31
|
+
@t = t
|
31
32
|
@v = t.get_cell_view
|
32
|
-
@tt = ::Coopy::TableText.new(t)
|
33
33
|
@codes = {}
|
34
34
|
@codes["header"] = "\x1B[0;1m"
|
35
35
|
@codes["spec"] = "\x1B[35;1m"
|
@@ -70,7 +70,8 @@ module Coopy
|
|
70
70
|
txt += "\r\n"
|
71
71
|
end
|
72
72
|
end
|
73
|
-
@
|
73
|
+
@t = nil
|
74
|
+
@v = nil
|
74
75
|
@csv = nil
|
75
76
|
@codes = nil
|
76
77
|
return txt
|
@@ -79,9 +80,8 @@ module Coopy
|
|
79
80
|
protected
|
80
81
|
|
81
82
|
def get_text(x,y,color)
|
82
|
-
val = @
|
83
|
-
|
84
|
-
cell = ::Coopy::DiffRender.render_cell(@tt,x,y)
|
83
|
+
val = @t.get_cell(x,y)
|
84
|
+
cell = ::Coopy::DiffRender.render_cell(@t,@v,x,y)
|
85
85
|
if color
|
86
86
|
code = nil
|
87
87
|
code = @codes[cell.category] if cell.category != nil
|
@@ -92,10 +92,10 @@ module Coopy
|
|
92
92
|
if code != nil
|
93
93
|
if cell.rvalue != nil
|
94
94
|
val = _hx_str(@codes["remove"]) + _hx_str(cell.lvalue) + _hx_str(@codes["modify"]) + _hx_str(cell.pretty_separator) + _hx_str(@codes["add"]) + _hx_str(cell.rvalue) + _hx_str(@codes["done"])
|
95
|
-
val = _hx_str(@codes["conflict"]) + _hx_str(cell.pvalue) + _hx_str(@codes["modify"]) + _hx_str(cell.pretty_separator) + _hx_str(val) if cell.pvalue != nil
|
95
|
+
val = _hx_str(@codes["conflict"]) + _hx_str(cell.pvalue) + _hx_str(@codes["modify"]) + _hx_str(cell.pretty_separator) + _hx_str(val.to_s) if cell.pvalue != nil
|
96
96
|
else
|
97
97
|
val = cell.pretty_value
|
98
|
-
val = _hx_str(code) + _hx_str(val) + _hx_str(@codes["done"])
|
98
|
+
val = _hx_str(code) + _hx_str(val.to_s) + _hx_str(@codes["done"])
|
99
99
|
end
|
100
100
|
end
|
101
101
|
else
|
@@ -108,7 +108,6 @@ module Coopy
|
|
108
108
|
w = t.get_width
|
109
109
|
h = t.get_height
|
110
110
|
v = t.get_cell_view
|
111
|
-
tt = ::Coopy::TableText.new(t)
|
112
111
|
csv = ::Coopy::Csv.new
|
113
112
|
sizes = Array.new
|
114
113
|
row = -1
|