diff-lcs 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'optparse'
4
- require 'ostruct'
5
- require 'diff/lcs/hunk'
3
+ require "optparse"
4
+ require "ostruct"
5
+ require "diff/lcs/hunk"
6
6
 
7
- module Diff::LCS::Ldiff #:nodoc:
7
+ module Diff::LCS::Ldiff # :nodoc:
8
+ # standard:disable Layout/HeredocIndentation
8
9
  BANNER = <<-COPYRIGHT
9
10
  ldiff #{Diff::LCS::VERSION}
10
11
  Copyright 2004-2019 Austin Ziegler
@@ -16,60 +17,61 @@ ldiff #{Diff::LCS::VERSION}
16
17
  the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
17
18
  MIT licence.
18
19
  COPYRIGHT
20
+ # standard:enable Layout/HeredocIndentation
19
21
  end
20
22
 
21
23
  class << Diff::LCS::Ldiff
22
- attr_reader :format, :lines #:nodoc:
23
- attr_reader :file_old, :file_new #:nodoc:
24
- attr_reader :data_old, :data_new #:nodoc:
24
+ attr_reader :format, :lines # :nodoc:
25
+ attr_reader :file_old, :file_new # :nodoc:
26
+ attr_reader :data_old, :data_new # :nodoc:
25
27
 
26
- def run(args, _input = $stdin, output = $stdout, error = $stderr) #:nodoc:
28
+ def run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
27
29
  @binary = nil
28
30
 
29
31
  args.options do |o|
30
32
  o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile"
31
- o.separator ''
33
+ o.separator ""
32
34
  o.on(
33
- '-c', '-C', '--context [LINES]', Integer,
34
- 'Displays a context diff with LINES lines', 'of context. Default 3 lines.'
35
+ "-c", "-C", "--context [LINES]", Integer,
36
+ "Displays a context diff with LINES lines", "of context. Default 3 lines."
35
37
  ) do |ctx|
36
38
  @format = :context
37
- @lines = ctx || 3
39
+ @lines = ctx || 3
38
40
  end
39
41
  o.on(
40
- '-u', '-U', '--unified [LINES]', Integer,
41
- 'Displays a unified diff with LINES lines', 'of context. Default 3 lines.'
42
+ "-u", "-U", "--unified [LINES]", Integer,
43
+ "Displays a unified diff with LINES lines", "of context. Default 3 lines."
42
44
  ) do |ctx|
43
45
  @format = :unified
44
- @lines = ctx || 3
46
+ @lines = ctx || 3
45
47
  end
46
- o.on('-e', 'Creates an \'ed\' script to change', 'oldfile to newfile.') do |_ctx|
48
+ o.on("-e", "Creates an 'ed' script to change", "oldfile to newfile.") do |_ctx|
47
49
  @format = :ed
48
50
  end
49
- o.on('-f', 'Creates an \'ed\' script to change', 'oldfile to newfile in reverse order.') do |_ctx|
51
+ o.on("-f", "Creates an 'ed' script to change", "oldfile to newfile in reverse order.") do |_ctx|
50
52
  @format = :reverse_ed
51
53
  end
52
54
  o.on(
53
- '-a', '--text',
54
- 'Treat the files as text and compare them', 'line-by-line, even if they do not seem', 'to be text.'
55
+ "-a", "--text",
56
+ "Treat the files as text and compare them", "line-by-line, even if they do not seem", "to be text."
55
57
  ) do |_txt|
56
58
  @binary = false
57
59
  end
58
- o.on('--binary', 'Treats the files as binary.') do |_bin|
60
+ o.on("--binary", "Treats the files as binary.") do |_bin|
59
61
  @binary = true
60
62
  end
61
- o.on('-q', '--brief', 'Report only whether or not the files', 'differ, not the details.') do |_ctx|
63
+ o.on("-q", "--brief", "Report only whether or not the files", "differ, not the details.") do |_ctx|
62
64
  @format = :report
63
65
  end
64
- o.on_tail('--help', 'Shows this text.') do
66
+ o.on_tail("--help", "Shows this text.") do
65
67
  error << o
