diff-lcs 1.1.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -0
  3. data/Code-of-Conduct.md +74 -0
  4. data/Contributing.md +119 -0
  5. data/History.md +400 -0
  6. data/{License.rdoc → License.md} +6 -5
  7. data/Manifest.txt +36 -4
  8. data/README.rdoc +35 -23
  9. data/Rakefile +106 -11
  10. data/bin/htmldiff +7 -4
  11. data/bin/ldiff +4 -1
  12. data/docs/COPYING.txt +21 -22
  13. data/docs/artistic.txt +127 -0
  14. data/lib/diff/lcs/array.rb +1 -15
  15. data/lib/diff/lcs/backports.rb +9 -0
  16. data/lib/diff/lcs/block.rb +4 -18
  17. data/lib/diff/lcs/callbacks.rb +233 -230
  18. data/lib/diff/lcs/change.rb +114 -109
  19. data/lib/diff/lcs/htmldiff.rb +17 -18
  20. data/lib/diff/lcs/hunk.rb +232 -116
  21. data/lib/diff/lcs/internals.rb +308 -0
  22. data/lib/diff/lcs/ldiff.rb +138 -177
  23. data/lib/diff/lcs/string.rb +1 -15
  24. data/lib/diff/lcs.rb +597 -963
  25. data/lib/diff-lcs.rb +1 -3
  26. data/spec/change_spec.rb +89 -0
  27. data/spec/diff_spec.rb +32 -16
  28. data/spec/fixtures/aX +1 -0
  29. data/spec/fixtures/bXaX +1 -0
  30. data/spec/fixtures/ds1.csv +50 -0
  31. data/spec/fixtures/ds2.csv +51 -0
  32. data/spec/fixtures/ldiff/output.diff +4 -0
  33. data/spec/fixtures/ldiff/output.diff-c +7 -0
  34. data/spec/fixtures/ldiff/output.diff-e +3 -0
  35. data/spec/fixtures/ldiff/output.diff-f +3 -0
  36. data/spec/fixtures/ldiff/output.diff-u +5 -0
  37. data/spec/fixtures/ldiff/output.diff.chef +4 -0
  38. data/spec/fixtures/ldiff/output.diff.chef-c +15 -0
  39. data/spec/fixtures/ldiff/output.diff.chef-e +3 -0
  40. data/spec/fixtures/ldiff/output.diff.chef-f +3 -0
  41. data/spec/fixtures/ldiff/output.diff.chef-u +9 -0
  42. data/spec/fixtures/ldiff/output.diff.chef2 +7 -0
  43. data/spec/fixtures/ldiff/output.diff.chef2-c +20 -0
  44. data/spec/fixtures/ldiff/output.diff.chef2-d +7 -0
  45. data/spec/fixtures/ldiff/output.diff.chef2-e +7 -0
  46. data/spec/fixtures/ldiff/output.diff.chef2-f +7 -0
  47. data/spec/fixtures/ldiff/output.diff.chef2-u +16 -0
  48. data/spec/fixtures/new-chef +4 -0
  49. data/spec/fixtures/new-chef2 +17 -0
  50. data/spec/fixtures/old-chef +4 -0
  51. data/spec/fixtures/old-chef2 +14 -0
  52. data/spec/hunk_spec.rb +83 -0
  53. data/spec/issues_spec.rb +154 -0
  54. data/spec/lcs_spec.rb +36 -16
  55. data/spec/ldiff_spec.rb +87 -0
  56. data/spec/patch_spec.rb +198 -172
  57. data/spec/sdiff_spec.rb +99 -89
  58. data/spec/spec_helper.rb +149 -59
  59. data/spec/traverse_balanced_spec.rb +191 -167
  60. data/spec/traverse_sequences_spec.rb +105 -51
  61. metadata +218 -99
  62. data/.gemtest +0 -0
  63. data/History.rdoc +0 -54
  64. data/diff-lcs.gemspec +0 -51
  65. data/docs/artistic.html +0 -289
