diff-lcs 1.4.4 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a82b46de7966bb69d8293ece23c885ff05a3a6f1828d99466079026200e3bd
4
- data.tar.gz: af785a974e010578214c66694d3e2fd232b26a452d41049a55a9127c07f4b4d4
3
+ metadata.gz: 0df61a794bf8b132a80753391063526ffc15277d5f2dc592d319d37255d3700f
4
+ data.tar.gz: 9664b2f8338ff376bf7b4c9c1ae45e591e789b00b726a53523a2076f014aa5e0
5
5
  SHA512:
6
- metadata.gz: 1f9ef284f2af3cb47d73100700dbfc39ac16802735f6751637025ed803604b7e27272b34ed1deccc2ddc4813b6e170c7ae2b3012afb094fc5e72d446866455e4
7
- data.tar.gz: 0b5b56817c536cd55c52e43f2e9ac5b70d76ef1edf9dcf1e7639917da16fcd65f1bf4472df7c44d8d44603c2f5caa2748ce6ddbd41bb7b0215ad3fd0c38fb49a
6
+ metadata.gz: 37e529e14e23a3c121f3d5cc3f88fbed90d9efe44376bb579699126c2c1d2ea34649a079902dca42cb72f891daa27e347c99b2e0a32b58245117dd2567af2db0
7
+ data.tar.gz: 30576530bd6e1634635989729caeeaed68b9268423b659443b95abc66549491376f179b558b07dc8cc9bcf14f2768433d771c037514ec720a21a43dc9c197a5f
data/Contributing.md CHANGED
@@ -110,6 +110,7 @@ Thanks to everyone else who has contributed code or bug reports to Diff::LCS:
110
110
  - Ryan Lovelett
111
111
  - Scott Steele
112
112
  - Simon Courtois
113
+ - Tien (@tiendo1011)
113
114
  - Tomas Jura
114
115
  - Vít Ondruch
115
116
 
data/History.md CHANGED
@@ -1,107 +1,161 @@
1
1
  # History
2
2
 