66
68
  return 0
67
69
  end
68
- o.on_tail('--version', 'Shows the version of Diff::LCS.') do
70
+ o.on_tail("--version", "Shows the version of Diff::LCS.") do
69
71
  error << Diff::LCS::Ldiff::BANNER
70
72
  return 0
71
73
  end
72
- o.on_tail ''
74
+ o.on_tail ""
73
75
  o.on_tail 'By default, runs produces an "old-style" diff, with output like UNIX diff.'
74
76
  o.parse!
75
77
  end
@@ -81,25 +83,25 @@ class << Diff::LCS::Ldiff
81
83
 
82
84
  # Defaults are for old-style diff
83
85
  @format ||= :old
84
- @lines ||= 0
86
+ @lines ||= 0
85
87
 
86
88
  file_old, file_new = *ARGV
87
89
 
88
90
  case @format
89
91
  when :context
90
- char_old = '*' * 3
91
- char_new = '-' * 3
92
+ char_old = "*" * 3
93
+ char_new = "-" * 3
92
94
  when :unified
93
- char_old = '-' * 3
94
- char_new = '+' * 3
95
+ char_old = "-" * 3
96
+ char_new = "+" * 3
95
97
  end
96
98
 
97
99
  # After we've read up to a certain point in each file, the number of
98
100
  # items we've read from each file will differ by FLD (could be 0).
99
101
  file_length_difference = 0
100
102
 
101
- data_old = IO.read(file_old)
102
- data_new = IO.read(file_new)
103
+ data_old = File.read(file_old)
104
+ data_new = File.read(file_new)
103
105
 
104
106
  # Test binary status
105
107
  if @binary.nil?
@@ -128,10 +130,10 @@ class << Diff::LCS::Ldiff
128
130
  return 1
129
131
  end
130
132
 
131
- if (@format == :unified) or (@format == :context)
132
- ft = File.stat(file_old).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.000000000 %z')
133
+ if (@format == :unified) || (@format == :context)
134
+ ft = File.stat(file_old).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
133
135
  output << "#{char_old} #{file_old}\t#{ft}\n"
134
- ft = File.stat(file_new).mtime.localtime.strftime('%Y-%m-%d %H:%M:%S.000000000 %z')
136
+ ft = File.stat(file_new).mtime.localtime.strftime("%Y-%m-%d %H:%M:%S.000000000 %z")
135
137
  output << "#{char_new} #{file_new}\t#{ft}\n"
136
138
  end
137
139
 
@@ -150,7 +152,7 @@ class << Diff::LCS::Ldiff
150
152
  file_length_difference = hunk.file_length_difference
151
153
 
152
154
  next unless oldhunk
153
- next if @lines.positive? and hunk.merge(oldhunk)
155
+ next if @lines.positive? && hunk.merge(oldhunk)
154
156
 
155
157
  output << oldhunk.diff(@format)
156
158
  output << "\n" if @format == :unified
data/lib/diff/lcs.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Diff; end unless defined? Diff # rubocop:disable Style/Documentation
3
+ module Diff; end unless defined? Diff
4
4
 
5
5
  # == How Diff Works (by Mark-Jason Dominus)
6
6
  #
@@ -49,13 +49,13 @@ module Diff; end unless defined? Diff # rubocop:disable Style/Documentation
49
49
  # a x b y c z p d q
50
50
  # a b c a x b y c z
51
51
  module Diff::LCS
52
- VERSION = '1.5.0'
52
+ VERSION = "1.5.1"
53
53
  end
54
54
 
55
- require 'diff/lcs/callbacks'
56
- require 'diff/lcs/internals'
55
+ require "diff/lcs/callbacks"
56
+ require "diff/lcs/internals"
57
57
 
58
- module Diff::LCS # rubocop:disable Style/Documentation
58
+ module Diff::LCS
59
59
  # Returns an Array containing the longest common subsequence(s) between
60
60
  # +self+ and +other+. See Diff::LCS#lcs.
61
61
  #
@@ -67,7 +67,7 @@ module Diff::LCS # rubocop:disable Style/Documentation
67
67
  # identically for key purposes. That is:
