daff 1.3.2 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/daff.rb +11 -2
- data/lib/lib/coopy/alignment.rb +26 -2
- data/lib/lib/coopy/combined_table.rb +127 -0
- data/lib/lib/coopy/combined_table_body.rb +151 -0
- data/lib/lib/coopy/combined_table_head.rb +103 -0
- data/lib/lib/coopy/compare_flags.rb +3 -0
- data/lib/lib/coopy/compare_table.rb +38 -2
- data/lib/lib/coopy/coopy.rb +188 -110
- data/lib/lib/coopy/csv.rb +22 -3
- data/lib/lib/coopy/diff_render.rb +38 -10
- data/lib/lib/coopy/highlight_patch.rb +1 -1
- data/lib/lib/coopy/index.rb +8 -1
- data/lib/lib/coopy/json_table.rb +165 -0
- data/lib/lib/coopy/json_tables.rb +129 -0
- data/lib/lib/coopy/meta.rb +3 -0
- data/lib/lib/coopy/simple_meta.rb +314 -0
- data/lib/lib/coopy/simple_table.rb +4 -0
- data/lib/lib/coopy/simple_view.rb +12 -0
- data/lib/lib/coopy/sql_compare.rb +114 -66
- data/lib/lib/coopy/sql_table.rb +18 -2
- data/lib/lib/coopy/sql_tables.rb +128 -0
- data/lib/lib/coopy/sqlite_helper.rb +23 -1
- data/lib/lib/coopy/table.rb +1 -0
- data/lib/lib/coopy/table_comparison_state.rb +15 -0
- data/lib/lib/coopy/table_diff.rb +115 -5
- data/lib/lib/coopy/tables.rb +52 -0
- data/lib/lib/coopy/terminal_diff_render.rb +24 -8
- data/lib/lib/coopy/view.rb +3 -0
- data/lib/lib/rb/boot.rb +19 -0
- data/lib/lib/reflect.rb +10 -0
- data/lib/lib/std.rb +12 -0
- metadata +27 -16
data/lib/lib/coopy/csv.rb
CHANGED
@@ -104,8 +104,27 @@ module Coopy
|
|
104
104
|
tab.resize(w,h)
|
105
105
|
end
|
106
106
|
if at >= w
|
107
|
-
|
108
|
-
|
107
|
+
if yat > 0
|
108
|
+
if cell != "" && cell != nil
|
109
|
+
context = ""
|
110
|
+
begin
|
111
|
+
_g = 0
|
112
|
+
while(_g < w)
|
113
|
+
i = _g
|
114
|
+
_g+=1
|
115
|
+
context += "," if i > 0
|
116
|
+
begin
|
117
|
+
s = tab.get_cell(i,yat)
|
118
|
+
context += s.to_s
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
puts "Ignored overflowing row " + _hx_str(yat) + " with cell '" + _hx_str(cell) + "' after: " + _hx_str(context)
|
123
|
+
end
|
124
|
+
else
|
125
|
+
w = at + 1
|
126
|
+
tab.resize(w,h)
|
127
|
+
end
|
109
128
|
end
|
110
129
|
tab.set_cell(at,h - 1,cell)
|
111
130
|
at+=1
|
@@ -157,7 +176,7 @@ module Coopy
|
|
157
176
|
@row_ended = true
|
158
177
|
break
|
159
178
|
end
|
160
|
-
if ch == 34
|
179
|
+
if ch == 34
|
161
180
|
if i == @cursor
|
162
181
|
quoting = true
|
163
182
|
quote = ch
|
@@ -69,7 +69,11 @@ module Coopy
|
|
69
69
|
cell_decorate = ""
|
70
70
|
cell_decorate = " class=\"" + _hx_str(mode) + "\"" if mode != ""
|
71
71
|
self.insert(_hx_str(@td_open) + _hx_str(cell_decorate) + ">")
|
72
|
-
|
72
|
+
if txt != nil
|
73
|
+
self.insert(txt)
|
74
|
+
else
|
75
|
+
self.insert("null")
|
76
|
+
end
|
73
77
|
self.insert(@td_close)
|
74
78
|
end
|
75
79
|
|
@@ -144,6 +148,27 @@ module Coopy
|
|
144
148
|
self
|
145
149
|
end
|
146
150
|
|
151
|
+
def render_tables(tabs)
|
152
|
+
order = tabs.get_order
|
153
|
+
self.render(tabs.one) if order.length == 0 || tabs.has_ins_del
|
154
|
+
begin
|
155
|
+
_g1 = 1
|
156
|
+
_g = order.length
|
157
|
+
while(_g1 < _g)
|
158
|
+
i = _g1
|
159
|
+
_g1+=1
|
160
|
+
name = order[i]
|
161
|
+
tab = tabs.get(name)
|
162
|
+
next if tab.get_height <= 1
|
163
|
+
self.insert("<h3>")
|
164
|
+
self.insert(name)
|
165
|
+
self.insert("</h3>\n")
|
166
|
+
self.render(tab)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
self
|
170
|
+
end
|
171
|
+
|
147
172
|
def sample_css
|
148
173
|
".highlighter .add { \n background-color: #7fff7f;\n}\n\n.highlighter .remove { \n background-color: #ff7f7f;\n}\n\n.highlighter td.modify { \n background-color: #7f7fff;\n}\n\n.highlighter td.conflict { \n background-color: #f00;\n}\n\n.highlighter .spec { \n background-color: #aaa;\n}\n\n.highlighter .move { \n background-color: #ffa;\n}\n\n.highlighter .null { \n color: #888;\n}\n\n.highlighter table { \n border-collapse:collapse;\n}\n\n.highlighter td, .highlighter th {\n border: 1px solid #2D4068;\n padding: 3px 7px 2px;\n}\n\n.highlighter th, .highlighter .header, .highlighter .meta {\n background-color: #aaf;\n font-weight: bold;\n padding-bottom: 4px;\n padding-top: 5px;\n text-align:left;\n}\n\n.highlighter tr.header th {\n border-bottom: 2px solid black;\n}\n\n.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {\n background-color: white;\n border: none;\n}\n\n.highlighter .gap {\n color: #888;\n}\n\n.highlighter td {\n empty-cells: show;\n}\n"
|
149
174
|
end
|
@@ -157,8 +182,6 @@ module Coopy
|
|
157
182
|
|
158
183
|
def DiffRender.examine_cell(x,y,view,raw,vcol,vrow,vcorner,cell,offset = 0)
|
159
184
|
nested = view.is_hash(raw)
|
160
|
-
value = nil
|
161
|
-
value = view.to_s(raw) if !nested
|
162
185
|
cell.category = ""
|
163
186
|
cell.category_given_tr = ""
|
164
187
|
cell.separator = ""
|
@@ -166,8 +189,7 @@ module Coopy
|
|
166
189
|
cell.conflicted = false
|
167
190
|
cell.updated = false
|
168
191
|
cell.meta = cell.pvalue = cell.lvalue = cell.rvalue = nil
|
169
|
-
cell.value =
|
170
|
-
cell.value = "" if cell.value == nil
|
192
|
+
cell.value = raw
|
171
193
|
cell.pretty_value = cell.value
|
172
194
|
vrow = "" if vrow == nil
|
173
195
|
vcol = "" if vcol == nil
|
@@ -204,14 +226,16 @@ module Coopy
|
|
204
226
|
full = vrow
|
205
227
|
part = tokens[1]
|
206
228
|
part = full if part == nil
|
207
|
-
|
229
|
+
str = view.to_s(cell.value)
|
230
|
+
str = "" if str == nil
|
231
|
+
if nested || (str.index(part,nil || 0) || -1) >= 0
|
208
232
|
cat = "modify"
|
209
233
|
div = part
|
210
234
|
if part != full
|
211
235
|
if nested
|
212
236
|
cell.conflicted = view.hash_exists(raw,"theirs")
|
213
237
|
else
|
214
|
-
cell.conflicted = (
|
238
|
+
cell.conflicted = (str.index(full,nil || 0) || -1) >= 0
|
215
239
|
end
|
216
240
|
if cell.conflicted
|
217
241
|
div = full
|
@@ -227,10 +251,14 @@ module Coopy
|
|
227
251
|
else
|
228
252
|
tokens = [view.hash_get(raw,"before"),view.hash_get(raw,"after")]
|
229
253
|
end
|
230
|
-
elsif cell.pretty_value == div
|
231
|
-
tokens = ["",""]
|
232
254
|
else
|
233
|
-
|
255
|
+
cell.pretty_value = view.to_s(cell.pretty_value)
|
256
|
+
cell.pretty_value = "" if cell.pretty_value == nil
|
257
|
+
if cell.pretty_value == div
|
258
|
+
tokens = ["",""]
|
259
|
+
else
|
260
|
+
tokens = cell.pretty_value.split(div)
|
261
|
+
end
|
234
262
|
end
|
235
263
|
pretty_tokens = tokens
|
236
264
|
if tokens.length >= 2
|
data/lib/lib/coopy/index.rb
CHANGED
@@ -12,7 +12,11 @@ module Coopy
|
|
12
12
|
@height = 0
|
13
13
|
@hdr = 0
|
14
14
|
@ignore_whitespace = false
|
15
|
-
@
|
15
|
+
@ignore_case = false
|
16
|
+
if flags != nil
|
17
|
+
@ignore_whitespace = flags.ignore_whitespace
|
18
|
+
@ignore_case = flags.ignore_case
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
attr_accessor :items
|
@@ -27,6 +31,7 @@ module Coopy
|
|
27
31
|
attr_accessor :indexed_table
|
28
32
|
attr_accessor :hdr
|
29
33
|
attr_accessor :ignore_whitespace
|
34
|
+
attr_accessor :ignore_case
|
30
35
|
|
31
36
|
public
|
32
37
|
|
@@ -83,6 +88,7 @@ module Coopy
|
|
83
88
|
d = t.get_cell(@cols[k],i)
|
84
89
|
txt = @v.to_s(d)
|
85
90
|
txt = txt.strip if @ignore_whitespace
|
91
|
+
txt = txt.downcase if @ignore_case
|
86
92
|
wide += " // " if k > 0
|
87
93
|
next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
|
88
94
|
wide += txt
|
@@ -106,6 +112,7 @@ module Coopy
|
|
106
112
|
_g1+=1
|
107
113
|
txt = row.get_row_string(@cols[k])
|
108
114
|
txt = txt.strip if @ignore_whitespace
|
115
|
+
txt = txt.downcase if @ignore_case
|
109
116
|
wide += " // " if k > 0
|
110
117
|
next if txt == nil || txt == "" || txt == "null" || txt == "undefined"
|
111
118
|
wide += txt
|
@@ -0,0 +1,165 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class JsonTable
|
6
|
+
|
7
|
+
def initialize(data,name)
|
8
|
+
@data = data
|
9
|
+
@columns = Reflect.field(data,"columns")
|
10
|
+
@rows = Reflect.field(data,"rows")
|
11
|
+
@w = @columns.length
|
12
|
+
@h = @rows.length
|
13
|
+
@idx2col = {}
|
14
|
+
begin
|
15
|
+
_g1 = 0
|
16
|
+
_g = @columns.length
|
17
|
+
while(_g1 < _g)
|
18
|
+
idx = _g1
|
19
|
+
_g1+=1
|
20
|
+
begin
|
21
|
+
v = @columns[idx]
|
22
|
+
@idx2col[idx] = v
|
23
|
+
v
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
@name = name
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
attr_accessor :w
|
33
|
+
attr_accessor :h
|
34
|
+
attr_accessor :columns
|
35
|
+
attr_accessor :rows
|
36
|
+
attr_accessor :data
|
37
|
+
attr_accessor :idx2col
|
38
|
+
attr_accessor :name
|
39
|
+
|
40
|
+
public
|
41
|
+
|
42
|
+
def get_table
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def height() get_height end
|
47
|
+
def height=(__v) @height = __v end
|
48
|
+
def width() get_width end
|
49
|
+
def width=(__v) @width = __v end
|
50
|
+
|
51
|
+
def get_width
|
52
|
+
@w
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_height
|
56
|
+
@h + 1
|
57
|
+
end
|
58
|
+
|
59
|
+
def get_cell(x,y)
|
60
|
+
return @idx2col[x] if y == 0
|
61
|
+
Reflect.field(@rows[y - 1],@idx2col[x])
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_cell(x,y,c)
|
65
|
+
puts "JsonTable is read-only"
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
""
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_cell_view
|
73
|
+
::Coopy::SimpleView.new
|
74
|
+
end
|
75
|
+
|
76
|
+
def is_resizable
|
77
|
+
false
|
78
|
+
end
|
79
|
+
|
80
|
+
def resize(w,h)
|
81
|
+
false
|
82
|
+
end
|
83
|
+
|
84
|
+
def clear
|
85
|
+
end
|
86
|
+
|
87
|
+
def insert_or_delete_rows(fate,hfate)
|
88
|
+
false
|
89
|
+
end
|
90
|
+
|
91
|
+
def insert_or_delete_columns(fate,wfate)
|
92
|
+
false
|
93
|
+
end
|
94
|
+
|
95
|
+
def trim_blank
|
96
|
+
false
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_data
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def clone
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def set_meta(meta)
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_meta
|
111
|
+
self
|
112
|
+
end
|
113
|
+
|
114
|
+
def create
|
115
|
+
::Coopy::JsonTable.new(nil,nil)
|
116
|
+
end
|
117
|
+
|
118
|
+
def alter_columns(columns)
|
119
|
+
false
|
120
|
+
end
|
121
|
+
|
122
|
+
def change_row(rc)
|
123
|
+
false
|
124
|
+
end
|
125
|
+
|
126
|
+
def apply_flags(flags)
|
127
|
+
false
|
128
|
+
end
|
129
|
+
|
130
|
+
def as_table
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def clone_meta(table = nil)
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
|
138
|
+
def use_for_column_changes
|
139
|
+
false
|
140
|
+
end
|
141
|
+
|
142
|
+
def use_for_row_changes
|
143
|
+
false
|
144
|
+
end
|
145
|
+
|
146
|
+
def get_row_stream
|
147
|
+
nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def is_nested
|
151
|
+
false
|
152
|
+
end
|
153
|
+
|
154
|
+
def is_sql
|
155
|
+
false
|
156
|
+
end
|
157
|
+
|
158
|
+
def get_name
|
159
|
+
@name
|
160
|
+
end
|
161
|
+
|
162
|
+
haxe_me ["coopy", "JsonTable"]
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Coopy
|
5
|
+
class JsonTables
|
6
|
+
|
7
|
+
def initialize(json,flags)
|
8
|
+
@db = json
|
9
|
+
names = Reflect.field(json,"names")
|
10
|
+
allowed = nil
|
11
|
+
count = names.length
|
12
|
+
if flags.tables != nil
|
13
|
+
allowed = {}
|
14
|
+
begin
|
15
|
+
_g = 0
|
16
|
+
_g1 = flags.tables
|
17
|
+
while(_g < _g1.length)
|
18
|
+
name = _g1[_g]
|
19
|
+
_g+=1
|
20
|
+
allowed[name] = true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
count = 0
|
24
|
+
begin
|
25
|
+
_g2 = 0
|
26
|
+
while(_g2 < names.length)
|
27
|
+
name1 = names[_g2]
|
28
|
+
_g2+=1
|
29
|
+
count+=1 if allowed.include?(name1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@t = ::Coopy::SimpleTable.new(2,count + 1)
|
34
|
+
@t.set_cell(0,0,"name")
|
35
|
+
@t.set_cell(1,0,"table")
|
36
|
+
v = @t.get_cell_view
|
37
|
+
at = 1
|
38
|
+
begin
|
39
|
+
_g3 = 0
|
40
|
+
while(_g3 < names.length)
|
41
|
+
name2 = names[_g3]
|
42
|
+
_g3+=1
|
43
|
+
if allowed != nil
|
44
|
+
next if !allowed.include?(name2)
|
45
|
+
end
|
46
|
+
@t.set_cell(0,at,name2)
|
47
|
+
tab = Reflect.field(@db,"tables")
|
48
|
+
tab = Reflect.field(tab,name2)
|
49
|
+
@t.set_cell(1,at,v.wrap_table(::Coopy::JsonTable.new(tab,name2)))
|
50
|
+
at+=1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
attr_accessor :db
|
58
|
+
attr_accessor :t
|
59
|
+
attr_accessor :flags
|
60
|
+
|
61
|
+
public
|
62
|
+
|
63
|
+
def height() get_height end
|
64
|
+
def height=(__v) @height = __v end
|
65
|
+
def width() get_width end
|
66
|
+
def width=(__v) @width = __v end
|
67
|
+
|
68
|
+
def get_cell(x,y)
|
69
|
+
@t.get_cell(x,y)
|
70
|
+
end
|
71
|
+
|
72
|
+
def set_cell(x,y,c)
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_cell_view
|
76
|
+
@t.get_cell_view
|
77
|
+
end
|
78
|
+
|
79
|
+
def is_resizable
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
83
|
+
def resize(w,h)
|
84
|
+
false
|
85
|
+
end
|
86
|
+
|
87
|
+
def clear
|
88
|
+
end
|
89
|
+
|
90
|
+
def insert_or_delete_rows(fate,hfate)
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
def insert_or_delete_columns(fate,wfate)
|
95
|
+
false
|
96
|
+
end
|
97
|
+
|
98
|
+
def trim_blank
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_width
|
103
|
+
@t.get_width
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_height
|
107
|
+
@t.get_height
|
108
|
+
end
|
109
|
+
|
110
|
+
def get_data
|
111
|
+
nil
|
112
|
+
end
|
113
|
+
|
114
|
+
def clone
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_meta
|
119
|
+
::Coopy::SimpleMeta.new(self,true,true)
|
120
|
+
end
|
121
|
+
|
122
|
+
def create
|
123
|
+
::Coopy::JsonTables.new(nil,nil)
|
124
|
+
end
|
125
|
+
|
126
|
+
haxe_me ["coopy", "JsonTables"]
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|