3
+ ## 1.5.0 / 2021-12-23
4
+
5
+ - Updated the CI configuration and monkey-patch Hoe.
6
+
7
+ - Kenichi Kamiya fixed a test configuration deprecation in SimpleCov. [#69]
8
+
9
+ - Tien introduced several corrections and code improvements:
10
+
11
+ - Removed an off-by-one error when calculating an index value by embracing
12
+ Ruby iteration properly. This had a side-effect of fixing a long-standing
13
+ bug in `#traverse_sequences` where the traversal would not be transitive.
14
+ That is, `LCS(s2, s1)` should produce a sequence that is transitive with
15
+ `LCS(s1, s2)` on traversal, and applying the diff computed from those
16
+ results would result in equivalent changes that could be played forward or
17
+ backward as appropriate. [#71], [#75]
18
+
19
+ - The above fix resulted in a changed order of the longest common subsequence
20
+ when callbacks were applied. After analysis, it was determined that the
21
+ computed subsequence was _equivalent_ to the prior version, so the test was
22
+ updated. This also resulted in the clarification of documentation when
23
+ traversing the subsequences. [#79]
24
+
25
+ - An infinite loop case in the case where Diff::LCS would be included into an
26
+ enumerable class has been fixed. [#73]
27
+
28
+ - Clarified the purpose of a threshold test in calculation of LCS. [#72],
29
+ [#80]
30
+
31
+ - Removed autotest directory
32
+
3
33
  ## 1.4.4 / 2020-07-01
4
34
 
5
35
  - Fixed an issue reported by Jun Aruga in the Diff::LCS::Ldiff binary text
6
- detection. [#44][]
36
+ detection. [#44]
37
+
7
38
  - Fixed a theoretical issue reported by Jun Aruga in Diff::LCS::Hunk to raise
8
- a more useful exception. [#43][]
39
+ a more useful exception. [#43]
40
+
9
41
  - Added documentation that should address custom object issues as reported in
10
- [#35][].
42
+ [#35].
43
+
44
+ - Fixed more diff errors, in part reported in [#65].
11
45
 
12
- - Fixed more diff errors, in part reported in [#65][].
46
+ - The use of `Numeric#abs` is incorrect in `Diff::LCS::Block#diff_size`. The
47
+ diff size _must_ be accurate for correct change placement.
13
48
 
14
- - The use of `Numeric#abs` is incorrect in `Diff::LCS::Block#diff_size`.
15
- The diff size _must_ be accurate for correct change placement.
16
49
  - When selecting @max_diff_size in Diff::LCS::Hunk, choose it based on
17
50
  `block.diff_size.abs`.
18
- - Made a number of changes that will, unfortunately, increase allocations
19
- at the cost of being safe with frozen strings.
20
- - Add some knowledge that when `Diff::LCS::Hunk#diff` is called, that we
21
- are processing the _last_ hunk, so some changes will be made to how the
22
- output is generated.
51
+
52
+ - Made a number of changes that will, unfortunately, increase allocations at
53
+ the cost of being safe with frozen strings.
54
+
55
+ - Add some knowledge that when `Diff::LCS::Hunk#diff` is called, that we are
56
+ processing the _last_ hunk, so some changes will be made to how the output
57
+ is generated.
23
58
 
24
59
  - `old`, `ed`, and `reverse_ed` formats have no differences.
60
+
25
61
  - `unified` format will report `` given the
26
- correct conditions, at most once. Unified range reporting also
27
- differs for the last hunk such that the `length` of the range is
28
- reduced by one.
62
+ correct conditions, at most once. Unified range reporting also differs for
63
+ the last hunk such that the `length` of the range is reduced by one.
64
+
29
65
  - `context` format will report `\No newline at end of file` given the
30
66
  correct conditions, up to once per "file". Context range reporting also
31
- differs for the last hunk such that the `end` part of the range is
32
- reduced by one to a minimum of one.
67
+ differs for the last hunk such that the `end` part of the range is reduced
68
+ by one to a minimum of one.
33
69
 
34
- - Added a bunch more tests for the cases above, and fixed `hunk_spec.rb` so
35
- that the phrase being compared isn't nonsense French.
70
+ - Added a bunch more tests for the cases above, and fixed `hunk_spec.rb` so that
71
+ the phrase being compared isn't nonsense French.
36
72
 
37
73
  - Updated formatting.
74
+
38
75
  - Added a Rake task to assist with manual testing on Ruby 1.8.
39
76
 
40
77
  ## 1.4.3 / 2020-06-29
41
78
 
42
79
  - Fixed several issues with the 1.4 on Rubies older than 2.0. Some of this was
43
- providing useful shim functions to Hoe 3.x (which dropped these older
44
- Rubies a while ago). Specifically:
80
+ providing useful shim functions to Hoe 3.x (which dropped these older Rubies
81
+ a while ago). Specifically:
45
82
 
46
83
  - Removed Array#lazy from a method in Diff::LCS::Hunk.
84
+
47
85
  - Changed some unit tests to use old-style Symbol-keyed hashes.
48
- - Changed some unit test helper functions to no longer use keyword
49
- parameters, but only a trailing options hash.
86
+
87
+ - Changed some unit test helper functions to no longer use keyword parameters,
88
+ but only a trailing options hash.
89
+
50
90
  - Made the use of `psych` dependent on `RUBY_VERSION >= 1.9`.
51
91
 
52
- Resolves [#63][].
92
+ Resolves [#63].
53
93
 
54
94
  ## 1.4.2 / 2020-06-23
55
95
 
56
- - Camille Drapier fixed a small issue with RuboCop configuration. [#59][]
96
+ - Camille Drapier fixed a small issue with RuboCop configuration. [#59]
97
+
57
98
  - Applied another fix (and unit test) to fix an issue for the Chef team.
58
- [#60][], [#61][]
99
+ [#60], [#61]
59
100
 
60
101
  ## 1.4.1 / 2020-06-23
61
102
 
62
- - Fix an issue where diff sizes could be negative, and they should be. [#57][],
63
- [#58][]
103
+ - Fix an issue where diff sizes could be negative, and they should be. [#57],
104
+ [#58]
64
105
 
65
106
  ## 1.4 / 2020-06-23
66
107
 
67
- - Ruby versions lower than 2.4 are soft-deprecated and will not be run as
68
- part of the CI process any longer.
108
+ - Ruby versions lower than 2.4 are soft-deprecated and will not be run as part
109
+ of the CI process any longer.
110
+
69
111
  - Akinora MUSHA (knu) added the ability for Diff::LCS::Change objects to be
70
- implicitly treated arrays. Originally provided as pull request [#47][],
71
- but it introduced a number of test failures as documented in [#48][], and
72
- remediation of Diff::LCS itself was introduced in [#49][].
73
- - Resolved [#5][] with some tests comparing output from `system` calls to
74
- `bin/ldiff` with some pre-generated output. Resolved [#6][] with these
75
- tests.
76
- - Resolved a previously undetected `bin/ldiff` issue with `--context` output
77
- not matching `diff --context` output.
112
+ implicitly treated arrays. Originally provided as pull request [#47], but it
113
+ introduced a number of test failures as documented in [#48], and remediation
114
+ of Diff::LCS itself was introduced in [#49].
115
+
116
+ - Resolved [#5] with some tests comparing output from `system` calls to
117
+ `bin/ldiff` with some pre-generated output. Resolved [#6] with these tests.
118
+
119
+ - Resolved a previously undetected `bin/ldiff` issue with `--context` output not
120
+ matching `diff --context` output.
121
+
78
122
  - Resolved an issue with later versions of Ruby not working with an `OptParse`
79
123
  specification of `Numeric`; this has been changed to `Integer`.
80
- - Brandon Fish added truffleruby in [#52][].
81
- - Fixed two missing classes as reported in [#53][].
124
+
125
+ - Brandon Fish added truffleruby in [#52].
126
+
127
+ - Fixed two missing classes as reported in [#53].
82
128
 
83
129
  ## 1.3 / 2017-01-18
84
130
 
85
131
  - Bugs fixed:
86
132
 
87
- - Fixed an error for bin/ldiff --version. Fixes issue [#21][].
133
+ - Fixed an error for bin/ldiff --version. Fixes issue [#21].
134
+
88
135
  - Force Diff::LCS::Change and Diff::LCS::ContextChange to only perform
89
- equality comparisons against themselves. Provided by Kevin Mook in
90
- pull request [#29][].
91
- - Fix tab expansion in htmldiff, provided by Mark Friedgan in
92
- pull request [#25][].
93
- - Silence Ruby 2.4 Fixnum deprecation warnings. Fixxues issue [#38][] and
94
- [pull request#36][].
95
- - Ensure that test dependencies are loaded properly. Fixes issue [#33][]
96
- and pull request [#34][].
97
- - Fix issue [#1][] with incorrect intuition of patch direction. Tentative
98
- fix, but the previous failure cases pass now.
136
+ equality comparisons against themselves. Provided by Kevin Mook in pull
137
+ request [#29].
138
+
139
+ - Fix tab expansion in htmldiff, provided by Mark Friedgan in pull request
140
+ [#25].
141
+
142
+ - Silence Ruby 2.4 Fixnum deprecation warnings. Fixes issue [#38] and pull
143
+ request [#36].
144
+
145
+ - Ensure that test dependencies are loaded properly. Fixes issue [#33] and
146
+ pull request [#34].
147
+
148
+ - Fix issue [#1] with incorrect intuition of patch direction. Tentative fix,
149
+ but the previous failure cases pass now.
99
150
 
100
151
  - Tooling changes:
101
152
 
102
153
  - Added SimpleCov and Coveralls support.
154
+
103
155
  - Change the homepage (temporarily) to the GitHub repo.
156
+
104
157
  - Updated testing and gem infrastructure.
158
+
105
159
  - Modernized the specs.
106
160
 
107
161
  - Cleaned up documentation.
@@ -112,20 +166,19 @@
112
166
 
113
167
  - Bugs fixed:
114
168
 
115
- - Comparing arrays flattened them too far, especially with
116
- Diff::LCS.sdiff. Fixed by Josh Bronson in pull request [#23][].
169
+ - Comparing arrays flattened them too far, especially with Diff::LCS.sdiff.
170
+ Fixed by Josh Bronson in pull request [#23].
117
171
 
118
172
  ## 1.2.4 / 2013-04-20
119
173
 
120
174
  - Bugs fixed:
121
175
 
122
- - A bug was introduced after 1.1.3 when pruning common sequences at the
123
- start of comparison. Paul Kunysch (@pck) fixed this in
124
- pull request [#18][]. Thanks!
176
+ - A bug was introduced after 1.1.3 when pruning common sequences at the start
177
+ of comparison. Paul Kunysch (@pck) fixed this in pull request [#18]. Thanks!
125
178
 
126
- - The Rubinius (1.9 mode) bug in [rubinius/rubinius#2268][] has been
127
- fixed by the Rubinius team two days after it was filed. Thanks for
128
- fixing this so quickly!
179
+ - The Rubinius (1.9 mode) bug in [rubinius/rubinius#2268] has been fixed by
180
+ the Rubinius team two days after it was filed. Thanks for fixing this so
181
+ quickly!
129
182
 
130
183
  - Switching to Raggi's hoe-gemspec2 for gemspec generation.
131
184
 
@@ -135,94 +188,106 @@
135
188
 
136
189
  - The new encoding detection for diff output generation (added in 1.2.2)
137
190
  introduced a bug if the left side of the comparison was the empty set.
138
- Originally found in [rspec/rspec-expectations#238][] and
139
- [rspec/rspec-expectations#239][]. Jon Rowe developed a reasonable
140
- heuristic (left side, right side, empty string literal) to avoid this
141
- bug.
191
+ Originally found in [rspec/rspec-expectations#238] and
192
+ [rspec/rspec-expectations#239]. Jon Rowe developed a reasonable heuristic
193
+ (left side, right side, empty string literal) to avoid this bug.
194
+
142
195
  - There is a known issue with Rubinius in 1.9 mode reported in
143
- [rubinius/rubinius#2268][] and demonstrated in the Travis CI builds.
144
- For all other tested platforms, diff-lcs is considered stable. As soon
145
- as a suitably small test-case can be created for the Rubinius team to
146
- examine, this will be added to the Rubinius issue around this.
196
+ [rubinius/rubinius#2268] and demonstrated in the Travis CI builds. For all
197
+ other tested platforms, diff-lcs is considered stable. As soon as a suitably
198
+ small test-case can be created for the Rubinius team to examine, this will
199
+ be added to the Rubinius issue around this.
147
200
 
148
201
  ## 1.2.2 / 2013-03-30
149
202
 
150
203
  - Bugs Fixed:
151
204
 
152
- - Diff::LCS::Hunk could not properly generate a difference for comparison
153
- sets that are not US-ASCII-compatible because of the use of literal
154
- regular expressions and strings. Jon Rowe found this in
155
- [rspec/rspec-expectations#219][] and provided a first pass
156
- implementation in pull request [#15][]. I've reworked it because of
157
- test failures in Rubinius when running in Ruby 1.9 mode. This coerces
158
- the added values to the encoding of the old dataset (as determined by
159
- the first piece of the old dataset).
205
+ - Diff::LCS::Hunk could not properly generate a difference for comparison sets
206
+ that are not US-ASCII-compatible because of the use of literal regular
207
+ expressions and strings. Jon Rowe found this in
208
+ [rspec/rspec-expectations#219] and provided a first pass implementation in
209
+ pull request [#15]. I've reworked it because of test failures in Rubinius
210
+ when running in Ruby 1.9 mode. This coerces the added values to the encoding
211
+ of the old dataset (as determined by the first piece of the old dataset).
212
+
160
213
  - Adding Travis CI testing for Ruby 2.0.
161
214
 
162
215
  ## 1.2.1 / 2013-02-09
163
216
 
164
217
  - Bugs Fixed:
165
218
 
166
- - As seen in [rspec/rspec-expectations#200][], the release of
167
- Diff::LCS 1.2 introduced an unnecessary public API change to
168
- Diff::LCS::Hunk (see the change at
169
- [rspec/rspec-expectations@3d6fc82c][] for details). The new method name
170
- (and behaviour) is more correct, but I should not have renamed the
171
- function or should have at least provided an alias. This release
172
- restores Diff::LCS::Hunk#unshift as an alias to #merge. Note that the
173
- old #unshift behaviour was incorrect and will not be restored.
219
+ - As seen in [rspec/rspec-expectations#200], the release of Diff::LCS 1.2
220
+ introduced an unnecessary public API change to Diff::LCS::Hunk (see the
221
+ change at [rspec/rspec-expectations@3d6fc82c] for details). The new method
222
+ name (and behaviour) is more correct, but I should not have renamed the
223
+ function or should have at least provided an alias. This release restores
224
+ Diff::LCS::Hunk#unshift as an alias to #merge. Note that the old #unshift
225
+ behaviour was incorrect and will not be restored.
174
226
 
175
227
  ## 1.2.0 / 2013-01-21
176
228
 
177
229
  - Minor Enhancements:
178
230
 
179
- - Added special case handling for Diff::LCS.patch so that it handles
180
- patches that are empty or contain no changes.
181
- - Added two new methods (#patch_me and #unpatch_me) to the includable
182
- module.
231
+ - Added special case handling for Diff::LCS.patch so that it handles patches
232
+ that are empty or contain no changes.
233
+
234
+ - Added two new methods (#patch_me and #unpatch_me) to the includable module.
183
235
 
184
236
  - Bugs Fixed:
185
237
 
186
- - Fixed issue [#1][] patch direction detection.
187
- - Resolved issue [#2][] by handling `string[string.size, 1]` properly (it
238
+ - Fixed issue [#1] patch direction detection.
239
+
240
+ - Resolved issue [#2] by handling `string[string.size, 1]` properly (it
188
241
  returns `""` not `nil`).
189
- - Michael Granger (ged) fixed an implementation error in
190
- Diff::LCS::Change and added specs in pull request [#8][]. Thanks!
242
+
243
+ - Michael Granger (ged) fixed an implementation error in Diff::LCS::Change and
244
+ added specs in pull request [#8]. Thanks!
245
+
191
246
  - Made the code auto-testable.
192
- - Vít Ondruch (voxik) provided the latest version of the GPL2 license
193
- file in pull request [#10][]. Thanks!
247
+
248
+ - Vít Ondruch (voxik) provided the latest version of the GPL2 license file in
249
+ pull request [#10]. Thanks!
250
+
194
251
  - Fixed a documentation issue with the includable versions of #patch! and
195
- #unpatch! where they implied that they would replace the original
196
- value. Given that Diff::LCS.patch always returns a copy, the
197
- documentation was incorrect and has been corrected. To provide the
198
- behaviour that was originally documented, two new methods were added to
199
- provide this behaviour. Found by scooter-dangle in issue [#12][].
200
- Thanks!
252
+ #unpatch! where they implied that they would replace the original value.
253
+ Given that Diff::LCS.patch always returns a copy, the documentation was
254
+ incorrect and has been corrected. To provide the behaviour that was
255
+ originally documented, two new methods were added to provide this behaviour.
256
+ Found by scooter-dangle in issue [#12]. Thanks!
201
257
 
202
258
  - Code Style Changes:
203
259
 
204
260
  - Removed trailing spaces.
261
+
205
262
  - Calling class methods using `.` instead of `::`.
206
- - Vít Ondruch (voxik) removed unnecessary shebangs in pull request [#9][].
263
+
264
+ - Vít Ondruch (voxik) removed unnecessary shebangs in pull request [#9].
207
265
  Thanks!
266
+
208
267
  - Kenichi Kamiya (kachick) removed some warnings of an unused variable in
209
- lucky pull request [#13][]. Thanks!
210
- - Embarked on a major refactoring to make the files a little more
211
- manageable and understand the code on a deeper level.
268
+ lucky pull request [#13]. Thanks!
269
+
270
+ - Embarked on a major refactoring to make the files a little more manageable
271
+ and understand the code on a deeper level.
272
+
212
273
  - Adding to http://travis-ci.org.
213
274
 
214
275
  ## 1.1.3 / 2011-08-27
215
276
 
216
277
  - Converted to 'hoe' for release.
278
+
217
279
  - Converted tests to RSpec 2.
218
- - Extracted the body of htmldiff into a class available from
219
- diff/lcs/htmldiff.
280
+
281
+ - Extracted the body of htmldiff into a class available from diff/lcs/htmldiff.
282
+
220
283
  - Migrated development and issue tracking to GitHub.
284
+
221
285
  - Bugs fixed:
222
286
 
223
- - Eliminated the explicit use of RubyGems in both bin/htmldiff and
224
- bin/ldiff. Resolves issue [#4][].
225
- - Eliminated Ruby warnings. Resolves issue [#3][].
287
+ - Eliminated the explicit use of RubyGems in both bin/htmldiff and bin/ldiff.
288
+ Resolves issue [#4].
289
+
290
+ - Eliminated Ruby warnings. Resolves issue [#3].
226
291
 
227
292
  ## 1.1.2 / 2004-10-20
228
293
 
@@ -232,31 +297,38 @@
232
297
 
233
298
  - Fixed bug #891 (Set returned from patch command does not contain last equal
234
299
  part).
300
+
235
301
  - Fixed a problem with callback initialisation code (it assumed that all
236
- callbacks passed as classes can be initialised; now, it rescues
237
- NoMethodError in the event of private :new being called).
302
+ callbacks passed as classes can be initialised; now, it rescues NoMethodError
303
+ in the event of private :new being called).
304
+
238
305
  - Modified the non-initialisable callbacks to have a private #new method.
306
+
239
307
  - Moved ldiff core code to Diff::LCS::Ldiff (diff/lcs/ldiff.rb).
240
308
 
241
- ## 1.1.0 / -
309
+ ## 1.1.0
242
310
 
243
311
  - Eliminated the need for Diff::LCS::Event and removed it.
312
+
244
313
  - Added a contextual diff callback, Diff::LCS::ContextDiffCallback.
245
- - Implemented patching/unpatching for standard Diff callback output formats
246
- with both #diff and #sdiff.
314
+
315
+ - Implemented patching/unpatching for standard Diff callback output formats with
316
+ both #diff and #sdiff.
317
+
247
318
  - Extensive documentation changes.
248
319
 
249
320
  ## 1.0.4
250
321
 
251
- - Fixed a problem with bin/ldiff output, especially for unified format.
252
- Newlines that should have been present weren't.
253
- - Changed the .tar.gz installer to generate Windows batch files if ones do
254
- not exist already. Removed the existing batch files as they didn't work.
322
+ - Fixed a problem with bin/ldiff output, especially for unified format. Newlines
323
+ that should have been present weren't.
324
+
325
+ - Changed the .tar.gz installer to generate Windows batch files if ones do not
326
+ exist already. Removed the existing batch files as they didn't work.
255
327
 
256
328
  ## 1.0.3
257
329
 
258
- - Fixed a problem with #traverse_sequences where the first difference from
259
- the left sequence might not be appropriately captured.
330
+ - Fixed a problem with #traverse_sequences where the first difference from the
331
+ left sequence might not be appropriately captured.
260
332
 
261
333
  ## 1.0.2
262
334
 
@@ -266,8 +338,10 @@
266
338
  ## 1.0.1
267
339
 
268
340
  - Minor modifications to the gemspec, the README.
269
- - Renamed the diff program to ldiff (as well as the companion batch file) so
270
- as to not collide with the standard diff program.
341
+
342
+ - Renamed the diff program to ldiff (as well as the companion batch file) so as
343
+ to not collide with the standard diff program.
344
+
271
345
  - Fixed issues with RubyGems. Requires RubyGems > 0.6.1 or >= 0.6.1 with the
272
346
  latest CVS version.
273
347
 
@@ -317,3 +391,10 @@
317
391
  [#61]: https://github.com/halostatue/diff-lcs/pull/61
318
392
  [#63]: https://github.com/halostatue/diff-lcs/issues/63
319
393
  [#65]: https://github.com/halostatue/diff-lcs/issues/65
394
+ [#69]: https://github.com/halostatue/diff-lcs/issues/69
395
+ [#71]: https://github.com/halostatue/diff-lcs/issues/71
396
+ [#72]: https://github.com/halostatue/diff-lcs/issues/72
397
+ [#73]: https://github.com/halostatue/diff-lcs/issues/73
398
+ [#75]: https://github.com/halostatue/diff-lcs/issues/75
399
+ [#79]: https://github.com/halostatue/diff-lcs/issues/79
400
+ [#80]: https://github.com/halostatue/diff-lcs/issues/80
data/Manifest.txt CHANGED
@@ -6,7 +6,6 @@ License.md
6
6
  Manifest.txt
7
7
  README.rdoc
8
8
  Rakefile
9
- autotest/discover.rb
10
9
  bin/htmldiff
11
10
  bin/ldiff
12
11
  docs/COPYING.txt
@@ -34,6 +33,21 @@ spec/fixtures/ldiff/output.diff-c
34
33
  spec/fixtures/ldiff/output.diff-e
35
34
  spec/fixtures/ldiff/output.diff-f
36
35
  spec/fixtures/ldiff/output.diff-u
36
+ spec/fixtures/ldiff/output.diff.chef
37
+ spec/fixtures/ldiff/output.diff.chef-c
38
+ spec/fixtures/ldiff/output.diff.chef-e
39
+ spec/fixtures/ldiff/output.diff.chef-f
40
+ spec/fixtures/ldiff/output.diff.chef-u
41
+ spec/fixtures/ldiff/output.diff.chef2
42
+ spec/fixtures/ldiff/output.diff.chef2-c
43
+ spec/fixtures/ldiff/output.diff.chef2-d
44
+ spec/fixtures/ldiff/output.diff.chef2-e
45
+ spec/fixtures/ldiff/output.diff.chef2-f
46
+ spec/fixtures/ldiff/output.diff.chef2-u
47
+ spec/fixtures/new-chef
48
+ spec/fixtures/new-chef2
49
+ spec/fixtures/old-chef
50
+ spec/fixtures/old-chef2
37
51
  spec/hunk_spec.rb
38
52
  spec/issues_spec.rb
39
53
  spec/lcs_spec.rb
data/Rakefile CHANGED
@@ -2,8 +2,44 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rspec'
5
+ require 'rspec/core/rake_task'
5
6
  require 'hoe'
6
7
 
8
+ # This is required until https://github.com/seattlerb/hoe/issues/112 is fixed
9
+ class Hoe
10
+ def with_config
11
+ config = Hoe::DEFAULT_CONFIG
12
+
13
+ rc = File.expand_path("~/.hoerc")
14
+ homeconfig = load_config(rc)
15
+ config = config.merge(homeconfig)
16
+
17
+ localconfig = load_config(File.expand_path(File.join(Dir.pwd, ".hoerc")))
18
+ config = config.merge(localconfig)
19
+
20
+ yield config, rc
21
+ end
22
+
23
+ def load_config(name)
24
+ File.exist?(name) ? safe_load_yaml(name) : {}
25
+ end
26
+
27
+ def safe_load_yaml(name)
28
+ return safe_load_yaml_file(name) if YAML.respond_to?(:safe_load_file)
29
+
30
+ data = IO.binread(name)
31
+ YAML.safe_load(data, permitted_classes: [Regexp])
32
+ rescue
33
+ YAML.safe_load(data, [Regexp])
34
+ end
35
+
36
+ def safe_load_yaml_file(name)
37
+ YAML.safe_load_file(name, permitted_classes: [Regexp])
38
+ rescue
39
+ YAML.safe_load_file(name, [Regexp])
40
+ end
41
+ end
42
+
7
43
  Hoe.plugin :bundler
8
44
  Hoe.plugin :doofus
9
45
  Hoe.plugin :gemspec2
@@ -44,9 +80,20 @@ _spec = Hoe.spec 'diff-lcs' do
44
80
  extra_dev_deps << ['hoe-rubygems', '~> 1.0']
45
81
  extra_dev_deps << ['rspec', '>= 2.0', '< 4']
46
82
  extra_dev_deps << ['rake', '>= 10.0', '< 14']
47
- extra_dev_deps << ['rdoc', '>= 0']
83
+ extra_dev_deps << ['rdoc', '>= 6.3.1', '< 7']
48
84
  end
49
85
 
86
+ desc "Run all specifications"
87
+ RSpec::Core::RakeTask.new(:spec) do |t|
88
+ rspec_dirs = %w(spec lib).join(":")
89
+ t.rspec_opts = ["-I#{rspec_dirs}"]
90
+ end
91
+
92
+ Rake::Task["spec"].actions.uniq! { |a| a.source_location }
93
+
94
+ task :default => :spec unless Rake::Task["default"].prereqs.include?("spec")
95
+ task :test => :spec unless Rake::Task["test"].prereqs.include?("spec")
96
+
50
97
  if RUBY_VERSION >= '2.0' && RUBY_ENGINE == 'ruby'
51
98
  namespace :spec do
52
99
  desc "Runs test coverage. Only works Ruby 2.0+ and assumes 'simplecov' is installed."
@@ -44,13 +44,12 @@ class << Diff::LCS::Internals
44
44
  b_finish = b.size - 1
45
45
  vector = []
46
46
 
47
- # Prune off any common elements at the beginning...
47
+ # Collect any common elements at the beginning...
48
48
  while (a_start <= a_finish) and (b_start <= b_finish) and (a[a_start] == b[b_start])
49
49
  vector[a_start] = b_start
50
50
  a_start += 1
51
51
  b_start += 1
52
52
  end
53
- b_start = a_start
54
53
 
55
54
  # Now the end...
56
55
  while (a_start <= a_finish) and (b_start <= b_finish) and (a[a_finish] == b[b_finish])
@@ -60,6 +59,7 @@ class << Diff::LCS::Internals
60
59
  end
61
60
 
62
61
  # Now, compute the equivalence classes of positions of elements.
62
+ # An explanation for how this works: https://codeforces.com/topic/92191
63
63
  b_matches = position_hash(b, b_start..b_finish)
64
64
 
65
65
  thresh = []
@@ -71,6 +71,10 @@ class << Diff::LCS::Internals
71
71
  bm = b_matches[ai]
72
72
  k = nil
73
73
  bm.reverse_each do |j|
74
+ # Although the threshold check is not mandatory for this to work,
75
+ # it may have an optimization purpose
76
+ # An attempt to remove it: https://github.com/halostatue/diff-lcs/pull/72
77
+ # Why it is reintroduced: https://github.com/halostatue/diff-lcs/issues/78
74
78
  if k and (thresh[k] > j) and (thresh[k - 1] < j)
75
79
  thresh[k] = j
76
80
  else
@@ -253,7 +257,7 @@ enumerable as either source or destination value."
253
257
  end
254
258
 
255
259
  # Binary search for the insertion point
256
- last_index ||= enum.size
260
+ last_index ||= enum.size - 1
257
261
  first_index = 0
258
262
  while first_index <= last_index
259
263
  i = (first_index + last_index) >> 1
data/lib/diff/lcs.rb CHANGED
@@ -49,7 +49,7 @@ 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.4.4'
52
+ VERSION = '1.5.0'
53
53
  end
54
54
 
55
55
  require 'diff/lcs/callbacks'
@@ -85,14 +85,14 @@ module Diff::LCS # rubocop:disable Style/Documentation
85
85
  # Traverses the discovered longest common subsequences between +self+ and
86
86
  # +other+. See Diff::LCS#traverse_sequences.
87
87
  def traverse_sequences(other, callbacks = nil, &block)
88
- traverse_sequences(self, other, callbacks || Diff::LCS::SequenceCallbacks, &block)
88
+ Diff::LCS.traverse_sequences(self, other, callbacks || Diff::LCS::SequenceCallbacks, &block)
89
89
  end
90
90
 
91
91
  # Traverses the discovered longest common subsequences between +self+ and
92
92
  # +other+ using the alternate, balanced algorithm. See
93
93
  # Diff::LCS#traverse_balanced.
94
94
  def traverse_balanced(other, callbacks = nil, &block)
95
- traverse_balanced(self, other, callbacks || Diff::LCS::BalancedCallbacks, &block)
95
+ Diff::LCS.traverse_balanced(self, other, callbacks || Diff::LCS::BalancedCallbacks, &block)
96
96
  end
97
97
 
98
98
  # Attempts to patch +self+ with the provided +patchset+. A new sequence based
@@ -250,8 +250,9 @@ class << Diff::LCS
250
250
  # advance that arrow and will call <tt>callbacks#discard_a</tt> or
251
251
  # <tt>callbacks#discard_b</tt>, depending on which arrow it advanced. If both
252
252
  # arrows point to elements that are not part of the longest common
253
- # subsequence, then #traverse_sequences will advance one of them and call the
254
- # appropriate callback, but it is not specified which it will call.
253
+ # subsequence, then #traverse_sequences will advance arrow +a+ and call the
254
+ # appropriate callback, then it will advance arrow +b+ and call the appropriate
255
+ # callback.
255
256
  #
256
257
  # The methods for <tt>callbacks#match</tt>, <tt>callbacks#discard_a</tt>, and
257
258
  # <tt>callbacks#discard_b</tt> are invoked with an event comprising the
@@ -292,37 +293,36 @@ class << Diff::LCS
292
293
  b_size = seq2.size
293
294
  ai = bj = 0
294
295
 
295
- (0..matches.size).each do |i|
296
- b_line = matches[i]
297
-
298
- ax = string ? seq1[i, 1] : seq1[i]
299
- bx = string ? seq2[bj, 1] : seq2[bj]
300
-
296
+ matches.each do |b_line|
301
297
  if b_line.nil?
302
- unless ax.nil? or (string and ax.empty?)
303
- event = Diff::LCS::ContextChange.new('-', i, ax, bj, bx)
298
+ unless seq1[ai].nil?
299
+ ax = string ? seq1[ai, 1] : seq1[ai]
300
+ bx = string ? seq2[bj, 1] : seq2[bj]
301
+
302
+ event = Diff::LCS::ContextChange.new('-', ai, ax, bj, bx)
304
303
  event = yield event if block_given?
305
304
  callbacks.discard_a(event)
306
305
  end
307
306
  else
307
+ ax = string ? seq1[ai, 1] : seq1[ai]
308
+
308
309
  loop do
309
310
  break unless bj < b_line
310
311
 
311
312
  bx = string ? seq2[bj, 1] : seq2[bj]
312
- event = Diff::LCS::ContextChange.new('+', i, ax, bj, bx)
313
+ event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
313
314
  event = yield event if block_given?
314
315
  callbacks.discard_b(event)
315
316
  bj += 1
316
317
  end
317
318
  bx = string ? seq2[bj, 1] : seq2[bj]
318
- event = Diff::LCS::ContextChange.new('=', i, ax, bj, bx)
319
+ event = Diff::LCS::ContextChange.new('=', ai, ax, bj, bx)
319
320
  event = yield event if block_given?
320
321
  callbacks.match(event)
321
322
  bj += 1
322
323
  end
323
- ai = i
324
+ ai += 1
324
325
  end
325
- ai += 1
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.
@@ -380,14 +380,14 @@ class << Diff::LCS
380
380
  ai += 1
381
381
  end
382
382
 
383
- next unless bj < b_size
384
-
385
- ax = string ? seq1[ai, 1] : seq1[ai]
386
- bx = string ? seq2[bj, 1] : seq2[bj]
387
- event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
388
- event = yield event if block_given?
389
- callbacks.discard_b(event)
390
- bj += 1
383
+ if bj < b_size
384
+ ax = string ? seq1[ai, 1] : seq1[ai]
385
+ bx = string ? seq2[bj, 1] : seq2[bj]
386
+ event = Diff::LCS::ContextChange.new('+', ai, ax, bj, bx)
387
+ event = yield event if block_given?
388
+ callbacks.discard_b(event)
389
+ bj += 1
390
+ end
391
391
  end
392
392
  end
393
393
 
@@ -0,0 +1,4 @@
1
+ 3c3
2
+ < "description": "hi"
3
+ ---
4
+ > "description": "lo"
@@ -0,0 +1,15 @@
1
+ *** spec/fixtures/old-chef 2020-06-23 23:18:20.000000000 -0400
2
+ --- spec/fixtures/new-chef 2020-06-23 23:18:20.000000000 -0400
3
+ ***************
4
+ *** 1,4 ****
5
+ {
6
+ "name": "x",
7
+ ! "description": "hi"
8
+ }
9
+
10
+ --- 1,4 ----
11
+ {
12
+ "name": "x",
13
+ ! "description": "lo"
14
+ }
15
+
@@ -0,0 +1,3 @@
1
+ 3c
2
+ "description": "lo"
3
+ .
@@ -0,0 +1,3 @@
1
+ c3
2
+ "description": "lo"
3
+ .
@@ -0,0 +1,9 @@
1
+ --- spec/fixtures/old-chef 2020-06-23 23:18:20.000000000 -0400
2
+ +++ spec/fixtures/new-chef 2020-06-23 23:18:20.000000000 -0400
3
+ @@ -1,4 +1,4 @@
4
+ {
5
+ "name": "x",
6
+ - "description": "hi"
7
+ + "description": "lo"
8
+ }
9
+
@@ -0,0 +1,7 @@
1
+ 2d1
2
+ < recipe[b::default]
3
+ 14a14,17
4
+ > recipe[o::new]
5
+ > recipe[p::new]
6
+ > recipe[q::new]
7
+ > recipe[r::new]
@@ -0,0 +1,20 @@
1
+ *** spec/fixtures/old-chef2 2020-06-30 09:43:35.000000000 -0400
2
+ --- spec/fixtures/new-chef2 2020-06-30 09:44:32.000000000 -0400
3
+ ***************
4
+ *** 1,5 ****
5
+ recipe[a::default]
6
+ - recipe[b::default]
7
+ recipe[c::default]
8
+ recipe[d::default]
9
+ recipe[e::default]
10
+ --- 1,4 ----
11
+ ***************
12
+ *** 12,14 ****
13
+ --- 11,17 ----
14
+ recipe[l::default]
15
+ recipe[m::default]
16
+ recipe[n::default]
17
+ + recipe[o::new]
18
+ + recipe[p::new]
19
+ + recipe[q::new]
20
+ + recipe[r::new]
@@ -0,0 +1,7 @@
1
+ d2
2
+ a14
3
+ recipe[o::new]
4
+ recipe[p::new]
5
+ recipe[q::new]
6
+ recipe[r::new]
7
+ .
@@ -0,0 +1,7 @@
1
+ 14a
2
+ recipe[o::new]
3
+ recipe[p::new]
4
+ recipe[q::new]
5
+ recipe[r::new]
6
+ .
7
+ 2d
@@ -0,0 +1,7 @@
1
+ d2
2
+ a14
3
+ recipe[o::new]
4
+ recipe[p::new]
5
+ recipe[q::new]
6
+ recipe[r::new]
7
+ .
@@ -0,0 +1,16 @@
1
+ --- spec/fixtures/old-chef2 2020-06-30 09:43:35.000000000 -0400
2
+ +++ spec/fixtures/new-chef2 2020-06-30 09:44:32.000000000 -0400
3
+ @@ -1,5 +1,4 @@
4
+ recipe[a::default]
5
+ -recipe[b::default]
6
+ recipe[c::default]
7
+ recipe[d::default]
8
+ recipe[e::default]
9
+ @@ -12,3 +11,7 @@
10
+ recipe[l::default]
11
+ recipe[m::default]
12
+ recipe[n::default]
13
+ +recipe[o::new]
14
+ +recipe[p::new]
15
+ +recipe[q::new]
16
+ +recipe[r::new]
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "x",
3
+ "description": "lo"
4
+ }
@@ -0,0 +1,17 @@
1
+ recipe[a::default]
2
+ recipe[c::default]
3
+ recipe[d::default]
4
+ recipe[e::default]
5
+ recipe[f::default]
6
+ recipe[g::default]
7
+ recipe[h::default]
8
+ recipe[i::default]
9
+ recipe[j::default]
10
+ recipe[k::default]
11
+ recipe[l::default]
12
+ recipe[m::default]
13
+ recipe[n::default]
14
+ recipe[o::new]
15
+ recipe[p::new]
16
+ recipe[q::new]
17
+ recipe[r::new]
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "x",
3
+ "description": "hi"
4
+ }
@@ -0,0 +1,14 @@
1
+ recipe[a::default]
2
+ recipe[b::default]
3
+ recipe[c::default]
4
+ recipe[d::default]
5
+ recipe[e::default]
6
+ recipe[f::default]
7
+ recipe[g::default]
8
+ recipe[h::default]
9
+ recipe[i::default]
10
+ recipe[j::default]
11
+ recipe[k::default]
12
+ recipe[l::default]
13
+ recipe[m::default]
14
+ recipe[n::default]
data/spec/spec_helper.rb CHANGED
@@ -28,7 +28,7 @@ if ENV['COVERAGE']
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
 
@@ -123,8 +123,8 @@ module Diff::LCS::SpecHelper
123
123
  ],
124
124
  [
125
125
  ['-', 8, 'n'],
126
- ['-', 9, 'p'],
127
126
  ['+', 9, 'r'],
127
+ ['-', 9, 'p'],
128
128
  ['+', 10, 's'],
129
129
  ['+', 11, 't']
130
130
  ]
@@ -148,10 +148,10 @@ module Diff::LCS::SpecHelper
148
148
  ],
149
149
  [
150
150
  ['-', 9, 'r'],
151
- ['-', 10, 's'],
152
151
  ['+', 8, 'n'],
153
- ['-', 11, 't'],
154
- ['+', 9, 'p']
152
+ ['-', 10, 's'],
153
+ ['+', 9, 'p'],
154
+ ['-', 11, 't']
155
155
  ]
156
156
  ]
157
157
  end
@@ -288,7 +288,6 @@ module Diff::LCS::SpecHelper
288
288
  end
289
289
 
290
290
  def finished_b(event)
291
- p 'called #finished_b'
292
291
  @done_b << [
293
292
  event.old_element, event.old_position,
294
293
  event.new_element, event.new_position
@@ -127,13 +127,11 @@ describe 'Diff::LCS.traverse_sequences' do
127
127
  end
128
128
 
129
129
  it 'has done markers differently-sized sequences' do
130
- expect(@callback_s1_s2.done_a).to eq([['p', 9, 's', 10]])
130
+ expect(@callback_s1_s2.done_a).to eq([['p', 9, 't', 11]])
131
131
  expect(@callback_s1_s2.done_b).to be_empty
132
132
 
133
- # 20110731 I don't yet understand why this particular behaviour
134
- # isn't transitive.
135
133
  expect(@callback_s2_s1.done_a).to be_empty
136
- expect(@callback_s2_s1.done_b).to be_empty
134
+ expect(@callback_s2_s1.done_b).to eq([['t', 11, 'p', 9]])
137
135
  end
138
136
  end
139
137
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff-lcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Ziegler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-01 00:00:00.000000000 Z
11
+ date: 2021-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hoe-doofus
@@ -112,28 +112,34 @@ dependencies:
112
112
  requirements:
113
113
  - - ">="
114
114
  - !ruby/object:Gem::Version
115
- version: '0'
115
+ version: 6.3.1
116
+ - - "<"
117
+ - !ruby/object:Gem::Version
118
+ version: '7'
116
119
  type: :development
117
120
  prerelease: false
118
121
  version_requirements: !ruby/object:Gem::Requirement
119
122
  requirements:
120
123
  - - ">="
121
124
  - !ruby/object:Gem::Version
122
- version: '0'
125
+ version: 6.3.1
126
+ - - "<"
127
+ - !ruby/object:Gem::Version
128
+ version: '7'
123
129
  - !ruby/object:Gem::Dependency
124
130
  name: hoe
125
131
  requirement: !ruby/object:Gem::Requirement
126
132
  requirements:
127
133
  - - "~>"
128
134
  - !ruby/object:Gem::Version
129
- version: '3.22'
135
+ version: '3.23'
130
136
  type: :development
131
137
  prerelease: false
132
138
  version_requirements: !ruby/object:Gem::Requirement
133
139
  requirements:
134
140
  - - "~>"
135
141
  - !ruby/object:Gem::Version
136
- version: '3.22'
142
+ version: '3.23'
137
143
  description: |-
138
144
  Diff::LCS computes the difference between two Enumerable sequences using the
139
145
  McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities
@@ -172,7 +178,6 @@ files:
172
178
  - Manifest.txt
173
179
  - README.rdoc
174
180
  - Rakefile
175
- - autotest/discover.rb
176
181
  - bin/htmldiff
177
182
  - bin/ldiff
178
183
  - docs/COPYING.txt
@@ -200,6 +205,21 @@ files:
200
205
  - spec/fixtures/ldiff/output.diff-e
201
206
  - spec/fixtures/ldiff/output.diff-f
202
207
  - spec/fixtures/ldiff/output.diff-u
208
+ - spec/fixtures/ldiff/output.diff.chef
209
+ - spec/fixtures/ldiff/output.diff.chef-c
210
+ - spec/fixtures/ldiff/output.diff.chef-e
211
+ - spec/fixtures/ldiff/output.diff.chef-f
212
+ - spec/fixtures/ldiff/output.diff.chef-u
213
+ - spec/fixtures/ldiff/output.diff.chef2
214
+ - spec/fixtures/ldiff/output.diff.chef2-c
215
+ - spec/fixtures/ldiff/output.diff.chef2-d
216
+ - spec/fixtures/ldiff/output.diff.chef2-e
217
+ - spec/fixtures/ldiff/output.diff.chef2-f
218
+ - spec/fixtures/ldiff/output.diff.chef2-u
219
+ - spec/fixtures/new-chef
220
+ - spec/fixtures/new-chef2
221
+ - spec/fixtures/old-chef
222
+ - spec/fixtures/old-chef2
203
223
  - spec/hunk_spec.rb
204
224
  - spec/issues_spec.rb
205
225
  - spec/lcs_spec.rb
@@ -235,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
255
  - !ruby/object:Gem::Version
236
256
  version: '0'
237
257
  requirements: []
238
- rubygems_version: 3.0.3
258
+ rubygems_version: 3.1.6
239
259
  signing_key:
240
260
  specification_version: 4
241
261
  summary: Diff::LCS computes the difference between two Enumerable sequences using
data/autotest/discover.rb DELETED
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Autotest.add_discovery { 'rspec2' }