68
68
  #
69
69
  # O.new('a').eql?(O.new('a')) == true
70
- def lcs(other, &block) #:yields self[i] if there are matched subsequences:
70
+ def lcs(other, &block) # :yields: self[i] if there are matched subsequences
71
71
  Diff::LCS.lcs(self, other, &block)
72
72
  end
73
73
 
@@ -101,7 +101,7 @@ module Diff::LCS # rubocop:disable Style/Documentation
101
101
  def patch(patchset)
102
102
  Diff::LCS.patch(self, patchset)
103
103
  end
104
- alias unpatch patch
104
+ alias_method :unpatch, :patch
105
105
 
106
106
  # Attempts to patch +self+ with the provided +patchset+. A new sequence based
107
107
  # on +self+ and the +patchset+ will be created. See Diff::LCS#patch. Does no
@@ -141,11 +141,11 @@ module Diff::LCS # rubocop:disable Style/Documentation
141
141
  end
142
142
 
143
143
  class << Diff::LCS
144
- def lcs(seq1, seq2, &block) #:yields seq1[i] for each matched:
144
+ def lcs(seq1, seq2, &block) # :yields: seq1[i] for each matched
145
145
  matches = Diff::LCS::Internals.lcs(seq1, seq2)
146
146
  ret = []
147
- string = seq1.kind_of? String
148
- matches.each_with_index do |_e, i|
147
+ string = seq1.is_a? String
148
+ matches.each_index do |i|
149
149
  next if matches[i].nil?
150
150
 
151
151
  v = string ? seq1[i, 1] : seq1[i]
@@ -154,7 +154,7 @@ class << Diff::LCS
154
154
  end
155
155
  ret
156
156
  end
157
- alias LCS lcs
157
+ alias_method :LCS, :lcs
158
158
 
159
159
  # #diff computes the smallest set of additions and deletions necessary to
160
160
  # turn the first sequence into the second, and returns a description of these
@@ -165,7 +165,7 @@ class << Diff::LCS
165
165
  # Class argument is provided for +callbacks+, #diff will attempt to
166
166
  # initialise it. If the +callbacks+ object (possibly initialised) responds to
167
167
  # #finish, it will be called.
168
- def diff(seq1, seq2, callbacks = nil, &block) # :yields diff changes:
168
+ def diff(seq1, seq2, callbacks = nil, &block) # :yields: diff changes
169
169
  diff_traversal(:diff, seq1, seq2, callbacks || Diff::LCS::DiffCallbacks, &block)
170
170
  end
171
171
 
@@ -197,7 +197,7 @@ class << Diff::LCS
197
197
  # # insert
198
198
  # end
199
199
  # end
200
- def sdiff(seq1, seq2, callbacks = nil, &block) #:yields diff changes:
200
+ def sdiff(seq1, seq2, callbacks = nil, &block) # :yields: diff changes
201
201
  diff_traversal(:sdiff, seq1, seq2, callbacks || Diff::LCS::SDiffCallbacks, &block)
202
202
  end
203
203
 
@@ -282,12 +282,12 @@ class << Diff::LCS
282
282
  # <tt>callbacks#discard_b</tt> will be called after the end of the sequence
283
283
  # is reached, if +a+ has not yet reached the end of +A+ or +b+ has not yet
284
284
  # reached the end of +B+.
285
- def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks) #:yields change events:
285
+ def traverse_sequences(seq1, seq2, callbacks = Diff::LCS::SequenceCallbacks) # :yields: change events
286
286
  callbacks ||= Diff::LCS::SequenceCallbacks
287
287
  matches = Diff::LCS::Internals.lcs(seq1, seq2)
288
288
 
289
289
  run_finished_a = run_finished_b = false
290
- string = seq1.kind_of?(String)
290
+ string = seq1.is_a?(String)
291
291
 
292
292
  a_size = seq1.size
293
293
  b_size = seq2.size
@@ -299,7 +299,7 @@ class << Diff::LCS
299
299
  ax = string ? seq1[ai, 1] : seq1[ai]