data/spec/sdiff_spec.rb CHANGED
@@ -1,204 +1,214 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe "Diff::LCS.sdiff" do
5
+ describe 'Diff::LCS.sdiff' do
6
6
  include Diff::LCS::SpecHelper::Matchers
7
7
 
8
- shared_examples "compare sequences correctly" do
9
- it "should compare s1 -> s2 correctly" do
10
- Diff::LCS.sdiff(s1, s2).should == context_diff(result)
8
+ shared_examples 'compare sequences correctly' do
9
+ it 'compares s1 -> s2 correctly' do
10
+ expect(Diff::LCS.sdiff(s1, s2)).to eq(context_diff(result))
11
11
  end
12
12
 
13
- it "should compare s2 -> s1 correctly" do
14
- Diff::LCS.sdiff(s2, s1).should == context_diff(reverse_sdiff(result))
13
+ it 'compares s2 -> s1 correctly' do
14
+ expect(Diff::LCS.sdiff(s2, s1)).to eq(context_diff(reverse_sdiff(result)))
15
15
  end
16
16
  end
17
17
 
18
- describe "using seq1 & seq2" do
18
+ describe 'using seq1 & seq2' do
19
19
  let(:s1) { seq1 }
20
20
  let(:s2) { seq2 }
21
21
  let(:result) { correct_forward_sdiff }
22
22
 
23
- it_has_behavior "compare sequences correctly"
23
+ it_has_behavior 'compare sequences correctly'
24
24
  end
25
25
 
26
- describe "using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)" do
26
+ describe 'using %w(abc def yyy xxx ghi jkl) & %w(abc dxf xxx ghi jkl)' do
27
27
  let(:s1) { %w(abc def yyy xxx ghi jkl) }
28
28
  let(:s2) { %w(abc dxf xxx ghi jkl) }
29
29
  let(:result) {
30
30
  [
31
- [ '=', [ 0, 'abc' ], [ 0, 'abc' ] ],
32
- [ '!', [ 1, 'def' ], [ 1, 'dxf' ] ],
33
- [ '-', [ 2, 'yyy' ], [ 2, nil ] ],
34
- [ '=', [ 3, 'xxx' ], [ 2, 'xxx' ] ],
35
- [ '=', [ 4, 'ghi' ], [ 3, 'ghi' ] ],
36
- [ '=', [ 5, 'jkl' ], [ 4, 'jkl' ] ]
31
+ ['=', [0, 'abc'], [0, 'abc']],
32
+ ['!', [1, 'def'], [1, 'dxf']],
33
+ ['-', [2, 'yyy'], [2, nil]],
34
+ ['=', [3, 'xxx'], [2, 'xxx']],
35
+ ['=', [4, 'ghi'], [3, 'ghi']],
36
+ ['=', [5, 'jkl'], [4, 'jkl']]
37
37
  ]
38
38
  }
39
39
 
40
- it_has_behavior "compare sequences correctly"
40
+ it_has_behavior 'compare sequences correctly'
41
41
  end
42
42
 
43
- describe "using %w(a b c d e) & %w(a e)" do
43
+ describe 'using %w(a b c d e) & %w(a e)' do
44
44
  let(:s1) { %w(a b c d e) }
45
45
  let(:s2) { %w(a e) }
46
46
  let(:result) {
47
47
  [
48
- [ '=', [ 0, 'a' ], [ 0, 'a' ] ],
49
- [ '-', [ 1, 'b' ], [ 1, nil ] ],
50
- [ '-', [ 2, 'c' ], [ 1, nil ] ],
51
- [ '-', [ 3, 'd' ], [ 1, nil ] ],
52
- [ '=', [ 4, 'e' ], [ 1, 'e' ] ]
48
+ ['=', [0, 'a'], [0, 'a']],
49
+ ['-', [1, 'b'], [1, nil]],
50
+ ['-', [2, 'c'], [1, nil]],
51
+ ['-', [3, 'd'], [1, nil]],
52
+ ['=', [4, 'e'], [1, 'e']]
53
53
  ]
54
54
  }
