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.
Files changed (42) hide show
  1. data/README.md +4 -1
  2. data/lib/daff.rb +20 -7
  3. data/lib/lib/coopy/alignment.rb +6 -0
  4. data/lib/lib/coopy/cell_info.rb +1 -0
  5. data/lib/lib/coopy/compare_flags.rb +2 -0
  6. data/lib/lib/coopy/compare_table.rb +1 -1
  7. data/lib/lib/coopy/coopy.rb +80 -18
  8. data/lib/lib/coopy/csv.rb +1 -1
  9. data/lib/lib/coopy/diff_render.rb +61 -22
  10. data/lib/lib/coopy/flat_cell_builder.rb +1 -1
  11. data/lib/lib/coopy/highlight_patch.rb +8 -6
  12. data/lib/lib/coopy/mover.rb +1 -1
  13. data/lib/lib/coopy/ndjson.rb +134 -0
  14. data/lib/lib/coopy/nested_cell_builder.rb +74 -0
  15. data/lib/lib/coopy/simple_view.rb +29 -0
  16. data/lib/lib/coopy/sql_column.rb +35 -0
  17. data/lib/lib/coopy/sql_compare.rb +245 -0
  18. data/lib/lib/coopy/sql_database.rb +19 -0
  19. data/lib/lib/coopy/sql_helper.rb +12 -0
  20. data/lib/lib/coopy/sql_table.rb +216 -0
  21. data/lib/lib/coopy/sql_table_name.rb +23 -0
  22. data/lib/lib/coopy/sqlite_helper.rb +47 -0
  23. data/lib/lib/coopy/table_diff.rb +18 -6
  24. data/lib/lib/coopy/table_io.rb +5 -0
  25. data/lib/lib/coopy/terminal_diff_render.rb +8 -9
  26. data/lib/lib/coopy/view.rb +5 -0
  27. data/lib/lib/haxe/ds/int_map.rb +4 -0
  28. data/lib/lib/haxe/ds/string_map.rb +4 -0
  29. data/lib/lib/haxe/format/json_parser.rb +8 -8
  30. data/lib/lib/haxe/imap.rb +1 -0
  31. data/lib/lib/haxe/io/bytes.rb +1 -1
  32. data/lib/lib/haxe/io/bytes_output.rb +1 -1
  33. data/lib/lib/haxe/io/error.rb +1 -0
  34. data/lib/lib/haxe/io/output.rb +2 -2
  35. data/lib/lib/hx_overrides.rb +12 -0
  36. data/lib/lib/hx_sys.rb +1 -1
  37. data/lib/lib/rb/boot.rb +5 -1
  38. data/lib/lib/reflect.rb +1 -0
  39. data/lib/lib/sys/io/file_handle.rb +1 -0
  40. data/lib/lib/sys/io/file_output.rb +1 -1
  41. data/lib/lib/value_type.rb +1 -0
  42. metadata +36 -25
@@ -6,6 +6,11 @@ module Coopy
6
6
  def toString(d) puts "Abstract View.toString called" end
7
7
  def equals(d1,d2) puts "Abstract View.equals called" end
8
8
  def toDatum(str) puts "Abstract View.toDatum called" end
9
+ def makeHash() puts "Abstract View.makeHash called" end
10
+ def hashSet(h,str,d) puts "Abstract View.hashSet called" end
11
+ def isHash(h) puts "Abstract View.isHash called" end
12
+ def hashExists(h,str) puts "Abstract View.hashExists called" end
13
+ def hashGet(h,str) puts "Abstract View.hashGet called" end
9
14
  haxe_me
10
15
  end
11
16
 
@@ -8,6 +8,10 @@ module Ds
8
8
  def initialize
9
9
  end
10
10
 
11
+ def get(key)
12
+ return self[key]
13
+ end
14
+
11
15
  haxe_me
12
16
  end
13
17
 
@@ -8,6 +8,10 @@ module Ds
8
8
  def initialize
9
9
  end
10
10
 
11
+ def get(key)
12
+ return self[key]
13
+ end
14
+
11
15
  haxe_me
12
16
  end
13
17
 
@@ -183,7 +183,7 @@ module Format
183
183
  end
184
184
  f = nil
185
185
  begin
186
- x = @str[start,@pos - start]
186
+ x = HxOverrides.substr(@str,start,@pos - start)
187
187
  f = x.to_f