300
300
  bx = string ? seq2[bj, 1] : seq2[bj]
301
301
 
302
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
302
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
303
303
  event = yield event if block_given?
304
304
  callbacks.discard_a(event)
305
305
  end
@@ -310,13 +310,13 @@ class << Diff::LCS
310
310
  break unless bj < b_line
311
311
 
312
312
  bx = string ? seq2[bj, 1] : seq2[bj]
313
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
313
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
314
314
  event = yield event if block_given?
315
315
  callbacks.discard_b(event)
316
316
  bj += 1
317
317
  end
318
318
  bx = string ? seq2[bj, 1] : seq2[bj]
319
- event = Diff::LCS::ContextChange.new('=', ai, ax, bj, bx)
319
+ event = Diff::LCS::ContextChange.new("=", ai, ax, bj, bx)
320
320
  event = yield event if block_given?
321
321
  callbacks.match(event)
322
322
  bj += 1
@@ -326,13 +326,13 @@ class << Diff::LCS
326
326
 
327
327
  # The last entry (if any) processed was a match. +ai+ and +bj+ point just
328
328
  # past the last matching lines in their sequences.
329
- while (ai < a_size) or (bj < b_size)
329
+ while (ai < a_size) || (bj < b_size)
330
330
  # last A?
331
- if ai == a_size and bj < b_size
332
- if callbacks.respond_to?(:finished_a) and !run_finished_a
331
+ if ai == a_size && bj < b_size
332
+ if callbacks.respond_to?(:finished_a) && !run_finished_a
333
333
  ax = string ? seq1[-1, 1] : seq1[-1]
334
334
  bx = string ? seq2[bj, 1] : seq2[bj]
335
- event = Diff::LCS::ContextChange.new('>', (a_size - 1), ax, bj, bx)
335
+ event = Diff::LCS::ContextChange.new(">", (a_size - 1), ax, bj, bx)
336
336
  event = yield event if block_given?
337
337
  callbacks.finished_a(event)
338
338
  run_finished_a = true
@@ -340,7 +340,7 @@ class << Diff::LCS
340
340
  ax = string ? seq1[ai, 1] : seq1[ai]
341
341
  loop do
342
342
  bx = string ? seq2[bj, 1] : seq2[bj]
343
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
343
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
344
344
  event = yield event if block_given?
345
345
  callbacks.discard_b(event)
346
346
  bj += 1
@@ -350,11 +350,11 @@ class << Diff::LCS
350
350
  end
351
351
 
352
352
  # last B?
353
- if bj == b_size and ai < a_size
354
- if callbacks.respond_to?(:finished_b) and !run_finished_b
353
+ if bj == b_size && ai < a_size
354
+ if callbacks.respond_to?(:finished_b) && !run_finished_b
355
355
  ax = string ? seq1[ai, 1] : seq1[ai]
356
356
  bx = string ? seq2[-1, 1] : seq2[-1]
357
- event = Diff::LCS::ContextChange.new('<', ai, ax, (b_size - 1), bx)
357
+ event = Diff::LCS::ContextChange.new("<", ai, ax, (b_size - 1), bx)
358
358
  event = yield event if block_given?
359
359
  callbacks.finished_b(event)
360
360
  run_finished_b = true
@@ -362,7 +362,7 @@ class << Diff::LCS
362
362
  bx = string ? seq2[bj, 1] : seq2[bj]
363
363
  loop do
364
364
  ax = string ? seq1[ai, 1] : seq1[ai]
365
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
365
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
366
366
  event = yield event if block_given?
367
367
  callbacks.discard_a(event)
368
368
  ai += 1
@@ -374,7 +374,7 @@ class << Diff::LCS
374
374
  if ai < a_size
375
375
  ax = string ? seq1[ai, 1] : seq1[ai]
376
376
  bx = string ? seq2[bj, 1] : seq2[bj]
377
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
377
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
378
378
  event = yield event if block_given?
379
379
  callbacks.discard_a(event)
380
380
  ai += 1
@@ -383,7 +383,7 @@ class << Diff::LCS
383
383
  if bj < b_size