55
55
 
56
- it_has_behavior "compare sequences correctly"
56
+ it_has_behavior 'compare sequences correctly'
57
57
  end
58
58
 
59
- describe "using %w(a e) & %w(a b c d e)" do
59
+ describe 'using %w(a e) & %w(a b c d e)' do
60
60
  let(:s1) { %w(a e) }
61
61
  let(:s2) { %w(a b c d e) }
62
62
  let(:result) {
63
63
  [
64
- [ '=', [ 0, 'a' ], [ 0, 'a' ] ],
65
- [ '+', [ 1, nil ], [ 1, 'b' ] ],
66
- [ '+', [ 1, nil ], [ 2, 'c' ] ],
67
- [ '+', [ 1, nil ], [ 3, 'd' ] ],
68
- [ '=', [ 1, 'e' ], [ 4, 'e' ] ]
64
+ ['=', [0, 'a'], [0, 'a']],
65
+ ['+', [1, nil], [1, 'b']],
66
+ ['+', [1, nil], [2, 'c']],
67
+ ['+', [1, nil], [3, 'd']],
68
+ ['=', [1, 'e'], [4, 'e']]
69
69
  ]
70
70
  }
71
71
 
72
- it_has_behavior "compare sequences correctly"
72
+ it_has_behavior 'compare sequences correctly'
73
73
  end
74
74
 
75
- describe "using %w(v x a e) & %w(w y a b c d e)" do
75
+ describe 'using %w(v x a e) & %w(w y a b c d e)' do
76
76
  let(:s1) { %w(v x a e) }
77
77
  let(:s2) { %w(w y a b c d e) }
78
78
  let(:result) {
79
79
  [
80
- [ '!', [ 0, 'v' ], [ 0, 'w' ] ],
81
- [ '!', [ 1, 'x' ], [ 1, 'y' ] ],
82
- [ '=', [ 2, 'a' ], [ 2, 'a' ] ],
83
- [ '+', [ 3, nil ], [ 3, 'b' ] ],
84
- [ '+', [ 3, nil ], [ 4, 'c' ] ],
85
- [ '+', [ 3, nil ], [ 5, 'd' ] ],
86
- [ '=', [ 3, 'e' ], [ 6, 'e' ] ]
80
+ ['!', [0, 'v'], [0, 'w']],
81
+ ['!', [1, 'x'], [1, 'y']],
82
+ ['=', [2, 'a'], [2, 'a']],
83
+ ['+', [3, nil], [3, 'b']],
84
+ ['+', [3, nil], [4, 'c']],
85
+ ['+', [3, nil], [5, 'd']],
86
+ ['=', [3, 'e'], [6, 'e']]
87
87
  ]
88
88
  }
89
89
 
90
- it_has_behavior "compare sequences correctly"
90
+ it_has_behavior 'compare sequences correctly'
91
91
  end
92
92
 
93
- describe "using %w(x a e) & %w(a b c d e)" do
93
+ describe 'using %w(x a e) & %w(a b c d e)' do
94
94
  let(:s1) { %w(x a e) }
95
95
  let(:s2) { %w(a b c d e) }
96
96
  let(:result) {
97
97
  [
98
- [ '-', [ 0, 'x' ], [ 0, nil ] ],
99
- [ '=', [ 1, 'a' ], [ 0, 'a' ] ],
100
- [ '+', [ 2, nil ], [ 1, 'b' ] ],
101
- [ '+', [ 2, nil ], [ 2, 'c' ] ],
102
- [ '+', [ 2, nil ], [ 3, 'd' ] ],
103
- [ '=', [ 2, 'e' ], [ 4, 'e' ] ]
98
+ ['-', [0, 'x'], [0, nil]],
99
+ ['=', [1, 'a'], [0, 'a']],
100
+ ['+', [2, nil], [1, 'b']],
101
+ ['+', [2, nil], [2, 'c']],
102
+ ['+', [2, nil], [3, 'd']],
103
+ ['=', [2, 'e'], [4, 'e']]
104
104
  ]
105
105
  }
