daff 1.1.2
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/bin/daff.rb +3 -0
- data/lib/daff.rb +95 -0
- data/lib/lib/coopy/alignment.rb +409 -0
- data/lib/lib/coopy/bag.rb +10 -0
- data/lib/lib/coopy/cell_info.rb +29 -0
- data/lib/lib/coopy/change.rb +48 -0
- data/lib/lib/coopy/change_type.rb +21 -0
- data/lib/lib/coopy/compare.rb +98 -0
- data/lib/lib/coopy/compare_flags.rb +46 -0
- data/lib/lib/coopy/compare_table.rb +402 -0
- data/lib/lib/coopy/coopy.rb +414 -0
- data/lib/lib/coopy/cross_match.rb +16 -0
- data/lib/lib/coopy/csv.rb +181 -0
- data/lib/lib/coopy/diff_render.rb +254 -0
- data/lib/lib/coopy/highlight_patch.rb +651 -0
- data/lib/lib/coopy/highlight_patch_unit.rb +37 -0
- data/lib/lib/coopy/index.rb +101 -0
- data/lib/lib/coopy/index_item.rb +20 -0
- data/lib/lib/coopy/index_pair.rb +87 -0
- data/lib/lib/coopy/mover.rb +195 -0
- data/lib/lib/coopy/ordering.rb +49 -0
- data/lib/lib/coopy/report.rb +23 -0
- data/lib/lib/coopy/row.rb +9 -0
- data/lib/lib/coopy/simple_cell.rb +23 -0
- data/lib/lib/coopy/simple_table.rb +242 -0
- data/lib/lib/coopy/simple_view.rb +41 -0
- data/lib/lib/coopy/sparse_sheet.rb +50 -0
- data/lib/lib/coopy/table.rb +17 -0
- data/lib/lib/coopy/table_comparison_state.rb +32 -0
- data/lib/lib/coopy/table_diff.rb +738 -0
- data/lib/lib/coopy/table_io.rb +33 -0
- data/lib/lib/coopy/table_modifier.rb +39 -0
- data/lib/lib/coopy/table_text.rb +25 -0
- data/lib/lib/coopy/unit.rb +70 -0
- data/lib/lib/coopy/view.rb +14 -0
- data/lib/lib/coopy/viewed_datum.rb +37 -0
- data/lib/lib/coopy/viterbi.rb +172 -0
- data/lib/lib/coopy/workspace.rb +22 -0
- data/lib/lib/haxe/ds/int_map.rb +14 -0
- data/lib/lib/haxe/ds/string_map.rb +14 -0
- data/lib/lib/haxe/format/json_parser.rb +264 -0
- data/lib/lib/haxe/format/json_printer.rb +239 -0
- data/lib/lib/haxe/io/bytes.rb +33 -0
- data/lib/lib/haxe/io/eof.rb +17 -0
- data/lib/lib/haxe/io/error.rb +21 -0
- data/lib/lib/haxe/io/output.rb +40 -0
- data/lib/lib/haxe/log.rb +16 -0
- data/lib/lib/hx_overrides.rb +18 -0
- data/lib/lib/imap.rb +6 -0
- data/lib/lib/lambda.rb +36 -0
- data/lib/lib/list.rb +42 -0
- data/lib/lib/rb/boot.rb +19 -0
- data/lib/lib/rb/ruby_iterator.rb +49 -0
- data/lib/lib/reflect.rb +29 -0
- data/lib/lib/string_buf.rb +14 -0
- data/lib/lib/sys.rb +19 -0
- data/lib/lib/sys/io/file.rb +19 -0
- data/lib/lib/sys/io/file_handle.rb +17 -0
- data/lib/lib/sys/io/file_output.rb +35 -0
- data/lib/lib/type.rb +32 -0
- data/lib/lib/value_type.rb +22 -0
- metadata +181 -0
@@ -0,0 +1,264 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Haxe
|
5
|
+
module Format
|
6
|
+
class JsonParser
|
7
|
+
|
8
|
+
def initialize(str)
|
9
|
+
@str = str
|
10
|
+
@pos = 0
|
11
|
+
end
|
12
|
+
|
13
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
14
|
+
|
15
|
+
attr_accessor :str
|
16
|
+
attr_accessor :pos
|
17
|
+
|
18
|
+
def parse_rec
|
19
|
+
while(true)
|
20
|
+
c = nil
|
21
|
+
begin
|
22
|
+
index = @pos
|
23
|
+
@pos+=1
|
24
|
+
c = (@str[index] || 0).ord
|
25
|
+
end
|
26
|
+
case(c)
|
27
|
+
when 32,13,10,9
|
28
|
+
when 123
|
29
|
+
obj = { }
|
30
|
+
field = nil
|
31
|
+
comma = nil
|
32
|
+
while(true)
|
33
|
+
c1 = nil
|
34
|
+
begin
|
35
|
+
index1 = @pos
|
36
|
+
@pos+=1
|
37
|
+
c1 = (@str[index1] || 0).ord
|
38
|
+
end
|
39
|
+
case(c1)
|
40
|
+
when 32,13,10,9
|
41
|
+
when 125
|
42
|
+
self.invalid_char if field != nil || comma == false
|
43
|
+
return obj
|
44
|
+
when 58
|
45
|
+
self.invalid_char if field == nil
|
46
|
+
begin
|
47
|
+
value = self.parse_rec
|
48
|
+
obj[field] = value
|
49
|
+
end
|
50
|
+
field = nil
|
51
|
+
comma = true
|
52
|
+
when 44
|
53
|
+
if comma
|
54
|
+
comma = false
|
55
|
+
else
|
56
|
+
self.invalid_char
|
57
|
+
end
|
58
|
+
when 34
|
59
|
+
self.invalid_char if comma
|
60
|
+
field = self.parse_string
|
61
|
+
else
|
62
|
+
self.invalid_char
|
63
|
+
end
|
64
|
+
end
|
65
|
+
when 91
|
66
|
+
arr = []
|
67
|
+
comma1 = nil
|
68
|
+
while(true)
|
69
|
+
c2 = nil
|
70
|
+
begin
|
71
|
+
index2 = @pos
|
72
|
+
@pos+=1
|
73
|
+
c2 = (@str[index2] || 0).ord
|
74
|
+
end
|
75
|
+
case(c2)
|
76
|
+
when 32,13,10,9
|
77
|
+
when 93
|
78
|
+
self.invalid_char if comma1 == false
|
79
|
+
return arr
|
80
|
+
when 44
|
81
|
+
if comma1
|
82
|
+
comma1 = false
|
83
|
+
else
|
84
|
+
self.invalid_char
|
85
|
+
end
|
86
|
+
else
|
87
|
+
self.invalid_char if comma1
|
88
|
+
@pos-=1
|
89
|
+
arr.push(self.parse_rec)
|
90
|
+
comma1 = true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
when 116
|
94
|
+
save = @pos
|
95
|
+
if lambda{|_this_| index3 = @pos
|
96
|
+
@pos+=1
|
97
|
+
_r = (@str[index3] || 0).ord}.call(self) != 114 || lambda{|_this_| index4 = @pos
|
98
|
+
@pos+=1
|
99
|
+
_r2 = (@str[index4] || 0).ord}.call(self) != 117 || lambda{|_this_| index5 = @pos
|
100
|
+
@pos+=1
|
101
|
+
_r3 = (@str[index5] || 0).ord}.call(self) != 101
|
102
|
+
@pos = save
|
103
|
+
self.invalid_char
|
104
|
+
end
|
105
|
+
return true
|
106
|
+
when 102
|
107
|
+
save1 = @pos
|
108
|
+
if lambda{|_this_| index6 = @pos
|
109
|
+
@pos+=1
|
110
|
+
_r4 = (@str[index6] || 0).ord}.call(self) != 97 || lambda{|_this_| index7 = @pos
|
111
|
+
@pos+=1
|
112
|
+
_r5 = (@str[index7] || 0).ord}.call(self) != 108 || lambda{|_this_| index8 = @pos
|
113
|
+
@pos+=1
|
114
|
+
_r6 = (@str[index8] || 0).ord}.call(self) != 115 || lambda{|_this_| index9 = @pos
|
115
|
+
@pos+=1
|
116
|
+
_r7 = (@str[index9] || 0).ord}.call(self) != 101
|
117
|
+
@pos = save1
|
118
|
+
self.invalid_char
|
119
|
+
end
|
120
|
+
return false
|
121
|
+
when 110
|
122
|
+
save2 = @pos
|
123
|
+
if lambda{|_this_| index10 = @pos
|
124
|
+
@pos+=1
|
125
|
+
_r8 = (@str[index10] || 0).ord}.call(self) != 117 || lambda{|_this_| index11 = @pos
|
126
|
+
@pos+=1
|
127
|
+
_r9 = (@str[index11] || 0).ord}.call(self) != 108 || lambda{|_this_| index12 = @pos
|
128
|
+
@pos+=1
|
129
|
+
_r10 = (@str[index12] || 0).ord}.call(self) != 108
|
130
|
+
@pos = save2
|
131
|
+
self.invalid_char
|
132
|
+
end
|
133
|
+
return nil
|
134
|
+
when 34
|
135
|
+
return self.parse_string
|
136
|
+
when 48,49,50,51,52,53,54,55,56,57,45
|
137
|
+
c3 = c
|
138
|
+
start = @pos - 1
|
139
|
+
minus = c3 == 45
|
140
|
+
digit = !minus
|
141
|
+
zero = c3 == 48
|
142
|
+
point = false
|
143
|
+
e = false
|
144
|
+
pm = false
|
145
|
+
_end = false
|
146
|
+
while(true)
|
147
|
+
begin
|
148
|
+
index13 = @pos
|
149
|
+
@pos+=1
|
150
|
+
c3 = (@str[index13] || 0).ord
|
151
|
+
end
|
152
|
+
case(c3)
|
153
|
+
when 48
|
154
|
+
self.invalid_number(start) if zero && !point
|
155
|
+
if minus
|
156
|
+
minus = false
|
157
|
+
zero = true
|
158
|
+
end
|
159
|
+
digit = true
|
160
|
+
when 49,50,51,52,53,54,55,56,57
|
161
|
+
self.invalid_number(start) if zero && !point
|
162
|
+
minus = false if minus
|
163
|
+
digit = true
|
164
|
+
zero = false
|
165
|
+
when 46
|
166
|
+
self.invalid_number(start) if minus || point
|
167
|
+
digit = false
|
168
|
+
point = true
|
169
|
+
when 101,69
|
170
|
+
self.invalid_number(start) if minus || zero || e
|
171
|
+
digit = false
|
172
|
+
e = true
|
173
|
+
when 43,45
|
174
|
+
self.invalid_number(start) if !e || pm
|
175
|
+
digit = false
|
176
|
+
pm = true
|
177
|
+
else
|
178
|
+
self.invalid_number(start) if !digit
|
179
|
+
@pos-=1
|
180
|
+
_end = true
|
181
|
+
end
|
182
|
+
break if _end
|
183
|
+
end
|
184
|
+
f = nil
|
185
|
+
begin
|
186
|
+
x = @str[start,@pos - start]
|
187
|
+
f = x.to_f
|
188
|
+
end
|
189
|
+
i = f.to_i
|
190
|
+
if i == f
|
191
|
+
return i
|
192
|
+
else
|
193
|
+
return f
|
194
|
+
end
|
195
|
+
else
|
196
|
+
self.invalid_char
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def parse_string
|
202
|
+
start = @pos
|
203
|
+
buf = StringBuf.new
|
204
|
+
while(true)
|
205
|
+
c = nil
|
206
|
+
begin
|
207
|
+
index = @pos
|
208
|
+
@pos+=1
|
209
|
+
c = (@str[index] || 0).ord
|
210
|
+
end
|
211
|
+
break if c == 34
|
212
|
+
if c == 92
|
213
|
+
buf.b += @str[start,@pos - start - 1]
|
214
|
+
begin
|
215
|
+
index1 = @pos
|
216
|
+
@pos+=1
|
217
|
+
c = (@str[index1] || 0).ord
|
218
|
+
end
|
219
|
+
case(c)
|
220
|
+
when 114
|
221
|
+
buf.b += [13].pack("U")
|
222
|
+
when 110
|
223
|
+
buf.b += [10].pack("U")
|
224
|
+
when 116
|
225
|
+
buf.b += [9].pack("U")
|
226
|
+
when 98
|
227
|
+
buf.b += [8].pack("U")
|
228
|
+
when 102
|
229
|
+
buf.b += [12].pack("U")
|
230
|
+
when 47,92,34
|
231
|
+
buf.b += [c].pack("U")
|
232
|
+
when 117
|
233
|
+
uc = nil
|
234
|
+
begin
|
235
|
+
x = "0x" + _hx_str(@str[@pos,4])
|
236
|
+
uc = x.to_i
|
237
|
+
end
|
238
|
+
@pos += 4
|
239
|
+
buf.b += [uc].pack("U")
|
240
|
+
else
|
241
|
+
raise "Invalid escape sequence \\" + _hx_str([c].pack("U")) + " at position " + _hx_str((@pos - 1))
|
242
|
+
end
|
243
|
+
start = @pos
|
244
|
+
elsif c == 0
|
245
|
+
raise "Unclosed string"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
buf.b += @str[start,@pos - start - 1]
|
249
|
+
return buf.b
|
250
|
+
end
|
251
|
+
|
252
|
+
def invalid_char
|
253
|
+
@pos-=1
|
254
|
+
raise "Invalid char " + _hx_str((@str[@pos] || 0).ord) + " at position " + _hx_str(@pos)
|
255
|
+
end
|
256
|
+
|
257
|
+
def invalid_number(start)
|
258
|
+
raise "Invalid number at position " + _hx_str(start) + ": " + _hx_str(@str[start,@pos - start])
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Haxe
|
5
|
+
module Format
|
6
|
+
class JsonPrinter
|
7
|
+
|
8
|
+
def initialize(replacer,space)
|
9
|
+
@replacer = replacer
|
10
|
+
@indent = space
|
11
|
+
@pretty = space != nil
|
12
|
+
@nind = 0
|
13
|
+
@buf = StringBuf.new
|
14
|
+
end
|
15
|
+
|
16
|
+
# protected - in ruby this doesn't play well with static/inline methods
|
17
|
+
|
18
|
+
attr_accessor :buf
|
19
|
+
attr_accessor :replacer
|
20
|
+
attr_accessor :indent
|
21
|
+
attr_accessor :pretty
|
22
|
+
attr_accessor :nind
|
23
|
+
|
24
|
+
def write(k,v)
|
25
|
+
v = (@replacer).call(k,v) if @replacer != nil
|
26
|
+
begin
|
27
|
+
_g = Type._typeof(v)
|
28
|
+
case(_g.index)
|
29
|
+
when 8
|
30
|
+
@buf.b += "\"???\"".to_s
|
31
|
+
when 4
|
32
|
+
self.fields_string(v,Reflect.fields(v))
|
33
|
+
when 1
|
34
|
+
v1 = v
|
35
|
+
@buf.b += v1.to_s
|
36
|
+
when 2
|
37
|
+
v2 = nil
|
38
|
+
if lambda{|_this_| f = v
|
39
|
+
_r = f.to_f.finite?}.call(self)
|
40
|
+
v2 = v
|
41
|
+
else
|
42
|
+
v2 = "null"
|
43
|
+
end
|
44
|
+
@buf.b += v2.to_s
|
45
|
+
when 5
|
46
|
+
@buf.b += "\"<fun>\"".to_s
|
47
|
+
when 6
|
48
|
+
c = _g.params[0]
|
49
|
+
if c == String
|
50
|
+
self.quote(v)
|
51
|
+
elsif c == Array
|
52
|
+
v3 = v
|
53
|
+
@buf.b += [91].pack("U")
|
54
|
+
len = v3.length
|
55
|
+
last = len - 1
|
56
|
+
begin
|
57
|
+
_g1 = 0
|
58
|
+
while(_g1 < len)
|
59
|
+
i = _g1
|
60
|
+
_g1+=1
|
61
|
+
if i > 0
|
62
|
+
@buf.b += [44].pack("U")
|
63
|
+
else
|
64
|
+
@nind+=1
|
65
|
+
end
|
66
|
+
@buf.b += [10].pack("U") if @pretty
|
67
|
+
if @pretty
|
68
|
+
v4 = nil
|
69
|
+
begin
|
70
|
+
c1 = @indent
|
71
|
+
l = @nind * @indent.length
|
72
|
+
if c1.length == 0 || "".length >= l
|
73
|
+
v4 = ""
|
74
|
+
else
|
75
|
+
v4 = str_pad("",((l - "".length) / c1.length).ceil * c1.length + "".length,c1,__php__.call("STR_PAD_LEFT"))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
@buf.b += v4.to_s
|
79
|
+
end
|
80
|
+
self.write(i,v3[i])
|
81
|
+
if i == last
|
82
|
+
@nind-=1
|
83
|
+
@buf.b += [10].pack("U") if @pretty
|
84
|
+
if @pretty
|
85
|
+
v5 = nil
|
86
|
+
begin
|
87
|
+
c2 = @indent
|
88
|
+
l1 = @nind * @indent.length
|
89
|
+
if c2.length == 0 || "".length >= l1
|
90
|
+
v5 = ""
|
91
|
+
else
|
92
|
+
v5 = str_pad("",((l1 - "".length) / c2.length).ceil * c2.length + "".length,c2,__php__.call("STR_PAD_LEFT"))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
@buf.b += v5.to_s
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
@buf.b += [93].pack("U")
|
101
|
+
elsif c == ::Haxe::Ds::StringMap
|
102
|
+
v6 = v
|
103
|
+
o = { }
|
104
|
+
_it2 = ::Rb::RubyIterator.new(v6.keys)
|
105
|
+
while(_it2.has_next) do
|
106
|
+
k1 = _it2._next
|
107
|
+
value = v6[k1]
|
108
|
+
o[k1] = value
|
109
|
+
end
|
110
|
+
self.fields_string(o,Reflect.fields(o))
|
111
|
+
elsif c == Date
|
112
|
+
v7 = v
|
113
|
+
self.quote(HxOverrides.date_str(v7))
|
114
|
+
else
|
115
|
+
self.fields_string(v,Reflect.fields(v))
|
116
|
+
end
|
117
|
+
when 7
|
118
|
+
i1 = nil
|
119
|
+
begin
|
120
|
+
e = v
|
121
|
+
i1 = e.index
|
122
|
+
end
|
123
|
+
begin
|
124
|
+
v8 = i1
|
125
|
+
@buf.b += v8.to_s
|
126
|
+
end
|
127
|
+
when 3
|
128
|
+
v9 = v
|
129
|
+
@buf.b += v9.to_s
|
130
|
+
when 0
|
131
|
+
@buf.b += "null".to_s
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def fields_string(v,fields)
|
137
|
+
@buf.b += [123].pack("U")
|
138
|
+
len = fields.length
|
139
|
+
last = len - 1
|
140
|
+
first = true
|
141
|
+
begin
|
142
|
+
_g = 0
|
143
|
+
while(_g < len)
|
144
|
+
i = _g
|
145
|
+
_g+=1
|
146
|
+
f = fields[i]
|
147
|
+
value = Reflect.field(v,f)
|
148
|
+
next if Reflect.is_function(value)
|
149
|
+
if first
|
150
|
+
@nind+=1
|
151
|
+
first = false
|
152
|
+
else
|
153
|
+
@buf.b += [44].pack("U")
|
154
|
+
end
|
155
|
+
@buf.b += [10].pack("U") if @pretty
|
156
|
+
if @pretty
|
157
|
+
v1 = nil
|
158
|
+
begin
|
159
|
+
c = @indent
|
160
|
+
l = @nind * @indent.length
|
161
|
+
if c.length == 0 || "".length >= l
|
162
|
+
v1 = ""
|
163
|
+
else
|
164
|
+
v1 = str_pad("",((l - "".length) / c.length).ceil * c.length + "".length,c,__php__.call("STR_PAD_LEFT"))
|
165
|
+
end
|
166
|
+
end
|
167
|
+
@buf.b += v1.to_s
|
168
|
+
end
|
169
|
+
self.quote(f)
|
170
|
+
@buf.b += [58].pack("U")
|
171
|
+
@buf.b += [32].pack("U") if @pretty
|
172
|
+
self.write(f,value)
|
173
|
+
if i == last
|
174
|
+
@nind-=1
|
175
|
+
@buf.b += [10].pack("U") if @pretty
|
176
|
+
if @pretty
|
177
|
+
v2 = nil
|
178
|
+
begin
|
179
|
+
c1 = @indent
|
180
|
+
l1 = @nind * @indent.length
|
181
|
+
if c1.length == 0 || "".length >= l1
|
182
|
+
v2 = ""
|
183
|
+
else
|
184
|
+
v2 = str_pad("",((l1 - "".length) / c1.length).ceil * c1.length + "".length,c1,__php__.call("STR_PAD_LEFT"))
|
185
|
+
end
|
186
|
+
end
|
187
|
+
@buf.b += v2.to_s
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
@buf.b += [125].pack("U")
|
193
|
+
end
|
194
|
+
|
195
|
+
def quote(s)
|
196
|
+
@buf.b += [34].pack("U")
|
197
|
+
i = 0
|
198
|
+
while(true)
|
199
|
+
c = nil
|
200
|
+
begin
|
201
|
+
index = i
|
202
|
+
i+=1
|
203
|
+
c = (s[index] || 0).ord
|
204
|
+
end
|
205
|
+
break if c == 0
|
206
|
+
case(c)
|
207
|
+
when 34
|
208
|
+
@buf.b += "\\\"".to_s
|
209
|
+
when 92
|
210
|
+
@buf.b += "\\\\".to_s
|
211
|
+
when 10
|
212
|
+
@buf.b += "\\n".to_s
|
213
|
+
when 13
|
214
|
+
@buf.b += "\\r".to_s
|
215
|
+
when 9
|
216
|
+
@buf.b += "\\t".to_s
|
217
|
+
when 8
|
218
|
+
@buf.b += "\\b".to_s
|
219
|
+
when 12
|
220
|
+
@buf.b += "\\f".to_s
|
221
|
+
else
|
222
|
+
@buf.b += [c].pack("U")
|
223
|
+
end
|
224
|
+
end
|
225
|
+
@buf.b += [34].pack("U")
|
226
|
+
end
|
227
|
+
|
228
|
+
public
|
229
|
+
|
230
|
+
def JsonPrinter._print(o,replacer = nil,space = nil)
|
231
|
+
printer = ::Haxe::Format::JsonPrinter.new(replacer,space)
|
232
|
+
printer.write("",o)
|
233
|
+
return printer.buf.b
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
239
|
+
end
|