384
384
  ax = string ? seq1[ai, 1] : seq1[ai]
385
385
  bx = string ? seq2[bj, 1] : seq2[bj]
386
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
386
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
387
387
  event = yield event if block_given?
388
388
  callbacks.discard_b(event)
389
389
  bj += 1
@@ -478,14 +478,14 @@ class << Diff::LCS
478
478
  b_size = seq2.size
479
479
  ai = bj = mb = 0
480
480
  ma = -1
481
- string = seq1.kind_of?(String)
481
+ string = seq1.is_a?(String)
482
482
 
483
483
  # Process all the lines in the match vector.
484
484
  loop do
485
485
  # Find next match indices +ma+ and +mb+
486
486
  loop do
487
487
  ma += 1
488
- break unless ma < matches.size and matches[ma].nil?
488
+ break unless ma < matches.size && matches[ma].nil?
489
489
  end
490
490
 
491
491
  break if ma >= matches.size # end of matches?
@@ -493,36 +493,36 @@ class << Diff::LCS
493
493
  mb = matches[ma]
494
494
 
495
495
  # Change(seq2)
496
- while (ai < ma) or (bj < mb)
496
+ while (ai < ma) || (bj < mb)
497
497
  ax = string ? seq1[ai, 1] : seq1[ai]
498
498
  bx = string ? seq2[bj, 1] : seq2[bj]
499
499
 
500
500
  case [(ai < ma), (bj < mb)]
501
501
  when [true, true]
502
502
  if callbacks.respond_to?(:change)
503
- event = Diff::LCS::ContextChange.new('!', ai, ax, bj, bx)
503
+ event = Diff::LCS::ContextChange.new("!", ai, ax, bj, bx)
504
504
  event = yield event if block_given?
505
505
  callbacks.change(event)
506
506
  ai += 1
507
507
  else
508
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
508
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
509
509
  event = yield event if block_given?
510
510
  callbacks.discard_a(event)
511
511
  ai += 1
512
512
  ax = string ? seq1[ai, 1] : seq1[ai]
513
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
513
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
514
514
  event = yield event if block_given?
515
515
  callbacks.discard_b(event)
516
516
  end
517
517
 
518
518
  bj += 1
519
519
  when [true, false]
520
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
520
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
521
521
  event = yield event if block_given?
522
522
  callbacks.discard_a(event)
523
523
  ai += 1
524
524
  when [false, true]
525
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
525
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
526
526
  event = yield event if block_given?
527
527
  callbacks.discard_b(event)
528
528
  bj += 1
@@ -532,43 +532,43 @@ class << Diff::LCS
532
532
  # Match
533
533
  ax = string ? seq1[ai, 1] : seq1[ai]
534
534
  bx = string ? seq2[bj, 1] : seq2[bj]
535
- event = Diff::LCS::ContextChange.new('=', ai, ax, bj, bx)
535
+ event = Diff::LCS::ContextChange.new("=", ai, ax, bj, bx)
536
536
  event = yield event if block_given?
537
537
  callbacks.match(event)
538
538
  ai += 1
539
539
  bj += 1
540
540
  end
541
541
 
542
- while (ai < a_size) or (bj < b_size)
542
+ while (ai < a_size) || (bj < b_size)
543
543
  ax = string ? seq1[ai, 1] : seq1[ai]
544
544
  bx = string ? seq2[bj, 1] : seq2[bj]
545
545
 
546
546
  case [(ai < a_size), (bj < b_size)]
547
547
  when [true, true]
548
548
  if callbacks.respond_to?(:change)
549
- event = Diff::LCS::ContextChange.new('!', ai, ax, bj, bx)
549
+ event = Diff::LCS::ContextChange.new("!", ai, ax, bj, bx)
550
550
  event = yield event if block_given?
551
551
  callbacks.change(event)
552
552
  ai += 1
553
553
  else
554
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
554
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
555
555
  event = yield event if block_given?
556
556
  callbacks.discard_a(event)
557
557
  ai += 1
558
558
  ax = string ? seq1[ai, 1] : seq1[ai]