106
106
 
107
- it_has_behavior "compare sequences correctly"
107
+ it_has_behavior 'compare sequences correctly'
108
108
  end
109
109
 
110
- describe "using %w(a e) & %w(x a b c d e)" do
110
+ describe 'using %w(a e) & %w(x a b c d e)' do
111
111
  let(:s1) { %w(a e) }
112
112
  let(:s2) { %w(x a b c d e) }
113
113
  let(:result) {
114
114
  [
115
- [ '+', [ 0, nil ], [ 0, 'x' ] ],
116
- [ '=', [ 0, 'a' ], [ 1, 'a' ] ],
117
- [ '+', [ 1, nil ], [ 2, 'b' ] ],
118
- [ '+', [ 1, nil ], [ 3, 'c' ] ],
119
- [ '+', [ 1, nil ], [ 4, 'd' ] ],
120
- [ '=', [ 1, 'e' ], [ 5, 'e' ] ]
115
+ ['+', [0, nil], [0, 'x']],
116
+ ['=', [0, 'a'], [1, 'a']],
117
+ ['+', [1, nil], [2, 'b']],
118
+ ['+', [1, nil], [3, 'c']],
119
+ ['+', [1, nil], [4, 'd']],
120
+ ['=', [1, 'e'], [5, 'e']]
121
121
  ]
122
122
  }
123
123
 
124
- it_has_behavior "compare sequences correctly"
124
+ it_has_behavior 'compare sequences correctly'
125
125
  end
126
126
 
127
- describe "using %w(a e v) & %w(x a b c d e w x)" do
127
+ describe 'using %w(a e v) & %w(x a b c d e w x)' do
128
128
  let(:s1) { %w(a e v) }
129
129
  let(:s2) { %w(x a b c d e w x) }
130
130
  let(:result) {
131
131
  [
132
- [ '+', [ 0, nil ], [ 0, 'x' ] ],
133
- [ '=', [ 0, 'a' ], [ 1, 'a' ] ],
134
- [ '+', [ 1, nil ], [ 2, 'b' ] ],
135
- [ '+', [ 1, nil ], [ 3, 'c' ] ],
136
- [ '+', [ 1, nil ], [ 4, 'd' ] ],
137
- [ '=', [ 1, 'e' ], [ 5, 'e' ] ],
138
- [ '!', [ 2, 'v' ], [ 6, 'w' ] ],
139
- [ '+', [ 3, nil ], [ 7, 'x' ] ]
132
+ ['+', [0, nil], [0, 'x']],
133
+ ['=', [0, 'a'], [1, 'a']],
134
+ ['+', [1, nil], [2, 'b']],
135
+ ['+', [1, nil], [3, 'c']],
136
+ ['+', [1, nil], [4, 'd']],
137
+ ['=', [1, 'e'], [5, 'e']],
138
+ ['!', [2, 'v'], [6, 'w']],
139
+ ['+', [3, nil], [7, 'x']]
140
140
  ]
141
141
  }
142
142
 
143
- it_has_behavior "compare sequences correctly"
143
+ it_has_behavior 'compare sequences correctly'
144
144
  end
145
145
 
146
- describe "using %w() & %w(a b c)" do
146
+ describe 'using %w() & %w(a b c)' do
147
147
  let(:s1) { %w() }
148
148
  let(:s2) { %w(a b c) }
149
149
  let(:result) {
150
150
  [
151
- [ '+', [ 0, nil ], [ 0, 'a' ] ],
152
- [ '+', [ 0, nil ], [ 1, 'b' ] ],
153
- [ '+', [ 0, nil ], [ 2, 'c' ] ]
151
+ ['+', [0, nil], [0, 'a']],
152
+ ['+', [0, nil], [1, 'b']],
153
+ ['+', [0, nil], [2, 'c']]
154
154
  ]
155
155
  }
