diff-lcs 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +3 -0
- data/.rspec +2 -0
- data/.travis.yml +21 -0
- data/Contributing.rdoc +63 -0
- data/Gemfile +20 -0
- data/History.rdoc +37 -1
- data/Manifest.txt +10 -1
- data/README.rdoc +48 -23
- data/Rakefile +17 -3
- data/autotest/discover.rb +1 -0
- data/diff-lcs.gemspec +41 -29
- data/docs/COPYING.txt +21 -22
- data/docs/artistic.txt +127 -0
- data/lib/diff-lcs.rb +0 -2
- data/lib/diff/lcs.rb +654 -954
- data/lib/diff/lcs/array.rb +1 -15
- data/lib/diff/lcs/block.rb +4 -18
- data/lib/diff/lcs/callbacks.rb +222 -222
- data/lib/diff/lcs/change.rb +110 -102
- data/lib/diff/lcs/htmldiff.rb +0 -2
- data/lib/diff/lcs/hunk.rb +65 -56
- data/lib/diff/lcs/internals.rb +300 -0
- data/lib/diff/lcs/ldiff.rb +154 -169
- data/lib/diff/lcs/string.rb +1 -15
- data/spec/change_spec.rb +65 -0
- data/spec/diff_spec.rb +8 -2
- data/spec/issues_spec.rb +24 -0
- data/spec/lcs_spec.rb +23 -5
- data/spec/patch_spec.rb +51 -27
- data/spec/sdiff_spec.rb +0 -2
- data/spec/spec_helper.rb +9 -3
- data/spec/traverse_balanced_spec.rb +26 -2
- data/spec/traverse_sequences_spec.rb +84 -28
- metadata +219 -83
- data/docs/artistic.html +0 -289
data/lib/diff/lcs/array.rb
CHANGED
@@ -1,18 +1,4 @@
|
|
1
|
-
|
2
|
-
#--
|
3
|
-
# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
|
4
|
-
# adapted from:
|
5
|
-
# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
|
6
|
-
# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
|
7
|
-
# implements McIlroy-Hunt diff algorithm
|
8
|
-
#
|
9
|
-
# This program is free software. It may be redistributed and/or modified under
|
10
|
-
# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
|
11
|
-
# Ruby licence.
|
12
|
-
#
|
13
|
-
# $Id$
|
14
|
-
#++
|
15
|
-
# Includes Diff::LCS into the Array built-in class.
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
16
2
|
|
17
3
|
require 'diff/lcs'
|
18
4
|
|
data/lib/diff/lcs/block.rb
CHANGED
@@ -1,22 +1,8 @@
|
|
1
|
-
|
2
|
-
#--
|
3
|
-
# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
|
4
|
-
# adapted from:
|
5
|
-
# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
|
6
|
-
# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
|
7
|
-
# implements McIlroy-Hunt diff algorithm
|
8
|
-
#
|
9
|
-
# This program is free software. It may be redistributed and/or modified under
|
10
|
-
# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
|
11
|
-
# Ruby licence.
|
12
|
-
#
|
13
|
-
# $Id$
|
14
|
-
#++
|
15
|
-
# Contains Diff::LCS::Block for bin/ldiff.
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
16
2
|
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
# A block is an operation removing, adding, or changing a group of items.
|
4
|
+
# Basically, this is just a list of changes, where each change adds or
|
5
|
+
# deletes a single item. Used by bin/ldiff.
|
20
6
|
class Diff::LCS::Block
|
21
7
|
attr_reader :changes, :insert, :remove
|
22
8
|
|
data/lib/diff/lcs/callbacks.rb
CHANGED
@@ -1,44 +1,31 @@
|
|
1
|
-
|
2
|
-
#--
|
3
|
-
# Copyright 2004 Austin Ziegler <diff-lcs@halostatue.ca>
|
4
|
-
# adapted from:
|
5
|
-
# Algorithm::Diff (Perl) by Ned Konz <perl@bike-nomad.com>
|
6
|
-
# Smalltalk by Mario I. Wolczko <mario@wolczko.com>
|
7
|
-
# implements McIlroy-Hunt diff algorithm
|
8
|
-
#
|
9
|
-
# This program is free software. It may be redistributed and/or modified under
|
10
|
-
# the terms of the GPL version 2 (or later), the Perl Artistic licence, or the
|
11
|
-
# Ruby licence.
|
12
|
-
#
|
13
|
-
# $Id$
|
14
|
-
#++
|
15
|
-
# Contains definitions for all default callback objects.
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
16
2
|
|
17
3
|
require 'diff/lcs/change'
|
18
4
|
|
19
5
|
module Diff::LCS
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
# This callback object implements the default set of callback events,
|
7
|
+
# which only returns the event itself. Note that #finished_a and
|
8
|
+
# #finished_b are not implemented -- I haven't yet figured out where they
|
9
|
+
# would be useful.
|
10
|
+
#
|
11
|
+
# Note that this is intended to be called as is, e.g.,
|
12
|
+
#
|
13
|
+
# Diff::LCS.LCS(seq1, seq2, Diff::LCS::DefaultCallbacks)
|
27
14
|
class DefaultCallbacks
|
28
15
|
class << self
|
29
|
-
|
16
|
+
# Called when two items match.
|
30
17
|
def match(event)
|
31
18
|
event
|
32
19
|
end
|
33
|
-
|
20
|
+
# Called when the old value is discarded in favour of the new value.
|
34
21
|
def discard_a(event)
|
35
22
|
event
|
36
23
|
end
|
37
|
-
|
24
|
+
# Called when the new value is discarded in favour of the old value.
|
38
25
|
def discard_b(event)
|
39
26
|
event
|
40
27
|
end
|
41
|
-
|
28
|
+
# Called when both the old and new values have changed.
|
42
29
|
def change(event)
|
43
30
|
event
|
44
31
|
end
|
@@ -47,65 +34,74 @@ module Diff::LCS
|
|
47
34
|
end
|
48
35
|
end
|
49
36
|
|
50
|
-
|
51
|
-
|
52
|
-
|
37
|
+
# An alias for DefaultCallbacks that is used in
|
38
|
+
# Diff::LCS#traverse_sequences.
|
39
|
+
#
|
40
|
+
# Diff::LCS.LCS(seq1, seq2, Diff::LCS::SequenceCallbacks)
|
53
41
|
SequenceCallbacks = DefaultCallbacks
|
54
|
-
|
55
|
-
|
56
|
-
|
42
|
+
|
43
|
+
# An alias for DefaultCallbacks that is used in
|
44
|
+
# Diff::LCS#traverse_balanced.
|
45
|
+
#
|
46
|
+
# Diff::LCS.LCS(seq1, seq2, Diff::LCS::BalancedCallbacks)
|
57
47
|
BalancedCallbacks = DefaultCallbacks
|
48
|
+
|
49
|
+
def self.callbacks_for(callbacks)
|
50
|
+
callbacks.new rescue callbacks
|
51
|
+
end
|
58
52
|
end
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
54
|
+
# This will produce a compound array of simple diff change objects. Each
|
55
|
+
# element in the #diffs array is a +hunk+ or +hunk+ array, where each
|
56
|
+
# element in each +hunk+ array is a single Change object representing the
|
57
|
+
# addition or removal of a single element from one of the two tested
|
58
|
+
# sequences. The +hunk+ provides the full context for the changes.
|
59
|
+
#
|
60
|
+
# diffs = Diff::LCS.diff(seq1, seq2)
|
61
|
+
# # This example shows a simplified array format.
|
62
|
+
# # [ [ [ '-', 0, 'a' ] ], # 1
|
63
|
+
# # [ [ '+', 2, 'd' ] ], # 2
|
64
|
+
# # [ [ '-', 4, 'h' ], # 3
|
65
|
+
# # [ '+', 4, 'f' ] ],
|
66
|
+
# # [ [ '+', 6, 'k' ] ], # 4
|
67
|
+
# # [ [ '-', 8, 'n' ], # 5
|
68
|
+
# # [ '-', 9, 'p' ],
|
69
|
+
# # [ '+', 9, 'r' ],
|
70
|
+
# # [ '+', 10, 's' ],
|
71
|
+
# # [ '+', 11, 't' ] ] ]
|
72
|
+
#
|
73
|
+
# There are five hunks here. The first hunk says that the +a+ at position 0
|
74
|
+
# of the first sequence should be deleted (<tt>'-'</tt>). The second hunk
|
75
|
+
# says that the +d+ at position 2 of the second sequence should be inserted
|
76
|
+
# (<tt>'+'</tt>). The third hunk says that the +h+ at position 4 of the
|
77
|
+
# first sequence should be removed and replaced with the +f+ from position 4
|
78
|
+
# of the second sequence. The other two hunks are described similarly.
|
79
|
+
#
|
80
|
+
# === Use
|
81
|
+
#
|
82
|
+
# This callback object must be initialised and is used by the Diff::LCS#diff
|
83
|
+
# method.
|
84
|
+
#
|
85
|
+
# cbo = Diff::LCS::DiffCallbacks.new
|
86
|
+
# Diff::LCS.LCS(seq1, seq2, cbo)
|
87
|
+
# cbo.finish
|
88
|
+
#
|
89
|
+
# Note that the call to #finish is absolutely necessary, or the last set of
|
90
|
+
# changes will not be visible. Alternatively, can be used as:
|
91
|
+
#
|
92
|
+
# cbo = Diff::LCS::DiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
93
|
+
#
|
94
|
+
# The necessary #finish call will be made.
|
95
|
+
#
|
96
|
+
# === Simplified Array Format
|
97
|
+
#
|
98
|
+
# The simplified array format used in the example above can be obtained
|
99
|
+
# with:
|
100
|
+
#
|
101
|
+
# require 'pp'
|
102
|
+
# pp diffs.map { |e| e.map { |f| f.to_a } }
|
107
103
|
class Diff::LCS::DiffCallbacks
|
108
|
-
|
104
|
+
# Returns the difference set collected during the diff process.
|
109
105
|
attr_reader :diffs
|
110
106
|
|
111
107
|
def initialize # :yields self:
|
@@ -121,14 +117,14 @@ class Diff::LCS::DiffCallbacks
|
|
121
117
|
end
|
122
118
|
end
|
123
119
|
|
124
|
-
|
125
|
-
|
120
|
+
# Finalizes the diff process. If an unprocessed hunk still exists, then it
|
121
|
+
# is appended to the diff list.
|
126
122
|
def finish
|
127
|
-
|
123
|
+
finish_hunk
|
128
124
|
end
|
129
125
|
|
130
126
|
def match(event)
|
131
|
-
|
127
|
+
finish_hunk
|
132
128
|
end
|
133
129
|
|
134
130
|
def discard_a(event)
|
@@ -139,86 +135,88 @@ class Diff::LCS::DiffCallbacks
|
|
139
135
|
@hunk << Diff::LCS::Change.new('+', event.new_position, event.new_element)
|
140
136
|
end
|
141
137
|
|
142
|
-
|
143
|
-
def add_nonempty_hunk
|
138
|
+
def finish_hunk
|
144
139
|
@diffs << @hunk unless @hunk.empty?
|
145
140
|
@hunk = []
|
146
141
|
end
|
142
|
+
private :finish_hunk
|
147
143
|
end
|
148
144
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
145
|
+
# This will produce a compound array of contextual diff change objects. Each
|
146
|
+
# element in the #diffs array is a "hunk" array, where each element in each
|
147
|
+
# "hunk" array is a single change. Each change is a Diff::LCS::ContextChange
|
148
|
+
# that contains both the old index and new index values for the change. The
|
149
|
+
# "hunk" provides the full context for the changes. Both old and new objects
|
150
|
+
# will be presented for changed objects. +nil+ will be substituted for a
|
151
|
+
# discarded object.
|
152
|
+
#
|
153
|
+
# seq1 = %w(a b c e h j l m n p)
|
154
|
+
# seq2 = %w(b c d e f j k l m r s t)
|
155
|
+
#
|
156
|
+
# diffs = Diff::LCS.diff(seq1, seq2, Diff::LCS::ContextDiffCallbacks)
|
157
|
+
# # This example shows a simplified array format.
|
158
|
+
# # [ [ [ '-', [ 0, 'a' ], [ 0, nil ] ] ], # 1
|
159
|
+
# # [ [ '+', [ 3, nil ], [ 2, 'd' ] ] ], # 2
|
160
|
+
# # [ [ '-', [ 4, 'h' ], [ 4, nil ] ], # 3
|
161
|
+
# # [ '+', [ 5, nil ], [ 4, 'f' ] ] ],
|
162
|
+
# # [ [ '+', [ 6, nil ], [ 6, 'k' ] ] ], # 4
|
163
|
+
# # [ [ '-', [ 8, 'n' ], [ 9, nil ] ], # 5
|
164
|
+
# # [ '+', [ 9, nil ], [ 9, 'r' ] ],
|
165
|
+
# # [ '-', [ 9, 'p' ], [ 10, nil ] ],
|
166
|
+
# # [ '+', [ 10, nil ], [ 10, 's' ] ],
|
167
|
+
# # [ '+', [ 10, nil ], [ 11, 't' ] ] ] ]
|
168
|
+
#
|
169
|
+
# The five hunks shown are comprised of individual changes; if there is a
|
170
|
+
# related set of changes, they are still shown individually.
|
171
|
+
#
|
172
|
+
# This callback can also be used with Diff::LCS#sdiff, which will produce
|
173
|
+
# results like:
|
174
|
+
#
|
175
|
+
# diffs = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextCallbacks)
|
176
|
+
# # This example shows a simplified array format.
|
177
|
+
# # [ [ [ "-", [ 0, "a" ], [ 0, nil ] ] ], # 1
|
178
|
+
# # [ [ "+", [ 3, nil ], [ 2, "d" ] ] ], # 2
|
179
|
+
# # [ [ "!", [ 4, "h" ], [ 4, "f" ] ] ], # 3
|
180
|
+
# # [ [ "+", [ 6, nil ], [ 6, "k" ] ] ], # 4
|
181
|
+
# # [ [ "!", [ 8, "n" ], [ 9, "r" ] ], # 5
|
182
|
+
# # [ "!", [ 9, "p" ], [ 10, "s" ] ],
|
183
|
+
# # [ "+", [ 10, nil ], [ 11, "t" ] ] ] ]
|
184
|
+
#
|
185
|
+
# The five hunks are still present, but are significantly shorter in total
|
186
|
+
# presentation, because changed items are shown as changes ("!") instead of
|
187
|
+
# potentially "mismatched" pairs of additions and deletions.
|
188
|
+
#
|
189
|
+
# The result of this operation is similar to that of
|
190
|
+
# Diff::LCS::SDiffCallbacks. They may be compared as:
|
191
|
+
#
|
192
|
+
# s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
|
193
|
+
# c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten
|
194
|
+
#
|
195
|
+
# s == c # -> true
|
196
|
+
#
|
197
|
+
# === Use
|
198
|
+
#
|
199
|
+
# This callback object must be initialised and can be used by the
|
200
|
+
# Diff::LCS#diff or Diff::LCS#sdiff methods.
|
201
|
+
#
|
202
|
+
# cbo = Diff::LCS::ContextDiffCallbacks.new
|
203
|
+
# Diff::LCS.LCS(seq1, seq2, cbo)
|
204
|
+
# cbo.finish
|
205
|
+
#
|
206
|
+
# Note that the call to #finish is absolutely necessary, or the last set of
|
207
|
+
# changes will not be visible. Alternatively, can be used as:
|
208
|
+
#
|
209
|
+
# cbo = Diff::LCS::ContextDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
210
|
+
#
|
211
|
+
# The necessary #finish call will be made.
|
212
|
+
#
|
213
|
+
# === Simplified Array Format
|
214
|
+
#
|
215
|
+
# The simplified array format used in the example above can be obtained
|
216
|
+
# with:
|
217
|
+
#
|
218
|
+
# require 'pp'
|
219
|
+
# pp diffs.map { |e| e.map { |f| f.to_a } }
|
222
220
|
class Diff::LCS::ContextDiffCallbacks < Diff::LCS::DiffCallbacks
|
223
221
|
def discard_a(event)
|
224
222
|
@hunk << Diff::LCS::ContextChange.simplify(event)
|
@@ -233,70 +231,72 @@ class Diff::LCS::ContextDiffCallbacks < Diff::LCS::DiffCallbacks
|
|
233
231
|
end
|
234
232
|
end
|
235
233
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
234
|
+
# This will produce a simple array of diff change objects. Each element in
|
235
|
+
# the #diffs array is a single ContextChange. In the set of #diffs provided
|
236
|
+
# by SDiffCallbacks, both old and new objects will be presented for both
|
237
|
+
# changed <strong>and unchanged</strong> objects. +nil+ will be substituted
|
238
|
+
# for a discarded object.
|
239
|
+
#
|
240
|
+
# The diffset produced by this callback, when provided to Diff::LCS#sdiff,
|
241
|
+
# will compute and display the necessary components to show two sequences
|
242
|
+
# and their minimized differences side by side, just like the Unix utility
|
243
|
+
# +sdiff+.
|
244
|
+
#
|
245
|
+
# same same
|
246
|
+
# before | after
|
247
|
+
# old < -
|
248
|
+
# - > new
|
249
|
+
#
|
250
|
+
# seq1 = %w(a b c e h j l m n p)
|
251
|
+
# seq2 = %w(b c d e f j k l m r s t)
|
252
|
+
#
|
253
|
+
# diffs = Diff::LCS.sdiff(seq1, seq2)
|
254
|
+
# # This example shows a simplified array format.
|
255
|
+
# # [ [ "-", [ 0, "a"], [ 0, nil ] ],
|
256
|
+
# # [ "=", [ 1, "b"], [ 0, "b" ] ],
|
257
|
+
# # [ "=", [ 2, "c"], [ 1, "c" ] ],
|
258
|
+
# # [ "+", [ 3, nil], [ 2, "d" ] ],
|
259
|
+
# # [ "=", [ 3, "e"], [ 3, "e" ] ],
|
260
|
+
# # [ "!", [ 4, "h"], [ 4, "f" ] ],
|
261
|
+
# # [ "=", [ 5, "j"], [ 5, "j" ] ],
|
262
|
+
# # [ "+", [ 6, nil], [ 6, "k" ] ],
|
263
|
+
# # [ "=", [ 6, "l"], [ 7, "l" ] ],
|
264
|
+
# # [ "=", [ 7, "m"], [ 8, "m" ] ],
|
265
|
+
# # [ "!", [ 8, "n"], [ 9, "r" ] ],
|
266
|
+
# # [ "!", [ 9, "p"], [ 10, "s" ] ],
|
267
|
+
# # [ "+", [ 10, nil], [ 11, "t" ] ] ]
|
268
|
+
#
|
269
|
+
# The result of this operation is similar to that of
|
270
|
+
# Diff::LCS::ContextDiffCallbacks. They may be compared as:
|
271
|
+
#
|
272
|
+
# s = Diff::LCS.sdiff(seq1, seq2).reject { |e| e.action == "=" }
|
273
|
+
# c = Diff::LCS.sdiff(seq1, seq2, Diff::LCS::ContextDiffCallbacks).flatten
|
274
|
+
#
|
275
|
+
# s == c # -> true
|
276
|
+
#
|
277
|
+
# === Use
|
278
|
+
#
|
279
|
+
# This callback object must be initialised and is used by the Diff::LCS#sdiff
|
280
|
+
# method.
|
281
|
+
#
|
282
|
+
# cbo = Diff::LCS::SDiffCallbacks.new
|
283
|
+
# Diff::LCS.LCS(seq1, seq2, cbo)
|
284
|
+
#
|
285
|
+
# As with the other initialisable callback objects,
|
286
|
+
# Diff::LCS::SDiffCallbacks can be initialised with a block. As there is no
|
287
|
+
# "fininishing" to be done, this has no effect on the state of the object.
|
288
|
+
#
|
289
|
+
# cbo = Diff::LCS::SDiffCallbacks.new { |tcbo| Diff::LCS.LCS(seq1, seq2, tcbo) }
|
290
|
+
#
|
291
|
+
# === Simplified Array Format
|
292
|
+
#
|
293
|
+
# The simplified array format used in the example above can be obtained
|
294
|
+
# with:
|
295
|
+
#
|
296
|
+
# require 'pp'
|
297
|
+
# pp diffs.map { |e| e.to_a }
|
298
298
|
class Diff::LCS::SDiffCallbacks
|
299
|
-
|
299
|
+
# Returns the difference set collected during the diff process.
|
300
300
|
attr_reader :diffs
|
301
301
|
|
302
302
|
def initialize #:yields self:
|