diff-lcs 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +506 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +71 -0
- data/CONTRIBUTORS.md +48 -0
- data/{License.md → LICENCE.md} +15 -16
- data/Manifest.txt +61 -5
- data/README.md +92 -0
- data/Rakefile +19 -50
- data/SECURITY.md +41 -0
- data/docs/artistic.txt +1 -1
- data/lib/diff/lcs/change.rb +1 -1
- data/lib/diff/lcs/htmldiff.rb +2 -0
- data/lib/diff/lcs/hunk.rb +38 -22
- data/lib/diff/lcs/ldiff.rb +65 -49
- data/lib/diff/lcs/version.rb +7 -0
- data/lib/diff/lcs.rb +10 -9
- data/mise.toml +5 -0
- data/spec/fixtures/123_x +2 -0
- data/spec/fixtures/456_x +2 -0
- data/spec/fixtures/empty +0 -0
- data/spec/fixtures/file1.bin +0 -0
- data/spec/fixtures/file2.bin +0 -0
- data/spec/fixtures/four_lines +4 -0
- data/spec/fixtures/four_lines_with_missing_new_line +4 -0
- data/spec/fixtures/ldiff/diff.missing_new_line1-e +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line1-f +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line2-e +1 -0
- data/spec/fixtures/ldiff/diff.missing_new_line2-f +1 -0
- data/spec/fixtures/ldiff/error.diff.chef-e +2 -0
- data/spec/fixtures/ldiff/error.diff.chef-f +2 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line1-e +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line1-f +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line2-e +1 -0
- data/spec/fixtures/ldiff/error.diff.missing_new_line2-f +1 -0
- data/spec/fixtures/ldiff/output.diff.bin1 +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-c +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-e +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-f +0 -0
- data/spec/fixtures/ldiff/output.diff.bin1-u +0 -0
- data/spec/fixtures/ldiff/output.diff.bin2 +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-c +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-e +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-f +1 -0
- data/spec/fixtures/ldiff/output.diff.bin2-u +1 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines +5 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-c +9 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-e +6 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-f +6 -0
- data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-u +7 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty +5 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-c +9 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-e +1 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-f +1 -0
- data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-u +7 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context +4 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-c +9 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-e +3 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-f +3 -0
- data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-u +6 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1 +5 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-c +14 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-e +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-f +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line1-u +9 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2 +5 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-c +14 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-e +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-f +0 -0
- data/spec/fixtures/ldiff/output.diff.missing_new_line2-u +9 -0
- data/spec/hunk_spec.rb +1 -1
- data/spec/issues_spec.rb +32 -32
- data/spec/ldiff_spec.rb +21 -10
- data/spec/patch_spec.rb +1 -1
- data/spec/spec_helper.rb +93 -93
- metadata +86 -64
- data/Code-of-Conduct.md +0 -74
- data/Contributing.md +0 -121
- data/History.md +0 -431
- data/README.rdoc +0 -84
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
Contribution to diff-lcs is encouraged in any form: a bug report, a feature
|
4
|
+
request, or code contributions. There are a few DOs and DON'Ts for
|
5
|
+
contributions.
|
6
|
+
|
7
|
+
- DO:
|
8
|
+
|
9
|
+
- Keep the coding style that already exists for any updated Ruby code (support
|
10
|
+
or otherwise). I use [Standard Ruby][standardrb] for linting and formatting.
|
11
|
+
|
12
|
+
- Use thoughtfully-named topic branches for contributions. Rebase your commits
|
13
|
+
into logical chunks as necessary.
|
14
|
+
|
15
|
+
- Use [quality commit messages][qcm].
|
16
|
+
|
17
|
+
- Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
|
18
|
+
`CHANGELOG.md` as a separate commit from your main change. (Follow the style
|
19
|
+
in the `CHANGELOG.md` and provide a link to your PR.)
|
20
|
+
|
21
|
+
- Add or update tests as appropriate for your change. The test suite is
|
22
|
+
written in [RSpec][rspec].
|
23
|
+
|
24
|
+
- Add or update documentation as appropriate for your change. The
|
25
|
+
documentation is RDoc; diff-lcs does not use extensions that may be present
|
26
|
+
in alternative documentation generators.
|
27
|
+
|
28
|
+
- DO NOT:
|
29
|
+
|
30
|
+
- Modify `VERSION` in `lib/diff/lcs/version.rb`. When your patch is accepted
|
31
|
+
and a release is made, the version will be updated at that point.
|
32
|
+
|
33
|
+
- Modify `diff-lcs.gemspec`; it is a generated file. (You _may_ use
|
34
|
+
`rake gemspec` to regenerate it if your change involves metadata related to
|
35
|
+
gem itself).
|
36
|
+
|
37
|
+
- Modify the `Gemfile`.
|
38
|
+
|
39
|
+
## Test Dependencies
|
40
|
+
|
41
|
+
diff-lcs uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it adds
|
42
|
+
a number of rake tasks. You will mostly be interested in `rake`, which runs
|
43
|
+
tests in the same way that `rake spec` does.
|
44
|
+
|
45
|
+
To assist with the installation of the development dependencies for diff-lcs, I
|
46
|
+
have provided a Gemfile pointing to the (generated) `diff-lcs.gemspec` file.
|
47
|
+
`minitar.gemspec` file. This will permit you to use `bundle install` to install
|
48
|
+
the dependencies.
|
49
|
+
|
50
|
+
You can run tests with code coverage analysis by running `rake spec:coverage`.
|
51
|
+
|
52
|
+
## Workflow
|
53
|
+
|
54
|
+
Here's the most direct way to get your work merged into the project:
|
55
|
+
|
56
|
+
- Fork the project.
|
57
|
+
- Clone your fork (`git clone git://github.com/<username>/diff-lcs.git`).
|
58
|
+
- Create a topic branch to contain your change
|
59
|
+
(`git checkout -b my_awesome_feature`).
|
60
|
+
- Hack away, add tests. Not necessarily in that order.
|
61
|
+
- Make sure everything still passes by running `rake`.
|
62
|
+
- If necessary, rebase your commits into logical chunks, without errors.
|
63
|
+
- Push the branch up (`git push origin my_awesome_feature`).
|
64
|
+
- Create a pull request against halostatue/diff-lcs and describe what your
|
65
|
+
change does and the why you think it should be merged.
|
66
|
+
|
67
|
+
[hoe]: https://github.com/seattlerb/hoe
|
68
|
+
[qcm]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
69
|
+
[release-gem]: https://github.com/rubygems/release-gem
|
70
|
+
[rspec]: http://rspec.info/documentation/
|
71
|
+
[standardrb]: https://github.com/standardrb/standard
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Contributors
|
2
|
+
|
3
|
+
- Austin Ziegler (@halostatue) created diff-lcs.
|
4
|
+
|
5
|
+
Thanks to everyone else who has contributed to diff-lcs over the years:
|
6
|
+
|
7
|
+
- @ginriki
|
8
|
+
- @joshbronson
|
9
|
+
- @kevinmook
|
10
|
+
- @mckaz
|
11
|
+
- Akinori Musha
|
12
|
+
- Artem Ignatyev
|
13
|
+
- Brandon Fish
|
14
|
+
- Baptiste Courtois (@annih)
|
15
|
+
- Camille Drapier
|
16
|
+
- Cédric Boutillier
|
17
|
+
- Gregg Kellogg
|
18
|
+
- Jagdeep Singh
|
19
|
+
- Jason Gladish
|
20
|
+
- Jon Rowe
|
21
|
+
- Josef Strzibny
|
22
|
+
- Josep (@apuratepp)
|
23
|
+
- Josh Bronson
|
24
|
+
- Jun Aruga
|
25
|
+
- Justin Steele
|
26
|
+
- Kenichi Kamiya
|
27
|
+
- Kensuke Nagae
|
28
|
+
- Kevin Ansfield
|
29
|
+
- Koichi Ito
|
30
|
+
- Mark Friedgan
|
31
|
+
- Masato Nakamura
|
32
|
+
- Mark Young
|
33
|
+
- Michael Granger
|
34
|
+
- Myron Marston
|
35
|
+
- Nicolas Leger
|
36
|
+
- Oleg Orlov
|
37
|
+
- Patrick Linnane
|
38
|
+
- Paul Kunysch
|
39
|
+
- Pete Higgins
|
40
|
+
- Peter Goldstein
|
41
|
+
- Peter Wagenet
|
42
|
+
- Philippe Lafoucrière
|
43
|
+
- Ryan Lovelett
|
44
|
+
- Scott Steele
|
45
|
+
- Simon Courtois
|
46
|
+
- Tien (@tiendo1011)
|
47
|
+
- Tomas Jura
|
48
|
+
- Vít Ondruch
|
data/{License.md → LICENCE.md}
RENAMED
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
1
|
+
# Licence
|
2
2
|
|
3
3
|
This software is available under three licenses: the GNU GPL version 2 (or at
|
4
4
|
your option, a later version), the Perl Artistic license, or the MIT license.
|
5
5
|
Note that my preference for licensing is the MIT license, but Algorithm::Diff
|
6
|
-
was dually originally licensed with the Perl Artistic and the GNU GPL ("the
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
was dually originally licensed with the Perl Artistic and the GNU GPL ("the same
|
7
|
+
terms as Perl itself") and given that the Ruby implementation originally hewed
|
8
|
+
pretty closely to the Perl version, I must maintain the additional licensing
|
9
|
+
terms.
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
- Copyright 2004–2025 Austin Ziegler and contributors.
|
12
|
+
- Adapted from Algorithm::Diff (Perl) by Ned Konz and a Smalltalk version by
|
13
13
|
Mario I. Wolczko.
|
14
14
|
|
15
15
|
## MIT License
|
@@ -17,20 +17,19 @@ licensing terms.
|
|
17
17
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
18
18
|
this software and associated documentation files (the "Software"), to deal in
|
19
19
|
the Software without restriction, including without limitation the rights to
|
20
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
21
|
-
|
22
|
-
|
20
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
21
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
22
|
+
subject to the following conditions:
|
23
23
|
|
24
24
|
The above copyright notice and this permission notice shall be included in all
|
25
25
|
copies or substantial portions of the Software.
|
26
26
|
|
27
27
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
28
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
SOFTWARE.
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
29
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
30
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
31
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
32
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
34
33
|
|
35
34
|
## Perl Artistic License
|
36
35
|
|
data/Manifest.txt
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
.rspec
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
CHANGELOG.md
|
3
|
+
CODE_OF_CONDUCT.md
|
4
|
+
CONTRIBUTING.md
|
5
|
+
CONTRIBUTORS.md
|
6
|
+
LICENCE.md
|
6
7
|
Manifest.txt
|
7
|
-
README.
|
8
|
+
README.md
|
8
9
|
Rakefile
|
10
|
+
SECURITY.md
|
9
11
|
bin/htmldiff
|
10
12
|
bin/ldiff
|
11
13
|
docs/COPYING.txt
|
@@ -22,17 +24,46 @@ lib/diff/lcs/hunk.rb
|
|
22
24
|
lib/diff/lcs/internals.rb
|
23
25
|
lib/diff/lcs/ldiff.rb
|
24
26
|
lib/diff/lcs/string.rb
|
27
|
+
lib/diff/lcs/version.rb
|
28
|
+
mise.toml
|
25
29
|
spec/change_spec.rb
|
26
30
|
spec/diff_spec.rb
|
31
|
+
spec/fixtures/123_x
|
32
|
+
spec/fixtures/456_x
|
27
33
|
spec/fixtures/aX
|
28
34
|
spec/fixtures/bXaX
|
29
35
|
spec/fixtures/ds1.csv
|
30
36
|
spec/fixtures/ds2.csv
|
37
|
+
spec/fixtures/empty
|
38
|
+
spec/fixtures/file1.bin
|
39
|
+
spec/fixtures/file2.bin
|
40
|
+
spec/fixtures/four_lines
|
41
|
+
spec/fixtures/four_lines_with_missing_new_line
|
42
|
+
spec/fixtures/ldiff/diff.missing_new_line1-e
|
43
|
+
spec/fixtures/ldiff/diff.missing_new_line1-f
|
44
|
+
spec/fixtures/ldiff/diff.missing_new_line2-e
|
45
|
+
spec/fixtures/ldiff/diff.missing_new_line2-f
|
46
|
+
spec/fixtures/ldiff/error.diff.chef-e
|
47
|
+
spec/fixtures/ldiff/error.diff.chef-f
|
48
|
+
spec/fixtures/ldiff/error.diff.missing_new_line1-e
|
49
|
+
spec/fixtures/ldiff/error.diff.missing_new_line1-f
|
50
|
+
spec/fixtures/ldiff/error.diff.missing_new_line2-e
|
51
|
+
spec/fixtures/ldiff/error.diff.missing_new_line2-f
|
31
52
|
spec/fixtures/ldiff/output.diff
|
32
53
|
spec/fixtures/ldiff/output.diff-c
|
33
54
|
spec/fixtures/ldiff/output.diff-e
|
34
55
|
spec/fixtures/ldiff/output.diff-f
|
35
56
|
spec/fixtures/ldiff/output.diff-u
|
57
|
+
spec/fixtures/ldiff/output.diff.bin1
|
58
|
+
spec/fixtures/ldiff/output.diff.bin1-c
|
59
|
+
spec/fixtures/ldiff/output.diff.bin1-e
|
60
|
+
spec/fixtures/ldiff/output.diff.bin1-f
|
61
|
+
spec/fixtures/ldiff/output.diff.bin1-u
|
62
|
+
spec/fixtures/ldiff/output.diff.bin2
|
63
|
+
spec/fixtures/ldiff/output.diff.bin2-c
|
64
|
+
spec/fixtures/ldiff/output.diff.bin2-e
|
65
|
+
spec/fixtures/ldiff/output.diff.bin2-f
|
66
|
+
spec/fixtures/ldiff/output.diff.bin2-u
|
36
67
|
spec/fixtures/ldiff/output.diff.chef
|
37
68
|
spec/fixtures/ldiff/output.diff.chef-c
|
38
69
|
spec/fixtures/ldiff/output.diff.chef-e
|
@@ -44,6 +75,31 @@ spec/fixtures/ldiff/output.diff.chef2-d
|
|
44
75
|
spec/fixtures/ldiff/output.diff.chef2-e
|
45
76
|
spec/fixtures/ldiff/output.diff.chef2-f
|
46
77
|
spec/fixtures/ldiff/output.diff.chef2-u
|
78
|
+
spec/fixtures/ldiff/output.diff.empty.vs.four_lines
|
79
|
+
spec/fixtures/ldiff/output.diff.empty.vs.four_lines-c
|
80
|
+
spec/fixtures/ldiff/output.diff.empty.vs.four_lines-e
|
81
|
+
spec/fixtures/ldiff/output.diff.empty.vs.four_lines-f
|
82
|
+
spec/fixtures/ldiff/output.diff.empty.vs.four_lines-u
|
83
|
+
spec/fixtures/ldiff/output.diff.four_lines.vs.empty
|
84
|
+
spec/fixtures/ldiff/output.diff.four_lines.vs.empty-c
|
85
|
+
spec/fixtures/ldiff/output.diff.four_lines.vs.empty-e
|
86
|
+
spec/fixtures/ldiff/output.diff.four_lines.vs.empty-f
|
87
|
+
spec/fixtures/ldiff/output.diff.four_lines.vs.empty-u
|
88
|
+
spec/fixtures/ldiff/output.diff.issue95_trailing_context
|
89
|
+
spec/fixtures/ldiff/output.diff.issue95_trailing_context-c
|
90
|
+
spec/fixtures/ldiff/output.diff.issue95_trailing_context-e
|
91
|
+
spec/fixtures/ldiff/output.diff.issue95_trailing_context-f
|
92
|
+
spec/fixtures/ldiff/output.diff.issue95_trailing_context-u
|
93
|
+
spec/fixtures/ldiff/output.diff.missing_new_line1
|
94
|
+
spec/fixtures/ldiff/output.diff.missing_new_line1-c
|
95
|
+
spec/fixtures/ldiff/output.diff.missing_new_line1-e
|
96
|
+
spec/fixtures/ldiff/output.diff.missing_new_line1-f
|
97
|
+
spec/fixtures/ldiff/output.diff.missing_new_line1-u
|
98
|
+
spec/fixtures/ldiff/output.diff.missing_new_line2
|
99
|
+
spec/fixtures/ldiff/output.diff.missing_new_line2-c
|
100
|
+
spec/fixtures/ldiff/output.diff.missing_new_line2-e
|
101
|
+
spec/fixtures/ldiff/output.diff.missing_new_line2-f
|
102
|
+
spec/fixtures/ldiff/output.diff.missing_new_line2-u
|
47
103
|
spec/fixtures/new-chef
|
48
104
|
spec/fixtures/new-chef2
|
49
105
|
spec/fixtures/old-chef
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Diff::LCS
|
2
|
+
|
3
|
+
- home :: https://github.com/halostatue/diff-lcs
|
4
|
+
- changelog :: https://github.com/halostatue/diff-lcs/blob/main/CHANGELOG.md
|
5
|
+
- code :: https://github.com/halostatue/diff-lcs
|
6
|
+
- bugs :: https://github.com/halostatue/diff-lcs/issues
|
7
|
+
- rdoc :: http://rubydoc.info/github/halostatue/diff-lcs
|
8
|
+
|
9
|
+
<a href="https://github.com/halostatue/diff-lcs/actions">
|
10
|
+
<img src="https://github.com/halostatue/diff-lcs/workflows/CI/badge.svg" />
|
11
|
+
</a>
|
12
|
+
|
13
|
+
## Description
|
14
|
+
|
15
|
+
Diff::LCS computes the difference between two Enumerable sequences using the
|
16
|
+
McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities
|
17
|
+
to create a simple HTML diff output format and a standard diff-like tool.
|
18
|
+
|
19
|
+
This is release 1.4.3, providing a simple extension that allows for
|
20
|
+
Diff::LCS::Change objects to be treated implicitly as arrays and fixes a number
|
21
|
+
of formatting issues.
|
22
|
+
|
23
|
+
Ruby versions below 2.5 are soft-deprecated, which means that older versions are
|
24
|
+
no longer part of the CI test suite. If any changes have been introduced that
|
25
|
+
break those versions, bug reports and patches will be accepted, but it will be
|
26
|
+
up to the reporter to verify any fixes prior to release. The next major release
|
27
|
+
will completely break compatibility.
|
28
|
+
|
29
|
+
## Synopsis
|
30
|
+
|
31
|
+
Using this module is quite simple. By default, Diff::LCS does not extend objects
|
32
|
+
with the Diff::LCS interface, but will be called as if it were a function:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'diff/lcs'
|
36
|
+
|
37
|
+
seq1 = %w(a b c e h j l m n p)
|
38
|
+
seq2 = %w(b c d e f j k l m r s t)
|
39
|
+
|
40
|
+
lcs = Diff::LCS.LCS(seq1, seq2)
|
41
|
+
diffs = Diff::LCS.diff(seq1, seq2)
|
42
|
+
sdiff = Diff::LCS.sdiff(seq1, seq2)
|
43
|
+
seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj)
|
44
|
+
bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj)
|
45
|
+
seq2 == Diff::LCS.patch!(seq1, diffs)
|
46
|
+
seq1 == Diff::LCS.unpatch!(seq2, diffs)
|
47
|
+
seq2 == Diff::LCS.patch!(seq1, sdiff)
|
48
|
+
seq1 == Diff::LCS.unpatch!(seq2, sdiff)
|
49
|
+
```
|
50
|
+
|
51
|
+
Objects can be extended with Diff::LCS:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
seq1.extend(Diff::LCS)
|
55
|
+
lcs = seq1.lcs(seq2)
|
56
|
+
diffs = seq1.diff(seq2)
|
57
|
+
sdiff = seq1.sdiff(seq2)
|
58
|
+
seq = seq1.traverse_sequences(seq2, callback_obj)
|
59
|
+
bal = seq1.traverse_balanced(seq2, callback_obj)
|
60
|
+
seq2 == seq1.patch!(diffs)
|
61
|
+
seq1 == seq2.unpatch!(diffs)
|
62
|
+
seq2 == seq1.patch!(sdiff)
|
63
|
+
seq1 == seq2.unpatch!(sdiff)
|
64
|
+
```
|
65
|
+
|
66
|
+
By requiring 'diff/lcs/array' or 'diff/lcs/string', Array or String will be
|
67
|
+
extended for use this way.
|
68
|
+
|
69
|
+
Note that Diff::LCS requires a sequenced enumerable container, which means that
|
70
|
+
the order of enumeration is both predictable and consistent for the same set of
|
71
|
+
data. While it is theoretically possible to generate a diff for an unordered
|
72
|
+
hash, it will only be meaningful if the enumeration of the hashes is consistent.
|
73
|
+
In general, this will mean that containers that behave like String or Array will
|
74
|
+
perform best.
|
75
|
+
|
76
|
+
## History
|
77
|
+
|
78
|
+
Diff::LCS is a port of Perl's Algorithm::Diff that uses the McIlroy-Hunt longest
|
79
|
+
common subsequence (LCS) algorithm to compute intelligent differences between
|
80
|
+
two sequenced enumerable containers. The implementation is based on Mario I.
|
81
|
+
Wolczko's [Smalltalk version 1.2][smalltalk] (1993) and Ned Konz's Perl version
|
82
|
+
[Algorithm::Diff 1.15][perl]. `Diff::LCS#sdiff` and
|
83
|
+
`Diff::LCS#traverse_balanced` were originally written for the Perl version by
|
84
|
+
Mike Schilli.
|
85
|
+
|
86
|
+
The algorithm is described in <em>A Fast Algorithm for Computing Longest Common
|
87
|
+
Subsequences</em>, CACM, vol.20, no.5, pp.350-353, May 1977, with a few minor
|
88
|
+
improvements to improve the speed. A simplified description of the algorithm,
|
89
|
+
originally written for the Perl version, was written by Mark-Jason Dominus.
|
90
|
+
|
91
|
+
[smalltalk]: ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st
|
92
|
+
[perl]: http://search.cpan.org/~nedkonz/Algorithm-Diff-1.15/
|
data/Rakefile
CHANGED
@@ -1,49 +1,16 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "rubygems"
|
4
2
|
require "rspec"
|
5
3
|
require "rspec/core/rake_task"
|
6
4
|
require "hoe"
|
5
|
+
require "rake/clean"
|
7
6
|
|
8
|
-
|
9
|
-
|
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)
|
7
|
+
Hoe.plugin :halostatue
|
8
|
+
Hoe.plugin :rubygems
|
29
9
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
43
|
-
Hoe.plugin :bundler
|
44
|
-
Hoe.plugin :doofus
|
45
|
-
Hoe.plugin :gemspec2
|
46
|
-
Hoe.plugin :git
|
10
|
+
Hoe.plugins.delete :debug
|
11
|
+
Hoe.plugins.delete :newb
|
12
|
+
Hoe.plugins.delete :publish
|
13
|
+
Hoe.plugins.delete :signing
|
47
14
|
|
48
15
|
if RUBY_VERSION < "1.9"
|
49
16
|
class Array # :nodoc:
|
@@ -70,18 +37,20 @@ end
|
|
70
37
|
_spec = Hoe.spec "diff-lcs" do
|
71
38
|
developer("Austin Ziegler", "halostatue@gmail.com")
|
72
39
|
|
40
|
+
self.trusted_release = ENV["rubygems_release_gem"] == "true"
|
41
|
+
|
73
42
|
require_ruby_version ">= 1.8"
|
74
43
|
|
75
|
-
self.history_file = "
|
76
|
-
self.readme_file = "README.
|
77
|
-
self.licenses = ["MIT", "Artistic-
|
44
|
+
self.history_file = "CHANGELOG.md"
|
45
|
+
self.readme_file = "README.md"
|
46
|
+
self.licenses = ["MIT", "Artistic-1.0-Perl", "GPL-2.0-or-later"]
|
78
47
|
|
79
|
-
spec_extras[:metadata] = ->(val) {
|
48
|
+
spec_extras[:metadata] = ->(val) {
|
49
|
+
val["rubygems_mfa_required"] = "true"
|
50
|
+
}
|
80
51
|
|
81
|
-
extra_dev_deps << ["hoe", "
|
82
|
-
extra_dev_deps << ["hoe-
|
83
|
-
extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
|
84
|
-
extra_dev_deps << ["hoe-git2", "~> 1.7"]
|
52
|
+
extra_dev_deps << ["hoe", "~> 4.0"]
|
53
|
+
extra_dev_deps << ["hoe-halostatue", "~> 2.0"]
|
85
54
|
extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
|
86
55
|
extra_dev_deps << ["rspec", ">= 2.0", "< 4"]
|
87
56
|
extra_dev_deps << ["rake", ">= 10.0", "< 14"]
|
@@ -101,11 +70,11 @@ task :default => :spec unless Rake::Task["default"].prereqs.include?("spec")
|
|
101
70
|
task :test => :spec unless Rake::Task["test"].prereqs.include?("spec")
|
102
71
|
# standard:enable Style/HashSyntax
|
103
72
|
|
104
|
-
if RUBY_VERSION >= "
|
73
|
+
if RUBY_VERSION >= "3.0" && RUBY_ENGINE == "ruby"
|
105
74
|
namespace :spec do
|
106
75
|
desc "Runs test coverage. Only works Ruby 2.0+ and assumes 'simplecov' is installed."
|
107
76
|
task :coverage do
|
108
|
-
ENV["COVERAGE"] = "
|
77
|
+
ENV["COVERAGE"] = "true"
|
109
78
|
Rake::Task["spec"].execute
|
110
79
|
end
|
111
80
|
end
|
data/SECURITY.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# diff-lcs Security
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
Security reports are accepted for the most recent major release and the previous
|
6
|
+
version for a limited time after the initial major release version. After a
|
7
|
+
major release, the previous version will receive full support for six months and
|
8
|
+
security support for an additional six months (for a total of twelve months).
|
9
|
+
|
10
|
+
Because diff-lcs 1.x supports a wide range of Ruby versions, security reports
|
11
|
+
will only be accepted when they can be demonstrated on Ruby 3.1 or higher.
|
12
|
+
|
13
|
+
> [!information]
|
14
|
+
>
|
15
|
+
> There will be a diff-lcs 2.0 released in 2025 which narrows support to modern
|
16
|
+
> versions of Ruby only.
|
17
|
+
>
|
18
|
+
> | Release Date | Support Ends | Security Support Ends |
|
19
|
+
> | ------------ | ------------ | --------------------- |
|
20
|
+
> | 2025 | +6 months | +12 months |
|
21
|
+
>
|
22
|
+
> If the 2.0.0 release happens on 2025-07-01, regular support for diff-lcs 1.x
|
23
|
+
> will end on 2026-12-31 and security support for diff-lcs 1.x will end on
|
24
|
+
> 2026-06-30.
|
25
|
+
|
26
|
+
## Reporting a Vulnerability
|
27
|
+
|
28
|
+
By preference, use the [Tidelift security contact][tidelift]. Tidelift will
|
29
|
+
coordinate the fix and disclosure.
|
30
|
+
|
31
|
+
Alternatively, Send an email to [diff-lcs@halostatue.ca][email] with the text
|
32
|
+
`Diff::LCS` in the subject. Emails sent to this address should be encrypted
|
33
|
+
using [age][age] with the following public key:
|
34
|
+
|
35
|
+
```
|
36
|
+
age1fc6ngxmn02m62fej5cl30lrvwmxn4k3q2atqu53aatekmnqfwumqj4g93w
|
37
|
+
```
|
38
|
+
|
39
|
+
[tidelift]: https://tidelift.com/security
|
40
|
+
[email]: mailto:diff-lcs@halostatue.ca
|
41
|
+
[age]: https://github.com/FiloSottile/age
|
data/docs/artistic.txt
CHANGED
@@ -122,6 +122,6 @@ products derived from this software without specific prior written permission.
|
|
122
122
|
|
123
123
|
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
124
124
|
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
125
|
-
WARRANTIES OF
|
125
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
126
126
|
|
127
127
|
The End
|
data/lib/diff/lcs/change.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# addition of an element from either the old or the new sequenced
|
5
5
|
# enumerable.
|
6
6
|
class Diff::LCS::Change
|
7
|
-
IntClass = 1.class # Fixnum is deprecated in Ruby 2.4 #
|
7
|
+
IntClass = 1.class # Fixnum is deprecated in Ruby 2.4 # standard:disable Naming/ConstantName
|
8
8
|
|
9
9
|
# The only actions valid for changes are '+' (add), '-' (delete), '='
|
10
10
|
# (no change), '!' (changed), '<' (tail changes from first sequence), or
|
data/lib/diff/lcs/htmldiff.rb
CHANGED
@@ -5,7 +5,9 @@ require "cgi"
|
|
5
5
|
# Produce a simple HTML diff view.
|
6
6
|
class Diff::LCS::HTMLDiff
|
7
7
|
class << self
|
8
|
+
# standard:disable ThreadSafety/ClassAndModuleAttributes
|
8
9
|
attr_accessor :can_expand_tabs # :nodoc:
|
10
|
+
# standard:enable ThreadSafety/ClassAndModuleAttributes
|
9
11
|
end
|
10
12
|
self.can_expand_tabs = true
|
11
13
|
|