coopy 0.6.4.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +7 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.md +22 -0
  7. data/README.md +59 -0
  8. data/Rakefile +4 -6
  9. data/coopy.gemspec +26 -0
  10. data/lib/coopy.rb +32 -175
  11. data/lib/coopy/alignment.rb +260 -0
  12. data/lib/coopy/bag.rb +17 -0
  13. data/lib/coopy/cell_info.rb +24 -0
  14. data/lib/coopy/change_type.rb +10 -0
  15. data/lib/coopy/compare_flags.rb +62 -0
  16. data/lib/coopy/compare_table.rb +327 -0
  17. data/lib/coopy/coopy.rb +22 -0
  18. data/lib/coopy/cross_match.rb +10 -0
  19. data/lib/coopy/csv_table.rb +51 -0
  20. data/lib/coopy/diff_render.rb +307 -0
  21. data/lib/coopy/index.rb +73 -0
  22. data/lib/coopy/index_item.rb +17 -0
  23. data/lib/coopy/index_pair.rb +72 -0
  24. data/lib/coopy/mover.rb +123 -0
  25. data/lib/coopy/ordering.rb +27 -0
  26. data/lib/coopy/row.rb +9 -0
  27. data/lib/coopy/simple_cell.rb +15 -0
  28. data/lib/coopy/simple_table.rb +144 -0
  29. data/lib/coopy/simple_view.rb +36 -0
  30. data/lib/coopy/table.rb +44 -0
  31. data/lib/coopy/table_comparison_state.rb +33 -0
  32. data/lib/coopy/table_diff.rb +634 -0
  33. data/lib/coopy/table_text.rb +14 -0
  34. data/lib/coopy/table_view.rb +31 -0
  35. data/lib/coopy/unit.rb +53 -0
  36. data/lib/coopy/version.rb +3 -0
  37. data/lib/coopy/view.rb +34 -0
  38. data/spec/fixtures/bridges.html +10 -0
  39. data/spec/fixtures/bridges_diff.csv +8 -0
  40. data/spec/fixtures/bridges_new.csv +9 -0
  41. data/spec/fixtures/bridges_old.csv +9 -0
  42. data/spec/fixtures/planetary_bodies.html +22 -0
  43. data/spec/fixtures/planetary_bodies_diff.csv +19 -0
  44. data/spec/fixtures/planetary_bodies_new.csv +20 -0
  45. data/spec/fixtures/planetary_bodies_old.csv +19 -0
  46. data/spec/fixtures/quote_me.csv +10 -0
  47. data/spec/fixtures/quote_me2.csv +11 -0
  48. data/spec/integration/table_diff_spec.rb +57 -0
  49. data/spec/libs/compare_flags_spec.rb +40 -0
  50. data/spec/libs/coopy_spec.rb +14 -0
  51. data/spec/libs/ordering_spec.rb +28 -0
  52. data/spec/libs/unit_spec.rb +31 -0
  53. data/spec/spec_helper.rb +29 -0
  54. metadata +153 -46
  55. data/bin/sqlite_diff +0 -4
  56. data/bin/sqlite_patch +0 -4
  57. data/bin/sqlite_rediff +0 -4
  58. data/lib/coopy/dbi_sql_wrapper.rb +0 -89
  59. data/lib/coopy/diff_apply_sql.rb +0 -35
  60. data/lib/coopy/diff_columns.rb +0 -33
  61. data/lib/coopy/diff_output.rb +0 -21
  62. data/lib/coopy/diff_output_action.rb +0 -34
  63. data/lib/coopy/diff_output_group.rb +0 -40
  64. data/lib/coopy/diff_output_raw.rb +0 -17
  65. data/lib/coopy/diff_output_stats.rb +0 -45
  66. data/lib/coopy/diff_output_table.rb +0 -49
  67. data/lib/coopy/diff_output_tdiff.rb +0 -48
  68. data/lib/coopy/diff_parser.rb +0 -92
  69. data/lib/coopy/diff_render_csv.rb +0 -29
  70. data/lib/coopy/diff_render_html.rb +0 -74
  71. data/lib/coopy/diff_render_log.rb +0 -52
  72. data/lib/coopy/row_change.rb +0 -25
  73. data/lib/coopy/scraperwiki_sql_wrapper.rb +0 -8
  74. data/lib/coopy/scraperwiki_utils.rb +0 -23
  75. data/lib/coopy/sequel_sql_wrapper.rb +0 -73
  76. data/lib/coopy/sql_compare.rb +0 -222
  77. data/lib/coopy/sql_wrapper.rb +0 -34
  78. data/lib/coopy/sqlite_sql_wrapper.rb +0 -143
  79. data/test/test_coopy.rb +0 -126