156
156
 
157
- it_has_behavior "compare sequences correctly"
157
+ it_has_behavior 'compare sequences correctly'
158
158
  end
159
159
 
160
- describe "using %w(a b c) & %w(1)" do
160
+ describe 'using %w(a b c) & %w(1)' do
161
161
  let(:s1) { %w(a b c) }
162
162
  let(:s2) { %w(1) }
163
163
  let(:result) {
164
164
  [
165
- [ '!', [ 0, 'a' ], [ 0, '1' ] ],
166
- [ '-', [ 1, 'b' ], [ 1, nil ] ],
167
- [ '-', [ 2, 'c' ], [ 1, nil ] ]
165
+ ['!', [0, 'a'], [0, '1']],
166
+ ['-', [1, 'b'], [1, nil]],
167
+ ['-', [2, 'c'], [1, nil]]
168
168
  ]
169
169
  }
170
170
 
171
- it_has_behavior "compare sequences correctly"
171
+ it_has_behavior 'compare sequences correctly'
172
172
  end
173
173
 
174
- describe "using %w(a b c) & %w(c)" do
174
+ describe 'using %w(a b c) & %w(c)' do
175
175
  let(:s1) { %w(a b c) }
176
176
  let(:s2) { %w(c) }
177
177
  let(:result) {
178
178
  [
179
- [ '-', [ 0, 'a' ], [ 0, nil ] ],
180
- [ '-', [ 1, 'b' ], [ 0, nil ] ],
181
- [ '=', [ 2, 'c' ], [ 0, 'c' ] ]
179
+ ['-', [0, 'a'], [0, nil]],
180
+ ['-', [1, 'b'], [0, nil]],
181
+ ['=', [2, 'c'], [0, 'c']]
182
182
  ]
183
183
  }
184
184
 
185
- it_has_behavior "compare sequences correctly"
185
+ it_has_behavior 'compare sequences correctly'
186
186
  end
187
187
 
188
- describe "using %w(abcd efgh ijkl mnop) & []" do
188
+ describe 'using %w(abcd efgh ijkl mnop) & []' do
189
189
  let(:s1) { %w(abcd efgh ijkl mnop) }
190
190
  let(:s2) { [] }
191
191
  let(:result) {
192
192
  [
193
- [ '-', [ 0, 'abcd' ], [ 0, nil ] ],
194
- [ '-', [ 1, 'efgh' ], [ 0, nil ] ],
195
- [ '-', [ 2, 'ijkl' ], [ 0, nil ] ],
196
- [ '-', [ 3, 'mnop' ], [ 0, nil ] ]
193
+ ['-', [0, 'abcd'], [0, nil]],
194
+ ['-', [1, 'efgh'], [0, nil]],
195
+ ['-', [2, 'ijkl'], [0, nil]],
196
+ ['-', [3, 'mnop'], [0, nil]]
197
197
  ]
198
198
  }
199
199
 
200
- it_has_behavior "compare sequences correctly"
200
+ it_has_behavior 'compare sequences correctly'
201
201
  end
202
- end
203
202
 
204
- # vim: ft=ruby
203
+ describe 'using [[1,2]] & []' do
204
+ let(:s1) { [[1, 2]] }
205
+ let(:s2) { [] }
206
+ let(:result) {
207
+ [
208
+ ['-', [0, [1, 2]], [0, nil]]
209
+ ]
210
+ }
211
+
212
+ it_has_behavior 'compare sequences correctly'
213
+ end
214
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,87 @@
1
- # -*- ruby encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'rubygems'
4
4
  require 'pathname'
5
5
 