559
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
559
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
560
560
  event = yield event if block_given?
561
561
  callbacks.discard_b(event)
562
562
  end
563
563
 
564
564
  bj += 1
565
565
  when [true, false]
566
- event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
566
+ event = Diff::LCS::ContextChange.new("-", ai, ax, bj, bx)
567
567
  event = yield event if block_given?
568
568
  callbacks.discard_a(event)
569
569
  ai += 1
570
570
  when [false, true]
571
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
571
+ event = Diff::LCS::ContextChange.new("+", ai, ax, bj, bx)
572
572
  event = yield event if block_given?
573
573
  callbacks.discard_b(event)
574
574
  bj += 1
@@ -576,10 +576,12 @@ class << Diff::LCS
576
576
  end
577
577
  end
578
578
 
579
- PATCH_MAP = { #:nodoc:
580
- :patch => { '+' => '+', '-' => '-', '!' => '!', '=' => '=' }.freeze,
581
- :unpatch => { '+' => '-', '-' => '+', '!' => '!', '=' => '=' }.freeze
579
+ # standard:disable Style/HashSyntax
580
+ PATCH_MAP = { # :nodoc:
581
+ :patch => {"+" => "+", "-" => "-", "!" => "!", "=" => "="}.freeze,
582
+ :unpatch => {"+" => "-", "-" => "+", "!" => "!", "=" => "="}.freeze
582
583
  }.freeze
584
+ # standard:enable Style/HashSyntax
583
585
 
584
586
  # Applies a +patchset+ to the sequence +src+ according to the +direction+
585
587
  # (<tt>:patch</tt> or <tt>:unpatch</tt>), producing a new sequence.
@@ -627,7 +629,7 @@ class << Diff::LCS
627
629
 
628
630
  return src.respond_to?(:dup) ? src.dup : src unless has_changes
629
631
 
630
- string = src.kind_of?(String)
632
+ string = src.is_a?(String)
631
633
  # Start with a new empty type of the source's class
632
634
  res = src.class.new
633
635
 
@@ -655,14 +657,14 @@ class << Diff::LCS
655
657
  end
656
658
 
657
659
  case action
658
- when '-' # Remove details from the old string
660
+ when "-" # Remove details from the old string
659
661
  while ai < op
660
662
  res << (string ? src[ai, 1] : src[ai])
661
663
  ai += 1
662
664
  bj += 1
663
665
  end
664
666
  ai += 1
665
- when '+'
667
+ when "+"
666
668
  while bj < np
667
669
  res << (string ? src[ai, 1] : src[ai])
668
670
  ai += 1
@@ -671,7 +673,7 @@ class << Diff::LCS
671
673
 
672
674
  res << el
673
675
  bj += 1
674
- when '='
676
+ when "="
675
677
  # This only appears in sdiff output with the SDiff callback.
676
678
  # Therefore, we only need to worry about dealing with a single
677
679
  # element.
@@ -679,7 +681,7 @@ class << Diff::LCS
679
681
 
680
682
  ai += 1
681
683
  bj += 1
682
- when '!'
684
+ when "!"
683
685
  while ai < op
684
686
  res << (string ? src[ai, 1] : src[ai])
685
687
  ai += 1
@@ -693,14 +695,14 @@ class << Diff::LCS
693
695
  end
694
696
  when Diff::LCS::Change
695
697
  case action
696
- when '-'
698
+ when "-"
697
699
  while ai < change.position
698
700
  res << (string ? src[ai, 1] : src[ai])
699
701
  ai += 1
700
702
  bj += 1
701
703
  end
702
704
  ai += 1
703
- when '+'
705
+ when "+"
704
706
  while bj < change.position
705
707
  res << (string ? src[ai, 1] : src[ai])
706
708
  ai += 1
@@ -736,4 +738,4 @@ class << Diff::LCS
736
738
  end
737
739
  end
738
740
 
739
- require 'diff/lcs/backports'
741
+ require "diff/lcs/backports"
data/lib/diff-lcs.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'diff/lcs'
3
+ require "diff/lcs"