188
188
  end
189
189
  i = f.to_i
@@ -210,7 +210,7 @@ module Format
210
210
  end
211
211
  break if c == 34
212
212
  if c == 92
213
- buf_b += @str[start,@pos - start - 1]
213
+ buf_b += HxOverrides.substr(@str,start,@pos - start - 1)
214
214
  begin
215
215
  index1 = @pos
216
216
  @pos+=1
@@ -232,30 +232,30 @@ module Format
232
232
  when 117
233
233
  uc = nil
234
234
  begin
235
- x = "0x" + _hx_str(@str[@pos,4])
235
+ x = "0x" + _hx_str(HxOverrides.substr(@str,@pos,4))
236
236
  uc = x.to_i
237
237
  end
238
238
  @pos += 4
239
239
  buf_b += [uc].pack("U")
240
240
  else
241
- raise "Invalid escape sequence \\" + _hx_str([c].pack("U")) + " at position " + _hx_str((@pos - 1))
241
+ raise hx_raise("Invalid escape sequence \\" + _hx_str([c].pack("U")) + " at position " + _hx_str((@pos - 1)))
242
242
  end
243
243
  start = @pos
244
244
  elsif c == 0
245
- raise "Unclosed string"
245
+ raise hx_raise("Unclosed string")
246
246
  end
247
247
  end
248
- buf_b += @str[start,@pos - start - 1]
248
+ buf_b += HxOverrides.substr(@str,start,@pos - start - 1)
249
249
  return buf_b
250
250
  end
251
251
 
252
252
  def invalid_char
253
253
  @pos-=1
254
- raise "Invalid char " + _hx_str((@str[@pos] || 0).ord) + " at position " + _hx_str(@pos)
254
+ raise hx_raise("Invalid char " + _hx_str((@str[@pos] || 0).ord) + " at position " + _hx_str(@pos))
255
255
  end
256
256
 
257
257
  def invalid_number(start)
258
- raise "Invalid number at position " + _hx_str(start) + ": " + _hx_str(@str[start,@pos - start])
258
+ raise hx_raise("Invalid number at position " + _hx_str(start) + ": " + _hx_str(HxOverrides.substr(@str,start,@pos - start)))
259
259
  end
260
260
 
261
261
  haxe_me
data/lib/lib/haxe/imap.rb CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  module Haxe
5
5
  class IMap
6
+ def get(k) puts "Abstract IMap.get called" end
6
7
  haxe_me
7
8
  end
8
9
 
@@ -19,7 +19,7 @@ module Io
19
19
  public
20
20
 
21
21
  def get_string(pos,len)
22
- raise ::Haxe::Io::Error.outside_bounds if pos < 0 || len < 0 || pos + len > @length
22
+ raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > @length
23
23
  return @b.byteslice(pos,len)
24
24
  end
25
25
 
@@ -20,7 +20,7 @@ module Io
20
20
 
21
21
  def write_bytes(buf,pos,len)
22
22
  begin
23
- raise ::Haxe::Io::Error.outside_bounds if pos < 0 || len < 0 || pos + len > buf.length
23
+ raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > buf.length
24
24
  @b.b += buf.b.byteslice(pos,len)
25
25
  end
26
26
  return len
@@ -15,6 +15,7 @@ module Io
15
15
  def Error.outside_bounds() Error.new("OutsideBounds",2) end
16
16
  def Error.overflow() Error.new("Overflow",1) end
17
17
  CONSTRUCTS__ = ["Blocked","Overflow","OutsideBounds","Custom"]
18
+ def ==(a) a.tag === @tag && a.index === @index && a.params == @params end
18
19
  end
19
20
 
20
21
  end
@@ -6,13 +6,13 @@ module Io
6
6
  class Output
7
7
 
8
8
  def write_byte(c)
9
- raise "Not implemented"
9
+ raise hx_raise("Not implemented")
10
10
  end
11
11
 
12
12
  def write_bytes(s,pos,len)
13
13
  k = len
14
14
  b = s.b
15
- raise ::Haxe::Io::Error.outside_bounds if pos < 0 || len < 0 || pos + len > s.length
15
+ raise hx_raise(::Haxe::Io::Error.outside_bounds) if pos < 0 || len < 0 || pos + len > s.length
16
16
  while(k > 0)
17
17
  self.write_byte(b[pos])