6
+ require 'psych' if RUBY_VERSION >= '1.9'
7
+
8
+ if ENV['COVERAGE']
9
+ require 'simplecov'
10
+
11
+ def require_do(resource)
12
+ require resource
13
+ yield if block_given?
14
+ rescue LoadError
15
+ nil
16
+ end
17
+
18
+ formatters = [SimpleCov::Formatter::HTMLFormatter]
19
+
20
+ require_do('simplecov-rcov') {
21
+ formatters << SimpleCov::Formatter::RcovFormatter
22
+ }
23
+ require_do('simplecov-vim/formatter') {
24
+ formatters << SimpleCov::Formatter::VimFormatter
25
+ }
26
+ require_do('simplecov-sublime-ruby-coverage') {
27
+ formatters << SimpleCov::Formatter::SublimeRubyCoverageFormatter
28
+ }
29
+
30
+ SimpleCov.start do
31
+ formatter SimpleCov::Formatter::MultiFormatter.new(formatters)
32
+ end
33
+ end
34
+
6
35
  file = Pathname.new(__FILE__).expand_path
7
36
  path = file.parent
8
37
  parent = path.parent
9
38
 
10
39
  $:.unshift parent.join('lib')
11
40
 
41
+ module CaptureSubprocessIO
42
+ def _synchronize
43
+ yield
44
+ end
45
+
46
+ def capture_subprocess_io
47
+ _synchronize { _capture_subprocess_io { yield } }
48
+ end
49
+
50
+ def _capture_subprocess_io
51
+ require 'tempfile'
52
+
53
+ captured_stdout, captured_stderr = Tempfile.new('out'), Tempfile.new('err')
54
+
55
+ orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
56
+ $stdout.reopen captured_stdout
57
+ $stderr.reopen captured_stderr
58
+
59
+ yield
60
+
61
+ $stdout.rewind
62
+ $stderr.rewind
63
+
64
+ [captured_stdout.read, captured_stderr.read]
65
+ ensure
66
+ captured_stdout.unlink
67
+ captured_stderr.unlink
68
+ $stdout.reopen orig_stdout
69
+ $stderr.reopen orig_stderr
70
+ end
71
+ private :_capture_subprocess_io
72
+ end
73
+
12
74
  require 'diff-lcs'
13
75
 
14
76
  module Diff::LCS::SpecHelper
77
+ def hello
78
+ 'hello'
79
+ end
80
+
81
+ def hello_ary
82
+ %w(h e l l o)
83
+ end
84
+
15
85
  def seq1
16
86
  %w(a b c e h j l m n p)
17
87
  end
@@ -38,50 +108,69 @@ module Diff::LCS::SpecHelper
38
108
 
39
109
  def correct_forward_diff
40
110
  [
41
- [ [ '-', 0, 'a' ] ],
42
- [ [ '+', 2, 'd' ] ],
43
- [ [ '-', 4, 'h' ],
44
- [ '+', 4, 'f' ] ],
45
- [ [ '+', 6, 'k' ] ],
46
- [ [ '-', 8, 'n' ],
47
- [ '-', 9, 'p' ],
48
- [ '+', 9, 'r' ],
49
- [ '+', 10, 's' ],
50
- [ '+', 11, 't' ] ]
111
+ [
112
+ ['-', 0, 'a']
113
+ ],
114
+ [
115
+ ['+', 2, 'd']
116
+ ],
117
+ [
118
+ ['-', 4, 'h'],
119
+ ['+', 4, 'f']
120
+ ],
121
+ [
122
+ ['+', 6, 'k']
123
+ ],
124
+ [
125
+ ['-', 8, 'n'],
126
+ ['+', 9, 'r'],
127
+ ['-', 9, 'p'],
128
+ ['+', 10, 's'],
129
+ ['+', 11, 't']
130
+ ]
51
131
  ]
52
132
  end
53
133
 
54
134
  def correct_backward_diff
