diff-lcs 1.4.4 → 1.5.1

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