18
18
  pos+=1
@@ -14,6 +14,18 @@
14
14
  return _hx_str(date.get_full_year) + "-" + _hx_str((((m < 10) ? "0" + _hx_str(m) : "" + _hx_str(m)))) + "-" + _hx_str((((d < 10) ? "0" + _hx_str(d) : "" + _hx_str(d)))) + " " + _hx_str((((h < 10) ? "0" + _hx_str(h) : "" + _hx_str(h)))) + ":" + _hx_str((((mi < 10) ? "0" + _hx_str(mi) : "" + _hx_str(mi)))) + ":" + _hx_str((((s < 10) ? "0" + _hx_str(s) : "" + _hx_str(s))))
15
15
  end
16
16
 
17
+ def HxOverrides.substr(s,pos,len = nil)
18
+ return "" if pos != nil && pos != 0 && len != nil && len < 0
19
+ len = s.length if len == nil
20
+ if pos < 0
21
+ pos = s.length + pos
22
+ pos = 0 if pos < 0
23
+ elsif len < 0
24
+ len = s.length + len - pos
25
+ end
26
+ return s[pos,len]
27
+ end
28
+
17
29
  haxe_me
18
30
  end
19
31
 
data/lib/lib/hx_sys.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  when 32,34
23
23
  ok = false
24
24
  when 0,13,10
25
- arg = arg[0,i]
25
+ arg = HxOverrides.substr(arg,0,i)
26
26
  end if _g2 != nil
27
27
  end
28
28
  end
data/lib/lib/rb/boot.rb CHANGED
@@ -7,7 +7,11 @@ module Rb
7
7
  # protected - in ruby this doesn't play well with static/inline methods
8
8
 
9
9
  def Boot.__trace(v,i)
10
- puts(v)
10
+ if i != nil
11
+ puts "#{v} #{i.inspect}"
12
+ else
13
+ puts v
14
+ end
11
15
  end
12
16
 
13
17
  haxe_me
data/lib/lib/reflect.rb CHANGED
@@ -9,6 +9,7 @@
9
9
  result = o[field.to_sym] if result == nil
10
10
  return result
11
11
  rescue => e
12
+ e = hx_rescued(e)
12
13
  return field
13
14
  end
14
15
  end
@@ -11,6 +11,7 @@ module Io
11
11
  def initialize(t,index,p = nil ) @tag = t; @index = index; @params = p; end
12
12
 
13
13
  CONSTRUCTS__ = []
14
+ def ==(a) a.tag === @tag && a.index === @index && a.params == @params end
14
15
  end
15
16
 
16
17
  end
@@ -25,7 +25,7 @@ module Io
25
25
  def write_bytes(b,p,l)
26
26
  s = b.get_string(p,l)
27
27
  r = @__f.write(s)
28
- raise ::Haxe::Io::Error.custom("An error occurred") if r < l
28
+ raise hx_raise(::Haxe::Io::Error.custom("An error occurred")) if r < l
29
29
  return r
30
30
  end
31
31
 
@@ -18,5 +18,6 @@
18
18
  def ValueType.tobject() ValueType.new("TObject",4) end
19
19
  def ValueType.tunknown() ValueType.new("TUnknown",8) end
20
20
  CONSTRUCTS__ = ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"]
21
+ def ==(a) a.tag === @tag && a.index === @index && a.params == @params end
21
22
  end
22
23
 
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.2.3
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-30 00:00:00.000000000 Z
13
+ date: 2015-02-01 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Diff and patch tables
16
16
  email:
@@ -34,14 +34,18 @@ files:
34
34
  - lib/lib/coopy/cell_builder.rb
35
35
  - lib/lib/coopy/compare_table.rb
36
36
  - lib/lib/coopy/table_io.rb
37
+ - lib/lib/coopy/sql_compare.rb
37
38
  - lib/lib/coopy/flat_cell_builder.rb
39
+ - lib/lib/coopy/nested_cell_builder.rb
38
40
  - lib/lib/coopy/index_item.rb
39
41
  - lib/lib/coopy/index_pair.rb
42
+ - lib/lib/coopy/sql_column.rb
40
43
  - lib/lib/coopy/diff_render.rb
41
44
  - lib/lib/coopy/cross_match.rb
42
45
  - lib/lib/coopy/table_diff.rb