55
135
  [
56
- [ [ '+', 0, 'a' ] ],
57
- [ [ '-', 2, 'd' ] ],
58
- [ [ '-', 4, 'f' ],
59
- [ '+', 4, 'h' ] ],
60
- [ [ '-', 6, 'k' ] ],
61
136
  [
62
- [ '-', 9, 'r' ],
63
- [ '-', 10, 's' ],
64
- [ '+', 8, 'n' ],
65
- [ '-', 11, 't' ],
66
- [ '+', 9, 'p' ] ]
137
+ ['+', 0, 'a']
138
+ ],
139
+ [
140
+ ['-', 2, 'd']
141
+ ],
142
+ [
143
+ ['-', 4, 'f'],
144
+ ['+', 4, 'h']
145
+ ],
146
+ [
147
+ ['-', 6, 'k']
148
+ ],
149
+ [
150
+ ['-', 9, 'r'],
151
+ ['+', 8, 'n'],
152
+ ['-', 10, 's'],
153
+ ['+', 9, 'p'],
154
+ ['-', 11, 't']
155
+ ]
67
156
  ]
68
157
  end
69
158
 
70
159
  def correct_forward_sdiff
71
160
  [
72
- [ '-', [ 0, 'a' ], [ 0, nil ] ],
73
- [ '=', [ 1, 'b' ], [ 0, 'b' ] ],
74
- [ '=', [ 2, 'c' ], [ 1, 'c' ] ],
75
- [ '+', [ 3, nil ], [ 2, 'd' ] ],
76
- [ '=', [ 3, 'e' ], [ 3, 'e' ] ],
77
- [ '!', [ 4, 'h' ], [ 4, 'f' ] ],
78
- [ '=', [ 5, 'j' ], [ 5, 'j' ] ],
79
- [ '+', [ 6, nil ], [ 6, 'k' ] ],
80
- [ '=', [ 6, 'l' ], [ 7, 'l' ] ],
81
- [ '=', [ 7, 'm' ], [ 8, 'm' ] ],
82
- [ '!', [ 8, 'n' ], [ 9, 'r' ] ],
83
- [ '!', [ 9, 'p' ], [ 10, 's' ] ],
84
- [ '+', [ 10, nil ], [ 11, 't' ] ]
161
+ ['-', [0, 'a'], [0, nil]],
162
+ ['=', [1, 'b'], [0, 'b']],
163
+ ['=', [2, 'c'], [1, 'c']],
164
+ ['+', [3, nil], [2, 'd']],
165
+ ['=', [3, 'e'], [3, 'e']],
166
+ ['!', [4, 'h'], [4, 'f']],
167
+ ['=', [5, 'j'], [5, 'j']],
168
+ ['+', [6, nil], [6, 'k']],
169
+ ['=', [6, 'l'], [7, 'l']],
170
+ ['=', [7, 'm'], [8, 'm']],
171
+ ['!', [8, 'n'], [9, 'r']],
172
+ ['!', [9, 'p'], [10, 's']],
173
+ ['+', [10, nil], [11, 't']]
85
174
  ]
86
175
  end
87
176
 
@@ -105,13 +194,13 @@ module Diff::LCS::SpecHelper
105
194
  end
106
195
 
107
196
  def format_diffs(diffs)
108
- diffs.map do |e|
197
+ diffs.map { |e|
109
198
  if e.kind_of?(Array)
110
- e.map { |f| f.to_a.join }.join(", ")
199
+ e.map { |f| f.to_a.join }.join(', ')
111
200
  else
112
201
  e.to_a.join
113
202
  end
114
- end.join("\n")
203
+ }.join("\n")
115
204
  end
116
205
 
117
206
  def map_diffs(diffs, klass = Diff::LCS::ContextChange)
@@ -132,8 +221,8 @@ module Diff::LCS::SpecHelper
132
221
 
133
222
  def balanced_reverse(change_result)
134
223
  new_result = []
