diff-lcs 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +491 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +74 -0
- data/CONTRIBUTORS.md +48 -0
- data/Contributing.md +45 -90
- data/{License.md → LICENCE.md} +6 -4
- data/Manifest.txt +7 -4
- data/README.md +92 -0
- data/Rakefile +43 -66
- data/SECURITY.md +41 -0
- data/bin/htmldiff +4 -4
- data/docs/artistic.txt +1 -1
- data/lib/diff/lcs/array.rb +1 -1
- data/lib/diff/lcs/backports.rb +2 -2
- data/lib/diff/lcs/block.rb +4 -4
- data/lib/diff/lcs/callbacks.rb +9 -7
- data/lib/diff/lcs/change.rb +20 -20
- data/lib/diff/lcs/htmldiff.rb +26 -16
- data/lib/diff/lcs/hunk.rb +66 -45
- data/lib/diff/lcs/internals.rb +17 -17
- data/lib/diff/lcs/ldiff.rb +86 -74
- data/lib/diff/lcs.rb +66 -63
- data/lib/diff-lcs.rb +1 -1
- data/spec/change_spec.rb +50 -50
- data/spec/diff_spec.rb +14 -14
- data/spec/hunk_spec.rb +20 -20
- data/spec/issues_spec.rb +76 -70
- data/spec/lcs_spec.rb +11 -11
- data/spec/ldiff_spec.rb +30 -17
- data/spec/patch_spec.rb +84 -84
- data/spec/sdiff_spec.rb +111 -109
- data/spec/spec_helper.rb +76 -74
- data/spec/traverse_balanced_spec.rb +191 -189
- data/spec/traverse_sequences_spec.rb +31 -31
- metadata +55 -30
- data/Code-of-Conduct.md +0 -74
- data/History.md +0 -400
- data/README.rdoc +0 -84
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,74 @@
|
|
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
|
+
|
6
|
+
- DO:
|
7
|
+
|
8
|
+
- Keep the coding style that already exists for any updated Ruby code (support
|
9
|
+
or otherwise). I use [Standard Ruby][standardrb] for linting and formatting.
|
10
|
+
|
11
|
+
- Use thoughtfully-named topic branches for contributions. Rebase your commits
|
12
|
+
into logical chunks as necessary.
|
13
|
+
|
14
|
+
- Use [quality commit messages][qcm].
|
15
|
+
|
16
|
+
- Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
|
17
|
+
`CHANGELOG.md` as a separate commit from your main change. (Follow the style
|
18
|
+
in the `CHANGELOG.md` and provide a link to your PR.)
|
19
|
+
|
20
|
+
- Add or update tests, written in [RSpec][rspec], as appropriate.
|
21
|
+
|
22
|
+
- Add or update documentation, as appropriate.
|
23
|
+
|
24
|
+
- DO NOT:
|
25
|
+
|
26
|
+
- Modify `VERSION` in `lib/diff/lcs.rb`. When your patch is accepted and a
|
27
|
+
release is made, the version will be updated at that point.
|
28
|
+
|
29
|
+
- Modify `diff-lcs.gemspect`; it is a generated file. (You _may_ use
|
30
|
+
`rake gemspec` to regenerate it if your change involves metadata related to
|
31
|
+
gem itself).
|
32
|
+
|
33
|
+
- Modify the `Gemfile`.
|
34
|
+
|
35
|
+
## Test Dependencies
|
36
|
+
|
37
|
+
diff-lcs uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it adds
|
38
|
+
a number of rake tasks. You will mostly be interested in `rake`, which runs
|
39
|
+
tests in the same way that `rake spec` does.
|
40
|
+
|
41
|
+
To assist with the installation of the development dependencies for diff-lcs, I
|
42
|
+
have provided a Gemfile pointing to the (generated) `diff-lcs.gemspec` file.
|
43
|
+
`minitar.gemspec` file. This will permit you to use `bundle install` to install
|
44
|
+
the dependencies.
|
45
|
+
|
46
|
+
You can run tests with code coverage analysis by running `rake spec:coverage`.
|
47
|
+
|
48
|
+
## Workflow
|
49
|
+
|
50
|
+
Here's the most direct way to get your work merged into the project:
|
51
|
+
|
52
|
+
- Fork the project.
|
53
|
+
- Clone your fork (`git clone git://github.com/<username>/diff-lcs.git`).
|
54
|
+
- Create a topic branch to contain your change
|
55
|
+
(`git checkout -b my_awesome_feature`).
|
56
|
+
- Hack away, add tests. Not necessarily in that order.
|
57
|
+
- Make sure everything still passes by running `rake`.
|
58
|
+
- If necessary, rebase your commits into logical chunks, without errors.
|
59
|
+
- Push the branch up (`git push origin my_awesome_feature`).
|
60
|
+
- Create a pull request against halostatue/diff-lcs and describe what your
|
61
|
+
change does and the why you think it should be merged.
|
62
|
+
|
63
|
+
### Help Wanted
|
64
|
+
|
65
|
+
I want to automated the releases. I am **not** switching from Hoe for release
|
66
|
+
management, so the use of [rubygems/release-gem][release-gem] requires some care
|
67
|
+
(perhaps by exporting `VERSION=$(rake version)` to the job), but assistance in
|
68
|
+
getting this action going for an automated release would be greatly appreciated.
|
69
|
+
|
70
|
+
[hoe]: https://github.com/seattlerb/hoe
|
71
|
+
[qcm]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
72
|
+
[release-gem]: https://github.com/rubygems/release-gem
|
73
|
+
[rspec]: http://rspec.info/documentation/
|
74
|
+
[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/Contributing.md
CHANGED
@@ -1,69 +1,58 @@
|
|
1
|
-
|
1
|
+
# Contributing
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
especially <del>welcome</del>encouraged. Because Diff::LCS is a complex
|
6
|
-
codebase, there are a few guidelines:
|
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
|
7
5
|
|
8
|
-
-
|
9
|
-
written with [RSpec][].
|
10
|
-
- Match my coding style.
|
11
|
-
- Use a thoughtfully-named topic branch that contains your change. Rebase
|
12
|
-
your commits into logical chunks as necessary.
|
13
|
-
- Use [quality commit messages][].
|
14
|
-
- Do not change the version number; when your patch is accepted and a release
|
15
|
-
is made, the version will be updated at that point.
|
16
|
-
- Submit a GitHub pull request with your changes.
|
17
|
-
- New or changed behaviours require appropriate documentation.
|
6
|
+
- DO:
|
18
7
|
|
19
|
-
|
8
|
+
- Keep the coding style that already exists for any updated Ruby code (support
|
9
|
+
or otherwise). I use [Standard Ruby][standardrb] for linting and formatting.
|
20
10
|
|
21
|
-
|
22
|
-
|
11
|
+
- Use thoughtfully-named topic branches for contributions. Rebase your commits
|
12
|
+
into logical chunks as necessary.
|
23
13
|
|
24
|
-
|
25
|
-
$ rake
|
26
|
-
```
|
14
|
+
- Use [quality commit messages][qcm].
|
27
15
|
|
28
|
-
|
16
|
+
- Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
|
17
|
+
`CHANGELOG.md` as a separate commit from your main change. (Follow the style
|
18
|
+
in the `CHANGELOG.md` and provide a link to your PR.)
|
29
19
|
|
30
|
-
|
31
|
-
$ rake spec
|
32
|
-
```
|
20
|
+
- Add or update tests, written in [RSpec][rspec], as appropriate.
|
33
21
|
|
34
|
-
|
22
|
+
- Add or update documentation, as appropriate.
|
35
23
|
|
36
|
-
|
37
|
-
provided a Gemfile pointing to the (generated) `diff-lcs.gemspec` file. This
|
38
|
-
will permit you to do:
|
24
|
+
- DO NOT:
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
```
|
26
|
+
- Modify `VERSION` in `lib/diff/lcs.rb`. When your patch is accepted and a
|
27
|
+
release is made, the version will be updated at that point.
|
43
28
|
|
44
|
-
|
45
|
-
|
29
|
+
- Modify `diff-lcs.gemspect`; it is a generated file. (You _may_ use
|
30
|
+
`rake gemspec` to regenerate it if your change involves metadata related to
|
31
|
+
gem itself).
|
46
32
|
|
47
|
-
|
48
|
-
$ rake newb
|
49
|
-
```
|
33
|
+
- Modify the `Gemfile`.
|
50
34
|
|
51
|
-
|
52
|
-
generate the RDoc.
|
35
|
+
## Test Dependencies
|
53
36
|
|
54
|
-
|
37
|
+
diff-lcs uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it adds
|
38
|
+
a number of rake tasks. You will mostly be interested in `rake`, which runs
|
39
|
+
tests in the same way that `rake spec` does.
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
41
|
+
To assist with the installation of the development dependencies for diff-lcs, I
|
42
|
+
have provided a Gemfile pointing to the (generated) `diff-lcs.gemspec` file.
|
43
|
+
`minitar.gemspec` file. This will permit you to use `bundle install` to install
|
44
|
+
the dependencies.
|
59
45
|
|
60
|
-
|
46
|
+
You can run tests with code coverage analysis by running `rake spec:coverage`.
|
47
|
+
|
48
|
+
## Workflow
|
61
49
|
|
62
50
|
Here's the most direct way to get your work merged into the project:
|
63
51
|
|
64
52
|
- Fork the project.
|
65
|
-
- Clone
|
66
|
-
- Create a topic branch to contain your change
|
53
|
+
- Clone your fork (`git clone git://github.com/<username>/diff-lcs.git`).
|
54
|
+
- Create a topic branch to contain your change
|
55
|
+
(`git checkout -b my_awesome_feature`).
|
67
56
|
- Hack away, add tests. Not necessarily in that order.
|
68
57
|
- Make sure everything still passes by running `rake`.
|
69
58
|
- If necessary, rebase your commits into logical chunks, without errors.
|
@@ -71,49 +60,15 @@ Here's the most direct way to get your work merged into the project:
|
|
71
60
|
- Create a pull request against halostatue/diff-lcs and describe what your
|
72
61
|
change does and the why you think it should be merged.
|
73
62
|
|
74
|
-
###
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
- @ginriki
|
81
|
-
- @joshbronson
|
82
|
-
- @kevinmook
|
83
|
-
- @mckaz
|
84
|
-
- Akinori Musha
|
85
|
-
- Artem Ignatyev
|
86
|
-
- Brandon Fish
|
87
|
-
- Camille Drapier
|
88
|
-
- Cédric Boutillier
|
89
|
-
- Gregg Kellogg
|
90
|
-
- Jagdeep Singh
|
91
|
-
- Jason Gladish
|
92
|
-
- Jon Rowe
|
93
|
-
- Josef Strzibny
|
94
|
-
- Josep (@apuratepp)
|
95
|
-
- Josh Bronson
|
96
|
-
- Jun Aruga
|
97
|
-
- Kenichi Kamiya
|
98
|
-
- Kensuke Nagae
|
99
|
-
- Kevin Ansfield
|
100
|
-
- Koichi Ito
|
101
|
-
- Mark Friedgan
|
102
|
-
- Michael Granger
|
103
|
-
- Myron Marston
|
104
|
-
- Nicolas Leger
|
105
|
-
- Oleg Orlov
|
106
|
-
- Paul Kunysch
|
107
|
-
- Pete Higgins
|
108
|
-
- Peter Wagenet
|
109
|
-
- Philippe Lafoucrière
|
110
|
-
- Ryan Lovelett
|
111
|
-
- Scott Steele
|
112
|
-
- Simon Courtois
|
113
|
-
- Tien (@tiendo1011)
|
114
|
-
- Tomas Jura
|
115
|
-
- Vít Ondruch
|
63
|
+
### Help Wanted
|
64
|
+
|
65
|
+
I want to automated the releases. I am **not** switching from Hoe for release
|
66
|
+
management, so the use of [rubygems/release-gem][release-gem] requires some care
|
67
|
+
(perhaps by exporting `VERSION=$(rake version)` to the job), but assistance in
|
68
|
+
getting this action going for an automated release would be greatly appreciated.
|
116
69
|
|
117
|
-
[rspec]: http://rspec.info/documentation/
|
118
|
-
[quality commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
119
70
|
[hoe]: https://github.com/seattlerb/hoe
|
71
|
+
[qcm]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
72
|
+
[release-gem]: https://github.com/rubygems/release-gem
|
73
|
+
[rspec]: http://rspec.info/documentation/
|
74
|
+
[standardrb]: https://github.com/standardrb/standard
|
data/{License.md → LICENCE.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# License
|
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.
|
@@ -12,7 +12,7 @@ licensing terms.
|
|
12
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
|
16
16
|
|
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
|
@@ -32,8 +32,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
32
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
33
33
|
SOFTWARE.
|
34
34
|
|
35
|
-
|
35
|
+
## Perl Artistic License
|
36
|
+
|
36
37
|
See the file docs/artistic.txt in the main distribution.
|
37
38
|
|
38
|
-
|
39
|
+
## GNU GPL version 2
|
40
|
+
|
39
41
|
See the file docs/COPYING.txt in the main distribution.
|
data/Manifest.txt
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
.rspec
|
2
|
-
|
2
|
+
CHANGELOG.md
|
3
|
+
CODE_OF_CONDUCT.md
|
4
|
+
CONTRIBUTING.md
|
5
|
+
CONTRIBUTORS.md
|
3
6
|
Contributing.md
|
4
|
-
|
5
|
-
License.md
|
7
|
+
LICENCE.md
|
6
8
|
Manifest.txt
|
7
|
-
README.
|
9
|
+
README.md
|
8
10
|
Rakefile
|
11
|
+
SECURITY.md
|
9
12
|
bin/htmldiff
|
10
13
|
bin/ldiff
|
11
14
|
docs/COPYING.txt
|
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,110 +1,86 @@
|
|
1
|
-
|
1
|
+
require "rubygems"
|
2
|
+
require "rspec"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "hoe"
|
5
|
+
require "rake/clean"
|
2
6
|
|
3
|
-
|
4
|
-
require 'rspec'
|
5
|
-
require 'rspec/core/rake_task'
|
6
|
-
require 'hoe'
|
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
|
-
|
43
|
-
Hoe.plugin :bundler
|
7
|
+
Hoe.plugin :cov
|
44
8
|
Hoe.plugin :doofus
|
45
9
|
Hoe.plugin :gemspec2
|
46
|
-
Hoe.plugin :
|
10
|
+
Hoe.plugin :git2
|
11
|
+
Hoe.plugin :rubygems
|
47
12
|
|
48
|
-
if RUBY_VERSION <
|
49
|
-
class Array
|
13
|
+
if RUBY_VERSION < "1.9"
|
14
|
+
class Array # :nodoc:
|
50
15
|
def to_h
|
51
16
|
Hash[*flatten(1)]
|
52
17
|
end
|
53
18
|
end
|
54
19
|
|
55
|
-
class Gem::Specification
|
56
|
-
def metadata=(*)
|
20
|
+
class Gem::Specification # :nodoc:
|
21
|
+
def metadata=(*)
|
22
|
+
end
|
57
23
|
|
58
|
-
def default_value(*)
|
24
|
+
def default_value(*)
|
25
|
+
end
|
59
26
|
end
|
60
27
|
|
61
|
-
class Object
|
28
|
+
class Object # :nodoc:
|
62
29
|
def caller_locations(*)
|
63
30
|
[]
|
64
31
|
end
|
65
32
|
end
|
66
33
|
end
|
67
34
|
|
68
|
-
_spec = Hoe.spec
|
69
|
-
developer(
|
35
|
+
_spec = Hoe.spec "diff-lcs" do
|
36
|
+
developer("Austin Ziegler", "halostatue@gmail.com")
|
37
|
+
|
38
|
+
self.history_file = "CHANGELOG.md"
|
39
|
+
self.readme_file = "README.md"
|
40
|
+
self.licenses = ["MIT", "Artistic-1.0-Perl", "GPL-2.0-or-later"]
|
70
41
|
|
71
|
-
require_ruby_version
|
42
|
+
require_ruby_version ">= 1.8"
|
72
43
|
|
73
|
-
|
74
|
-
|
75
|
-
|
44
|
+
spec_extras[:metadata] = ->(val) {
|
45
|
+
val["rubygems_mfa_required"] = "true"
|
46
|
+
val["changelog_uri"] = "https://github.com/halostatue/diff-lcs/blob/main/CHANGELOG.md"
|
47
|
+
}
|
76
48
|
|
77
|
-
extra_dev_deps << [
|
78
|
-
extra_dev_deps << [
|
79
|
-
extra_dev_deps << [
|
80
|
-
extra_dev_deps << [
|
81
|
-
extra_dev_deps << [
|
82
|
-
extra_dev_deps << [
|
83
|
-
extra_dev_deps << [
|
49
|
+
extra_dev_deps << ["hoe", ">= 3.0", "< 5"]
|
50
|
+
extra_dev_deps << ["hoe-doofus", "~> 1.0"]
|
51
|
+
extra_dev_deps << ["hoe-gemspec2", "~> 1.1"]
|
52
|
+
extra_dev_deps << ["hoe-git2", "~> 1.7"]
|
53
|
+
extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
|
54
|
+
extra_dev_deps << ["rspec", ">= 2.0", "< 4"]
|
55
|
+
extra_dev_deps << ["rake", ">= 10.0", "< 14"]
|
56
|
+
extra_dev_deps << ["rdoc", ">= 6.3.1", "< 7"]
|
84
57
|
end
|
85
58
|
|
86
59
|
desc "Run all specifications"
|
87
60
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
88
|
-
rspec_dirs = %w
|
61
|
+
rspec_dirs = %w[spec lib].join(":")
|
89
62
|
t.rspec_opts = ["-I#{rspec_dirs}"]
|
90
63
|
end
|
91
64
|
|
92
65
|
Rake::Task["spec"].actions.uniq! { |a| a.source_location }
|
93
66
|
|
67
|
+
# standard:disable Style/HashSyntax
|
94
68
|
task :default => :spec unless Rake::Task["default"].prereqs.include?("spec")
|
95
69
|
task :test => :spec unless Rake::Task["test"].prereqs.include?("spec")
|
70
|
+
# standard:enable Style/HashSyntax
|
96
71
|
|
97
|
-
if RUBY_VERSION >=
|
72
|
+
if RUBY_VERSION >= "2.0" && RUBY_ENGINE == "ruby"
|
98
73
|
namespace :spec do
|
99
74
|
desc "Runs test coverage. Only works Ruby 2.0+ and assumes 'simplecov' is installed."
|
100
75
|
task :coverage do
|
101
|
-
ENV[
|
102
|
-
Rake::Task[
|
76
|
+
ENV["COVERAGE"] = "yes"
|
77
|
+
Rake::Task["spec"].execute
|
103
78
|
end
|
104
79
|
end
|
105
80
|
end
|
106
81
|
|
107
82
|
task :ruby18 do
|
83
|
+
# standard:disable Layout/HeredocIndentation
|
108
84
|
puts <<-MESSAGE
|
109
85
|
You are starting a barebones Ruby 1.8 docker environment. You will need to
|
110
86
|
do the following:
|
@@ -117,5 +93,6 @@ do the following:
|
|
117
93
|
Don't forget to restore your Gemfile.lock after testing.
|
118
94
|
|
119
95
|
MESSAGE
|
96
|
+
# standard:enable Layout/HeredocIndentation
|
120
97
|
sh "docker run -it --rm -v #{Dir.pwd}:/root/diff-lcs bellbind/docker-ruby18-rails2 bash -l"
|
121
98
|
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/bin/htmldiff
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#! /usr/bin/env ruby -w
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "diff/lcs"
|
5
|
+
require "diff/lcs/htmldiff"
|
6
6
|
|
7
7
|
begin
|
8
|
-
require
|
8
|
+
require "text/format"
|
9
9
|
rescue LoadError
|
10
10
|
Diff::LCS::HTMLDiff.can_expand_tabs = false
|
11
11
|
end
|
@@ -24,7 +24,7 @@ options = { :title => "diff #{ARGV[0]} #{ARGV[1]}" }
|
|
24
24
|
htmldiff = Diff::LCS::HTMLDiff.new(left, right, options)
|
25
25
|
|
26
26
|
if ARGV[2]
|
27
|
-
File.open(ARGV[2],
|
27
|
+
File.open(ARGV[2], "w") do |f|
|
28
28
|
htmldiff.options[:output] = f
|
29
29
|
htmldiff.run
|
30
30
|
end
|
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
|