43
46
  - lib/lib/coopy/alignment.rb
44
47
  - lib/lib/coopy/terminal_diff_render.rb
48
+ - lib/lib/coopy/sql_table.rb
45
49
  - lib/lib/coopy/table_modifier.rb
46
50
  - lib/lib/coopy/highlight_patch.rb
47
51
  - lib/lib/coopy/table_text.rb
@@ -51,15 +55,20 @@ files:
51
55
  - lib/lib/coopy/coopy.rb
52
56
  - lib/lib/coopy/cell_info.rb
53
57
  - lib/lib/coopy/view.rb
58
+ - lib/lib/coopy/sql_table_name.rb
54
59
  - lib/lib/coopy/highlight_patch_unit.rb
55
60
  - lib/lib/coopy/compare_flags.rb
56
61
  - lib/lib/coopy/unit.rb
57
62
  - lib/lib/coopy/mover.rb
58
63
  - lib/lib/coopy/table_comparison_state.rb
64
+ - lib/lib/coopy/sql_database.rb
59
65
  - lib/lib/coopy/csv.rb
66
+ - lib/lib/coopy/sqlite_helper.rb
60
67
  - lib/lib/coopy/ordering.rb
61
68
  - lib/lib/coopy/merger.rb
69
+ - lib/lib/coopy/sql_helper.rb
62
70
  - lib/lib/coopy/sparse_sheet.rb
71
+ - lib/lib/coopy/ndjson.rb
63
72
  - lib/lib/coopy/table.rb
64
73
  - lib/lib/coopy/viterbi.rb
65
74
  - lib/lib/math.rb