135
- change_result.each { |line|
136
- line = [ line[0], line[2], line[1] ]
224
+ change_result.each do |line|
225
+ line = [line[0], line[2], line[1]]
137
226
  case line[0]
138
227
  when '<'
139
228
  line[0] = '>'
@@ -141,25 +230,24 @@ module Diff::LCS::SpecHelper
141
230
  line[0] = '<'
142
231
  end
143
232
  new_result << line
144
- }
145
- new_result.sort_by { |line| [ line[1], line[2] ] }
233
+ end
234
+ new_result.sort_by { |line| [line[1], line[2]] }
146
235
  end
147
236
 
148
237
  def map_to_no_change(change_result)
149
238
  new_result = []
150
- change_result.each { |line|
239
+ change_result.each do |line|
151
240
  case line[0]
152
241
  when '!'
153
- new_result << [ '<', line[1], line[2] ]
154
- new_result << [ '>', line[1] + 1, line[2] ]
242
+ new_result << ['<', line[1], line[2]]
243
+ new_result << ['>', line[1] + 1, line[2]]
155
244
  else
156
245
  new_result << line
157
246
  end
158
- }
247
+ end
159
248
  new_result
160
249
  end
161
250
 
162
-
163
251
  def simple_callback
164
252
  callbacks = Object.new
165
253
  class << callbacks
@@ -193,14 +281,17 @@ module Diff::LCS::SpecHelper
193
281
  end
194
282
 
195
283
  def finished_a(event)
196
- @done_a << [event.old_element, event.old_position,
197
- event.new_element, event.new_position]
284
+ @done_a << [
285
+ event.old_element, event.old_position,
286
+ event.new_element, event.new_position
287
+ ]
198
288
  end
199
289
 
200
290
  def finished_b(event)
201
- p "called #finished_b"
202
- @done_b << [event.old_element, event.old_position,
203
- event.new_element, event.new_position]
291
+ @done_b << [
292
+ event.old_element, event.old_position,
293
+ event.new_element, event.new_position
294
+ ]
204
295
  end
205
296
  end
206
297
  callbacks.reset
@@ -226,19 +317,19 @@ module Diff::LCS::SpecHelper
226
317
  end
227
318
 
228
319
  def match(event)
229
- @result << [ "=", event.old_position, event.new_position ]
320
+ @result << ['=', event.old_position, event.new_position]
230
321
  end
231
322
 
232
323
  def discard_a(event)
233
- @result << [ "<", event.old_position, event.new_position ]
324
+ @result << ['<', event.old_position, event.new_position]
234
325
  end
235
326
 
236
327
  def discard_b(event)
237
- @result << [ ">", event.old_position, event.new_position ]
328
+ @result << ['>', event.old_position, event.new_position]
238
329
  end
239
330
 
240
331
  def change(event)
241
- @result << [ "!", event.old_position, event.new_position ]
332
+ @result << ['!', event.old_position, event.new_position]
242
333
  end
243
334
  end
244
335
  cb.reset
@@ -258,14 +349,14 @@ module Diff::LCS::SpecHelper
258
349
 
259
350
  matcher :be_nil_or_match_values do |ii, s1, s2|
260
351
  match do |ee|
261
- ee.should satisfy { |vee| vee.nil? || s1[ii] == s2[ee] }
352
+ expect(ee).to(satisfy { |vee| vee.nil? || s1[ii] == s2[ee] })
262
353
  end
263
354
  end
264
355
 
265
356
  matcher :correctly_map_sequence do |s1|
266
357
  match do |actual|
267
358
  actual.each_with_index { |ee, ii|
268
- ee.should be_nil_or_match_values(ii, s1, @s2)
359
+ expect(ee).to be_nil_or_match_values(ii, s1, @s2)
269
360
  }
270
361
  end
271
362
 
@@ -279,6 +370,5 @@ end
279
370
  RSpec.configure do |conf|
280
371
  conf.include Diff::LCS::SpecHelper
281
372
  conf.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
373
+ conf.filter_run_excluding :broken => true
282
374
  end
283
-
284
- # vim: ft=ruby