@@ -1,126 +0,0 @@
1
- require 'test/unit'
2
- require 'coopy'
3
- require 'tmpdir'
4
- require 'fileutils'
5
-
6
- class CoopyTest < Test::Unit::TestCase
7
- def initialize(*args)
8
- super(*args)
9
- odir = File.dirname(__FILE__)
10
- @broken_bridges = File.join(odir,"broken_bridges.sqlite")
11
- @bridges = File.join(odir,"bridges.sqlite")
12
- @dir = nil
13
- end
14
-
15
- def setup
16
- @dir = Dir.mktmpdir
17
- @ct = 0
18
- @output = ""
19
- new_output
20
- end
21
-
22
- def teardown
23
- FileUtils.remove_entry_secure @dir
24
- @dir = nil
25
- end
26
-
27
- def new_output
28
- @ct = @ct+1
29
- tmp = @output
30
- @output = File.join(@dir,"output#{@ct}.txt")
31
- tmp
32
- end
33
-
34
- def cp(src,key)
35
- target = File.join(@dir,"#{key}.sqlite")
36
- FileUtils.cp src, target
37
- target
38
- end
39
-
40
- def read(fname)
41
- begin
42
- File.open(fname,"r") do |f|
43
- return f.read
44
- end
45
- rescue
46
- return ""
47
- end
48
- end
49
-
50
- def diff(*argv)
51
- Coopy.diff(["--output",@output] + argv)
52
- new_output
53
- end
54
-
55
- def rediff(*argv)
56
- Coopy.rediff(["--output",@output] + argv)
57
- new_output
58
- end
59
-
60
- def patch(*argv)
61
- Coopy.patch(argv)
62
- end
63
-
64
- def assert_rows_equal(x1,x2)
65
- txt = read(diff("--format","stats",x1,x2))
66
- assert_match(/row,insert,0$/,txt)
67
- assert_match(/row,delete,0$/,txt)
68
- assert_match(/row,update,0$/,txt)
69
- end
70
-
71
- def assert_rows_unequal(x1,x2)
72
- txt = read(diff("--format","stats",x1,x2))
73
- assert_match(/row,((insert)|(delete)|(update)),[^0]/,txt)
74
- end
75
-
76
- def test_basic_stats
77
- txt = read(diff("--format","stats",@broken_bridges,@bridges))
78
- assert_match(/row,insert,1$/,txt)
79
- assert_match(/row,delete,1$/,txt)
80
- assert_match(/row,update,1$/,txt)
81
- end
82
-
83
- def test_basic_csv
84
- txt = read(diff("--format","csv",@broken_bridges,@bridges))
85
- assert_match(/,/,txt)
86
- assert_no_match(/<tr/,txt)
87
- end
88
-
89
- def test_basic_html
90
- txt = read(diff("--format","html",@broken_bridges,@bridges))
91
- assert_match(/<tr/,txt)
92
- end
93
-
94
- def test_basic_apply
95
- v1 = cp(@broken_bridges,"v1")
96
- v2 = cp(@bridges,"v2")
97
- assert_rows_unequal(v1,v2)
98
- diff("--format","apply",v1,v2)
99
- assert_rows_equal(v1,v2)
100
- end
101
-
102
- def diff_patch(b1,b2)
103
- v1 = cp(b1,"v1")
104
- v2 = cp(b2,"v2")
105
- @diff = diff(v1,v2)
106
- assert_rows_unequal(v1,v2)
107
- patch(v1,@diff)
108
- assert_rows_equal(v1,v2)
109
- end
110
-
111
- def test_basic_diff_patch
112
- diff_patch(@broken_bridges,@bridges)
113
- end
114
-
115
- def test_reverse_diff_patch
116
- diff_patch(@bridges,@broken_bridges)
117
- end
118
-
119
- def test_basic_rediff
120
- v1 = cp(@broken_bridges,"v1")
121
- v2 = cp(@bridges,"v2")
122
- @diff = diff(v1,v2)
123
- @diff2 = rediff(@diff)
124
- assert_equal read(@diff), read(@diff2)
125
- end
126
- end