@@ -112,7 +121,8 @@ summary: ! '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=mast
112
121
  [![NPM version](https://badge.fury.io/js/daff.svg)](http://badge.fury.io/js/daff)
113
122
  [![Gem Version](https://badge.fury.io/rb/daff.svg)](http://badge.fury.io/rb/daff)
114
123
  [![PyPI version](https://badge.fury.io/py/daff.svg)](http://badge.fury.io/py/daff)
115
- [![PHP version](https://badge.fury.io/ph/paulfitz%2Fdaff-php.svg)](http://badge.fury.io/ph/paulfitz%2Fdaff-php) daff:
124
+ [![PHP version](https://badge.fury.io/ph/paulfitz%2Fdaff-php.svg)](http://badge.fury.io/ph/paulfitz%2Fdaff-php)
125
+ [![tips](https://img.shields.io/gratipay/paulfitz.svg)](https://gratipay.com/paulfitz/) daff:
116
126
  data diff =============== This is a library for comparing tables, producing a summary
117
127
  of their differences, and using such a summary as a patch file. It is optimized
118
128
  for comparing tables that share a common origin, in other words multiple versions
@@ -127,7 +137,7 @@ summary: ! '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=mast
127
137
  other complications, check out the coopy toolbox. The program ----------- You
128
138
  can run `daff`/`daff.py`/`daff.rb` as a utility program: ```` $ daff daff can produce
129
139
  and apply tabular diffs. Call as: daff [--output OUTPUT.csv] a.csv b.csv daff [--output
130
- OUTPUT.csv] parent.csv a.csv b.csv daff [--output OUTPUT.jsonbook] a.jsonbook b.jsonbook
140
+ OUTPUT.csv] parent.csv a.csv b.csv daff [--output OUTPUT.ndjson] a.ndjson b.ndjson
131
141
  daff patch [--inplace] [--output OUTPUT.csv] a.csv patch.csv daff merge [--inplace]
132
142
  [--output OUTPUT.csv] parent.csv a.csv b.csv daff trim [--output OUTPUT.csv] source.csv
133
143
  daff render [--output OUTPUT.html] diff.csv daff git daff version The --inplace
@@ -140,27 +150,28 @@ summary: ! '[![Build Status](https://travis-ci.org/paulfitz/daff.svg?branch=mast
140
150
  render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv --css
141
151
  CSS.css: generate a suitable css file to go with the html --fragment: generate
142
152
  just a html fragment rather than a page --plain: do not use fancy utf8 characters
143
- to make arrows prettier ```` Using with git -------------- Run `daff git csv`
144
- to install daff as a diff and merge handler for `*.csv` files in your repository. Run
145
- `daff git` for instructions on doing this manually. Your CSV diffs and merges will
146
- get smarter, since git will suddenly understand about rows and columns, not just
147
- lines: ![Example CSV diff](scripts/diff.png) The library ----------- You can
148
- use `daff` as a library from any supported language. We take here the example
149
- of Javascript. To use `daff` on a webpage, first include `daff.js`: ```html <script
150
- src="daff.js"></script> ``` Or if using node outside the browser: ```js var daff
151
- = require(''daff''); ``` For concreteness, assume we have two versions of a table,
152
- `data1` and `data2`: ```js var data1 = [ [''Country'',''Capital''], [''Ireland'',''Dublin''],
153
- [''France'',''Paris''], [''Spain'',''Barcelona''] ]; var data2 = [ [''Country'',''Code'',''Capital''],
154
- [''Ireland'',''ie'',''Dublin''], [''France'',''fr'',''Paris''], [''Spain'',''es'',''Madrid''],
155
- [''Germany'',''de'',''Berlin''] ]; ``` To make those tables accessible to the library,
156
- we wrap them in `daff.TableView`: ```js var table1 = new daff.TableView(data1);
157
- var table2 = new daff.TableView(data2); ``` We can now compute the alignment between
158
- the rows and columns in the two tables: ```js var alignment = daff.compareTables(table1,table2).align();
159
- ``` To produce a diff from the alignment, we first need a table for the output:
160
- ```js var data_diff = []; var table_diff = new daff.TableView(data_diff); ``` Using
161
- default options for the diff: ```js var flags = new daff.CompareFlags(); var highlighter
162
- = new daff.TableDiff(alignment,flags); highlighter.hilite(table_diff); ``` The
163
- diff is now in `data_diff` in highlighter format, see specification here: > http://share.find.coop/doc/spec_hilite.html ```js
153
+ to make arrows prettier ```` Formats supported are CSV, TSV, and [ndjson](http://dataprotocols.org/ndjson/). Using
154
+ with git -------------- Run `daff git csv` to install daff as a diff and merge
155
+ handler for `*.csv` files in your repository. Run `daff git` for instructions on
156
+ doing this manually. Your CSV diffs and merges will get smarter, since git will
157
+ suddenly understand about rows and columns, not just lines: ![Example CSV diff](scripts/diff.png) The
158
+ library ----------- You can use `daff` as a library from any supported language. We
159
+ take here the example of Javascript. To use `daff` on a webpage, first include
160
+ `daff.js`: ```html <script src="daff.js"></script> ``` Or if using node outside
161
+ the browser: ```js var daff = require(''daff''); ``` For concreteness, assume we
162
+ have two versions of a table, `data1` and `data2`: ```js var data1 = [ [''Country'',''Capital''],
163
+ [''Ireland'',''Dublin''], [''France'',''Paris''], [''Spain'',''Barcelona''] ]; var
164
+ data2 = [ [''Country'',''Code'',''Capital''], [''Ireland'',''ie'',''Dublin''], [''France'',''fr'',''Paris''],
165
+ [''Spain'',''es'',''Madrid''], [''Germany'',''de'',''Berlin''] ]; ``` To make those
166
+ tables accessible to the library, we wrap them in `daff.TableView`: ```js var table1
167
+ = new daff.TableView(data1); var table2 = new daff.TableView(data2); ``` We can
168
+ now compute the alignment between the rows and columns in the two tables: ```js
169
+ var alignment = daff.compareTables(table1,table2).align(); ``` To produce a diff
170
+ from the alignment, we first need a table for the output: ```js var data_diff =
171
+ []; var table_diff = new daff.TableView(data_diff); ``` Using default options for
172
+ the diff: ```js var flags = new daff.CompareFlags(); var highlighter = new daff.TableDiff(alignment,flags);
173
+ highlighter.hilite(table_diff); ``` The diff is now in `data_diff` in highlighter
174
+ format, see specification here: > http://share.find.coop/doc/spec_hilite.html ```js
164
175
  [ [ ''!'', '''', ''+++'', '''' ], [ ''@@'', ''Country'', ''Code'', ''Capital'' ],
165
176
  [ ''+'', ''Ireland'', ''ie'', ''Dublin'' ], [ ''+'', ''France'', ''fr'', ''Paris''
166
177
  ], [ ''->'', ''Spain'', ''es'', ''Barcelona->Madrid'' ], [ ''+++'', ''Germany'',