diff-lcs 1.5.1 → 2.0.0
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 +581 -0
- data/CODE_OF_CONDUCT.md +166 -0
- data/CONTRIBUTING.md +127 -0
- data/CONTRIBUTORS.md +59 -0
- data/LICENCE.md +68 -0
- data/Manifest.txt +99 -35
- data/README.md +105 -0
- data/Rakefile +107 -96
- data/SECURITY.md +36 -0
- data/integration/compare/array_diff_spec.rb +10 -0
- data/integration/compare/hash_diff_spec.rb +25 -0
- data/integration/compare/string_diff_spec.rb +10 -0
- data/integration/rspec_differ_spec.rb +26 -0
- data/integration/rspec_expectations_spec.rb +32 -0
- data/integration/runner +20 -0
- data/lib/diff/lcs/block.rb +29 -24
- data/lib/diff/lcs/callbacks.rb +240 -242
- data/lib/diff/lcs/change.rb +102 -104
- data/lib/diff/lcs/hunk.rb +110 -157
- data/lib/diff/lcs/internals.rb +92 -96
- data/lib/diff/lcs/ldiff.rb +81 -73
- data/lib/diff/lcs/version.rb +7 -0
- data/lib/diff/lcs.rb +440 -466
- data/{docs → licenses}/artistic.txt +1 -1
- data/licenses/dco.txt +34 -0
- data/spec/hunk_spec.rb +33 -46
- data/spec/issues_spec.rb +32 -32
- data/spec/lcs_spec.rb +6 -6
- data/spec/ldiff_spec.rb +27 -16
- data/spec/patch_spec.rb +1 -1
- data/spec/spec_helper.rb +98 -108
- data/test/fixtures/123_x +2 -0
- data/test/fixtures/456_x +2 -0
- data/test/fixtures/empty +0 -0
- data/test/fixtures/file1.bin +0 -0
- data/test/fixtures/file2.bin +0 -0
- data/test/fixtures/four_lines +4 -0
- data/test/fixtures/four_lines_with_missing_new_line +4 -0
- data/test/fixtures/ldiff/diff.missing_new_line1-e +1 -0
- data/test/fixtures/ldiff/diff.missing_new_line1-f +1 -0
- data/test/fixtures/ldiff/diff.missing_new_line2-e +1 -0
- data/test/fixtures/ldiff/diff.missing_new_line2-f +1 -0
- data/test/fixtures/ldiff/error.diff.chef-e +2 -0
- data/test/fixtures/ldiff/error.diff.chef-f +2 -0
- data/test/fixtures/ldiff/error.diff.missing_new_line1-e +1 -0
- data/test/fixtures/ldiff/error.diff.missing_new_line1-f +1 -0
- data/test/fixtures/ldiff/error.diff.missing_new_line2-e +1 -0
- data/test/fixtures/ldiff/error.diff.missing_new_line2-f +1 -0
- data/test/fixtures/ldiff/output.diff-c +7 -0
- data/test/fixtures/ldiff/output.diff-u +5 -0
- data/test/fixtures/ldiff/output.diff.bin1 +0 -0
- data/test/fixtures/ldiff/output.diff.bin1-c +0 -0
- data/test/fixtures/ldiff/output.diff.bin1-e +0 -0
- data/test/fixtures/ldiff/output.diff.bin1-f +0 -0
- data/test/fixtures/ldiff/output.diff.bin1-u +0 -0
- data/test/fixtures/ldiff/output.diff.bin2 +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-c +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-e +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-f +1 -0
- data/test/fixtures/ldiff/output.diff.bin2-u +1 -0
- data/{spec → test}/fixtures/ldiff/output.diff.chef-c +2 -2
- data/test/fixtures/ldiff/output.diff.chef-u +9 -0
- data/{spec → test}/fixtures/ldiff/output.diff.chef2-c +2 -2
- data/{spec → test}/fixtures/ldiff/output.diff.chef2-u +2 -2
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines +5 -0
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-c +9 -0
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-e +6 -0
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-f +6 -0
- data/test/fixtures/ldiff/output.diff.empty.vs.four_lines-u +7 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty +5 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-c +9 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-e +1 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-f +1 -0
- data/test/fixtures/ldiff/output.diff.four_lines.vs.empty-u +7 -0
- data/test/fixtures/ldiff/output.diff.issue95_trailing_context +4 -0
- data/test/fixtures/ldiff/output.diff.issue95_trailing_context-c +9 -0
- data/{spec/fixtures/ldiff/output.diff-e → test/fixtures/ldiff/output.diff.issue95_trailing_context-e} +1 -1
- data/{spec/fixtures/ldiff/output.diff-f → test/fixtures/ldiff/output.diff.issue95_trailing_context-f} +1 -1
- data/test/fixtures/ldiff/output.diff.issue95_trailing_context-u +6 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line1 +5 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line1-c +14 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line1-e +0 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line1-f +0 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line1-u +9 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line2 +5 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line2-c +14 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line2-e +0 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line2-f +0 -0
- data/test/fixtures/ldiff/output.diff.missing_new_line2-u +9 -0
- data/test/test_block.rb +34 -0
- data/test/test_change.rb +234 -0
- data/test/test_diff.rb +53 -0
- data/test/test_helper.rb +225 -0
- data/test/test_hunk.rb +72 -0
- data/test/test_issues.rb +168 -0
- data/test/test_lcs.rb +47 -0
- data/test/test_ldiff.rb +89 -0
- data/test/test_patch.rb +362 -0
- data/test/test_sdiff.rb +167 -0
- data/test/test_traverse_balanced.rb +322 -0
- data/test/test_traverse_sequences.rb +187 -0
- metadata +211 -103
- data/.rspec +0 -1
- data/Code-of-Conduct.md +0 -74
- data/Contributing.md +0 -121
- data/History.md +0 -431
- data/License.md +0 -41
- data/README.rdoc +0 -84
- data/bin/htmldiff +0 -35
- data/lib/diff/lcs/backports.rb +0 -9
- data/lib/diff/lcs/htmldiff.rb +0 -158
- data/spec/fixtures/ldiff/output.diff-c +0 -7
- data/spec/fixtures/ldiff/output.diff-u +0 -5
- data/spec/fixtures/ldiff/output.diff.chef-e +0 -3
- data/spec/fixtures/ldiff/output.diff.chef-f +0 -3
- data/spec/fixtures/ldiff/output.diff.chef-u +0 -9
- data/spec/fixtures/ldiff/output.diff.chef2-e +0 -7
- data/spec/fixtures/ldiff/output.diff.chef2-f +0 -7
- /data/{docs → licenses}/COPYING.txt +0 -0
- /data/{spec → test}/fixtures/aX +0 -0
- /data/{spec → test}/fixtures/bXaX +0 -0
- /data/{spec → test}/fixtures/ds1.csv +0 -0
- /data/{spec → test}/fixtures/ds2.csv +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef2 +0 -0
- /data/{spec → test}/fixtures/ldiff/output.diff.chef2-d +0 -0
- /data/{spec → test}/fixtures/new-chef +0 -0
- /data/{spec → test}/fixtures/new-chef2 +0 -0
- /data/{spec → test}/fixtures/old-chef +0 -0
- /data/{spec → test}/fixtures/old-chef2 +0 -0
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Contributor Covenant 3.0 Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We pledge to make our community welcoming, safe, and equitable for all.
|
|
6
|
+
|
|
7
|
+
We are committed to fostering an environment that respects and promotes the
|
|
8
|
+
dignity, rights, and contributions of all individuals, regardless of
|
|
9
|
+
characteristics including race, ethnicity, caste, color, age, physical
|
|
10
|
+
characteristics, neurodiversity, disability, sex or gender, gender identity or
|
|
11
|
+
expression, sexual orientation, language, philosophy or religion, national or
|
|
12
|
+
social origin, socio-economic position, level of education, or other status. The
|
|
13
|
+
same privileges of participation are extended to everyone who participates in
|
|
14
|
+
good faith and in accordance with this Covenant.
|
|
15
|
+
|
|
16
|
+
## Encouraged Behaviors
|
|
17
|
+
|
|
18
|
+
While acknowledging differences in social norms, we all strive to meet our
|
|
19
|
+
community's expectations for positive behavior. We also understand that our
|
|
20
|
+
words and actions may be interpreted differently than we intend based on
|
|
21
|
+
culture, background, or native language.
|
|
22
|
+
|
|
23
|
+
With these considerations in mind, we agree to behave mindfully toward each
|
|
24
|
+
other and act in ways that center our shared values, including:
|
|
25
|
+
|
|
26
|
+
1. Respecting the **purpose of our community**, our activities, and our ways of
|
|
27
|
+
gathering.
|
|
28
|
+
2. Engaging **kindly and honestly** with others.
|
|
29
|
+
3. Respecting **different viewpoints** and experiences.
|
|
30
|
+
4. **Taking responsibility** for our actions and contributions.
|
|
31
|
+
5. Gracefully giving and accepting **constructive feedback**.
|
|
32
|
+
6. Committing to **repairing harm** when it occurs.
|
|
33
|
+
7. Behaving in other ways that promote and sustain the **well-being of our
|
|
34
|
+
community**.
|
|
35
|
+
|
|
36
|
+
## Restricted Behaviors
|
|
37
|
+
|
|
38
|
+
We agree to restrict the following behaviors in our community. Instances,
|
|
39
|
+
threats, and promotion of these behaviors are violations of this Code of
|
|
40
|
+
Conduct.
|
|
41
|
+
|
|
42
|
+
1. **Harassment.** Violating explicitly expressed boundaries or engaging in
|
|
43
|
+
unnecessary personal attention after any clear request to stop.
|
|
44
|
+
2. **Character attacks.** Making insulting, demeaning, or pejorative comments
|
|
45
|
+
directed at a community member or group of people.
|
|
46
|
+
3. **Stereotyping or discrimination.** Characterizing anyone’s personality or
|
|
47
|
+
behavior on the basis of immutable identities or traits.
|
|
48
|
+
4. **Sexualization.** Behaving in a way that would generally be considered
|
|
49
|
+
inappropriately intimate in the context or purpose of the community.
|
|
50
|
+
5. **Violating confidentiality**. Sharing or acting on someone's personal or
|
|
51
|
+
private information without their permission.
|
|
52
|
+
6. **Endangerment.** Causing, encouraging, or threatening violence or other harm
|
|
53
|
+
toward any person or group.
|
|
54
|
+
7. Behaving in other ways that **threaten the well-being** of our community.
|
|
55
|
+
|
|
56
|
+
### Other Restrictions
|
|
57
|
+
|
|
58
|
+
1. **Misleading identity.** Impersonating someone else for any reason, or
|
|
59
|
+
pretending to be someone else to evade enforcement actions.
|
|
60
|
+
2. **Failing to credit sources.** Not properly crediting the sources of content
|
|
61
|
+
you contribute.
|
|
62
|
+
3. **Promotional materials**. Sharing marketing or other commercial content in a
|
|
63
|
+
way that is outside the norms of the community.
|
|
64
|
+
4. **Irresponsible communication.** Failing to responsibly present content which
|
|
65
|
+
includes, links or describes any other restricted behaviors.
|
|
66
|
+
|
|
67
|
+
## Reporting an Issue
|
|
68
|
+
|
|
69
|
+
Tensions can occur between community members even when they are trying their
|
|
70
|
+
best to collaborate. Not every conflict represents a code of conduct violation,
|
|
71
|
+
and this Code of Conduct reinforces encouraged behaviors and norms that can help
|
|
72
|
+
avoid conflicts and minimize harm.
|
|
73
|
+
|
|
74
|
+
When an incident does occur, it is important to report it promptly. To report a
|
|
75
|
+
possible violation, create a [private security advisory][advisory] — violations
|
|
76
|
+
of this code of conduct are considered security vulnerabilities.
|
|
77
|
+
|
|
78
|
+
Community Moderators take reports of violations seriously and will make every
|
|
79
|
+
effort to respond in a timely manner. They will investigate all reports of code
|
|
80
|
+
of conduct violations, reviewing messages, logs, and recordings, or interviewing
|
|
81
|
+
witnesses and other participants. Community Moderators will keep investigation
|
|
82
|
+
and enforcement actions as transparent as possible while prioritizing safety and
|
|
83
|
+
confidentiality. In order to honor these values, enforcement actions are carried
|
|
84
|
+
out in private with the involved parties, but communicating to the whole
|
|
85
|
+
community may be part of a mutually agreed upon resolution.
|
|
86
|
+
|
|
87
|
+
## Addressing and Repairing Harm
|
|
88
|
+
|
|
89
|
+
If an investigation by the Community Moderators finds that this Code of Conduct
|
|
90
|
+
has been violated, the following enforcement ladder may be used to determine how
|
|
91
|
+
best to repair harm, based on the incident's impact on the individuals involved
|
|
92
|
+
and the community as a whole. Depending on the severity of a violation, lower
|
|
93
|
+
rungs on the ladder may be skipped.
|
|
94
|
+
|
|
95
|
+
1. Warning
|
|
96
|
+
1. Event: A violation involving a single incident or series of incidents.
|
|
97
|
+
2. Consequence: A private, written warning from the Community Moderators.
|
|
98
|
+
3. Repair: Examples of repair include a private written apology,
|
|
99
|
+
acknowledgement of responsibility, and seeking clarification on
|
|
100
|
+
expectations.
|
|
101
|
+
|
|
102
|
+
2. Temporarily Limited Activities
|
|
103
|
+
1. Event: A repeated incidence of a violation that previously resulted in a
|
|
104
|
+
warning, or the first incidence of a more serious violation.
|
|
105
|
+
2. Consequence: A private, written warning with a time-limited cooldown
|
|
106
|
+
period designed to underscore the seriousness of the situation and give
|
|
107
|
+
the community members involved time to process the incident. The cooldown
|
|
108
|
+
period may be limited to particular communication channels or interactions
|
|
109
|
+
with particular community members.
|
|
110
|
+
3. Repair: Examples of repair may include making an apology, using the
|
|
111
|
+
cooldown period to reflect on actions and impact, and being thoughtful
|
|
112
|
+
about re-entering community spaces after the period is over.
|
|
113
|
+
|
|
114
|
+
3. Temporary Suspension
|
|
115
|
+
1. Event: A pattern of repeated violation which the Community Moderators have
|
|
116
|
+
tried to address with warnings, or a single serious violation.
|
|
117
|
+
2. Consequence: A private written warning with conditions for return from
|
|
118
|
+
suspension. In general, temporary suspensions give the person being
|
|
119
|
+
suspended time to reflect upon their behavior and possible corrective
|
|
120
|
+
actions.
|
|
121
|
+
3. Repair: Examples of repair include respecting the spirit of the
|
|
122
|
+
suspension, meeting the specified conditions for return, and being
|
|
123
|
+
thoughtful about how to reintegrate with the community when the suspension
|
|
124
|
+
is lifted.
|
|
125
|
+
|
|
126
|
+
4. Permanent Ban
|
|
127
|
+
1. Event: A pattern of repeated code of conduct violations that other steps
|
|
128
|
+
on the ladder have failed to resolve, or a violation so serious that the
|
|
129
|
+
Community Moderators determine there is no way to keep the community safe
|
|
130
|
+
with this person as a member.
|
|
131
|
+
2. Consequence: Access to all community spaces, tools, and communication
|
|
132
|
+
channels is removed. In general, permanent bans should be rarely used,
|
|
133
|
+
should have strong reasoning behind them, and should only be resorted to
|
|
134
|
+
if working through other remedies has failed to change the behavior.
|
|
135
|
+
3. Repair: There is no possible repair in cases of this severity.
|
|
136
|
+
|
|
137
|
+
This enforcement ladder is intended as a guideline. It does not limit the
|
|
138
|
+
ability of Community Managers to use their discretion and judgment, in keeping
|
|
139
|
+
with the best interests of our community.
|
|
140
|
+
|
|
141
|
+
## Scope
|
|
142
|
+
|
|
143
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
144
|
+
an individual is officially representing the community in public or other
|
|
145
|
+
spaces. Examples of representing our community include using an official email
|
|
146
|
+
address, posting via an official social media account, or acting as an appointed
|
|
147
|
+
representative at an online or offline event.
|
|
148
|
+
|
|
149
|
+
## Attribution
|
|
150
|
+
|
|
151
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 3.0,
|
|
152
|
+
permanently available at <https://www.contributor-covenant.org/version/3/0/>.
|
|
153
|
+
|
|
154
|
+
Contributor Covenant is stewarded by the Organization for Ethical Source and
|
|
155
|
+
licensed under CC BY-SA 4.0. To view a copy of this license, visit
|
|
156
|
+
<https://creativecommons.org/licenses/by-sa/4.0/>.
|
|
157
|
+
|
|
158
|
+
For answers to common questions about Contributor Covenant, see the FAQ at
|
|
159
|
+
<https://www.contributor-covenant.org/faq>. Translations are provided at
|
|
160
|
+
<https://www.contributor-covenant.org/translations>. Additional enforcement and
|
|
161
|
+
community guideline resources can be found at
|
|
162
|
+
<https://www.contributor-covenant.org/resources>. The enforcement ladder was
|
|
163
|
+
inspired by the work of [Mozilla’s code of conduct team][inclusion].
|
|
164
|
+
|
|
165
|
+
[advisory]: https://github.com/halostatue/diff-lcs/security/advisories/new
|
|
166
|
+
[inclusion]: https://github.com/mozilla/inclusion
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contribution to diff-lcs is encouraged: bug reports, feature requests, or code
|
|
4
|
+
contributions. New features should be proposed and discussed in an
|
|
5
|
+
[issue][issues].
|
|
6
|
+
|
|
7
|
+
Before contributing patches, please read the [Licence](./LICENCE.md).
|
|
8
|
+
|
|
9
|
+
diff-lcs is governed under the [Contributor Covenant Code of Conduct][cccoc].
|
|
10
|
+
|
|
11
|
+
## Code Guidelines
|
|
12
|
+
|
|
13
|
+
I have several guidelines to contributing code through pull requests:
|
|
14
|
+
|
|
15
|
+
- All code changes require tests. In most cases, this will be added or updated
|
|
16
|
+
unit tests. I use [Minitest][minitest].
|
|
17
|
+
|
|
18
|
+
- There are integration tests with RSpec which must not be broken, accessible
|
|
19
|
+
through `rake integration`. This requires a non-bundled RSpec,
|
|
20
|
+
`gem install rspec`.
|
|
21
|
+
|
|
22
|
+
- I use code formatters, static analysis tools, and linting to ensure consistent
|
|
23
|
+
styles and formatting. There should be no warning output from test run
|
|
24
|
+
processes. I use [Standard Ruby][standardrb].
|
|
25
|
+
|
|
26
|
+
- Proposed changes should be on a thoughtfully-named topic branch and organized
|
|
27
|
+
into logical commit chunks as appropriate.
|
|
28
|
+
|
|
29
|
+
- Use [Conventional Commits][conventional] with my
|
|
30
|
+
[conventions](#commit-conventions).
|
|
31
|
+
|
|
32
|
+
- Versions must not be updated in pull requests unless otherwise directed. This
|
|
33
|
+
means that you must not:
|
|
34
|
+
|
|
35
|
+
- Modify `VERSION` in `lib/diff/lcs/version.rb`. When your patch is accepted
|
|
36
|
+
and a release is made, the version will be updated at that point.
|
|
37
|
+
|
|
38
|
+
- Modify `diff-lcs.gemspec`; it is a generated file. (You _may_ use
|
|
39
|
+
`rake gemspec` to regenerate it if your change involves metadata related to
|
|
40
|
+
gem itself).
|
|
41
|
+
|
|
42
|
+
- Modify the `Gemfile`.
|
|
43
|
+
|
|
44
|
+
- Documentation should be added or updated as appropriate for new or updated
|
|
45
|
+
functionality. The documentation is RDoc; diff-lcs does not use extensions
|
|
46
|
+
that may be present in alternative documentation generators.
|
|
47
|
+
|
|
48
|
+
- All GitHub Actions checks marked as required must pass before a pull request
|
|
49
|
+
may be accepted and merged.
|
|
50
|
+
|
|
51
|
+
- Add your name or GitHub handle to `CONTRIBUTORS.md` and a record in the
|
|
52
|
+
`CHANGELOG.md` as a separate commit from your main change. (Follow the style
|
|
53
|
+
in the `CHANGELOG.md` and provide a link to your PR.)
|
|
54
|
+
|
|
55
|
+
- Include your DCO sign-off in each commit message (see [LICENCE](LICENCE.md)).
|
|
56
|
+
|
|
57
|
+
## AI Contribution Policy
|
|
58
|
+
|
|
59
|
+
diff-lcs is a library with complex interactions and subtle decisions (some of
|
|
60
|
+
them possibly even wrong). It is extremely important that contributions of any
|
|
61
|
+
sort be well understood by the submitter and that the developer can attest to
|
|
62
|
+
the [Developer Certificate of Origin][dco] for each pull request (see
|
|
63
|
+
[LICENCE](LICENCE.md)).
|
|
64
|
+
|
|
65
|
+
Any contribution (bug, feature request, or pull request) that uses undeclared AI
|
|
66
|
+
output will be rejected.
|
|
67
|
+
|
|
68
|
+
## Test Dependencies
|
|
69
|
+
|
|
70
|
+
diff-lcs uses Ryan Davis's [Hoe][Hoe] to manage the release process, and it adds
|
|
71
|
+
a number of rake tasks. You will mostly be interested in `rake`, which runs
|
|
72
|
+
tests in the same way that `rake spec` does.
|
|
73
|
+
|
|
74
|
+
To assist with the installation of the development dependencies for diff-lcs, I
|
|
75
|
+
have provided a Gemfile pointing to the (generated) `diff-lcs.gemspec` file.
|
|
76
|
+
This will permit you to use `bundle install` to install the dependencies.
|
|
77
|
+
|
|
78
|
+
You can run tests with code coverage analysis by running `rake spec:coverage`.
|
|
79
|
+
|
|
80
|
+
## Commit Conventions
|
|
81
|
+
|
|
82
|
+
diff-lcs has adopted a variation of the Conventional Commits format for commit
|
|
83
|
+
messages. The following types are permitted:
|
|
84
|
+
|
|
85
|
+
| Type | Purpose |
|
|
86
|
+
| ------- | ----------------------------------------------------- |
|
|
87
|
+
| `feat` | A new feature |
|
|
88
|
+
| `fix` | A bug fix |
|
|
89
|
+
| `chore` | A code change that is neither a bug fix nor a feature |
|
|
90
|
+
| `docs` | Documentation updates |
|
|
91
|
+
| `deps` | Dependency updates, including GitHub Actions. |
|
|
92
|
+
|
|
93
|
+
I encourage the use of [Tim Pope's][tpope-qcm] or [Chris Beam's][cbeams]
|
|
94
|
+
guidelines on the writing of commit messages
|
|
95
|
+
|
|
96
|
+
I require the use of [git][trailers1] [trailers][trailers2] for specific
|
|
97
|
+
additional metadata and strongly encourage it for others. The conditionally
|
|
98
|
+
required metadata trailers are:
|
|
99
|
+
|
|
100
|
+
- `Breaking-Change`: if the change is a breaking change. **Do not** use the
|
|
101
|
+
shorthand form (`feat!(scope)`) or `BREAKING CHANGE`.
|
|
102
|
+
|
|
103
|
+
- `Signed-off-by`: this is required for all developers except me, as outlined in
|
|
104
|
+
the [Licence](./LICENCE.md#developer-certificate-of-origin).
|
|
105
|
+
|
|
106
|
+
- `Fixes` or `Resolves`: If a change fixes one or more open [issues][issues],
|
|
107
|
+
that issue must be included in the `Fixes` or `Resolves` trailer. Multiple
|
|
108
|
+
issues should be listed comma separated in the same trailer:
|
|
109
|
+
`Fixes: #1, #5, #7`, but _may_ appear in separate trailers. While both `Fixes`
|
|
110
|
+
and `Resolves` are synonyms, only _one_ should be used in a given commit or
|
|
111
|
+
pull request.
|
|
112
|
+
|
|
113
|
+
- `Related to`: If a change does not fix an issue, those issue references should
|
|
114
|
+
be included in this trailer.
|
|
115
|
+
|
|
116
|
+
[cbeams]: https://cbea.ms/git-commit/
|
|
117
|
+
[cccoc]: ./CODE_OF_CONDUCT.md
|
|
118
|
+
[conventional]: https://www.conventionalcommits.org/en/v1.0.0/
|
|
119
|
+
[dco]: licences/dco.txt
|
|
120
|
+
[hoe]: https://github.com/seattlerb/hoe
|
|
121
|
+
[issues]: https://github.com/halostatue/diff-lcs/issues
|
|
122
|
+
[minitest]: https://github.com/seattlerb/minitest
|
|
123
|
+
[rspec]: https://rspec.info/documentation/
|
|
124
|
+
[standardrb]: https://github.com/standardrb/standard
|
|
125
|
+
[tpope-qcm]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
|
126
|
+
[trailers1]: https://git-scm.com/docs/git-interpret-trailers
|
|
127
|
+
[trailers2]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---trailerlttokengtltvaluegt
|
data/CONTRIBUTORS.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Contributors
|
|
2
|
+
|
|
3
|
+
- Austin Ziegler ([@halostatue][gh-user-halostatue]) created diff-lcs.
|
|
4
|
+
|
|
5
|
+
Thanks to everyone else who has contributed to diff-lcs over the years:
|
|
6
|
+
|
|
7
|
+
- [@ginriki][gh-user-ginriki]
|
|
8
|
+
- [@joshbronson][gh-user-joshbronson]
|
|
9
|
+
- [@kevinmook][gh-user-kevinmook]
|
|
10
|
+
- [@mckaz][gh-user-mckaz]
|
|
11
|
+
- Akinori Musha
|
|
12
|
+
- Artem Ignatyev
|
|
13
|
+
- Brandon Fish
|
|
14
|
+
- Baptiste Courtois ([@annih][gh-user-annih])
|
|
15
|
+
- Camille Drapier
|
|
16
|
+
- Cédric Boutillier
|
|
17
|
+
- [@earlopain][gh-user-earlopain]
|
|
18
|
+
- Gregg Kellogg
|
|
19
|
+
- Jagdeep Singh
|
|
20
|
+
- Jason Gladish
|
|
21
|
+
- Jon Rowe
|
|
22
|
+
- Josef Strzibny
|
|
23
|
+
- Josep ([@apuratepp][gh-user-apuratepp])
|
|
24
|
+
- Josh Bronson
|
|
25
|
+
- Jun Aruga
|
|
26
|
+
- Justin Steele
|
|
27
|
+
- Kenichi Kamiya
|
|
28
|
+
- Kensuke Nagae
|
|
29
|
+
- Kevin Ansfield
|
|
30
|
+
- Koichi Ito
|
|
31
|
+
- Mark Friedgan
|
|
32
|
+
- Masato Nakamura
|
|
33
|
+
- Mark Young
|
|
34
|
+
- Michael Granger
|
|
35
|
+
- Myron Marston
|
|
36
|
+
- Nicolas Leger
|
|
37
|
+
- Oleg Orlov
|
|
38
|
+
- Patrick Linnane
|
|
39
|
+
- Paul Kunysch
|
|
40
|
+
- Pete Higgins
|
|
41
|
+
- Peter Goldstein
|
|
42
|
+
- Peter Wagenet
|
|
43
|
+
- Philippe Lafoucrière
|
|
44
|
+
- Ryan Lovelett
|
|
45
|
+
- Scott Steele
|
|
46
|
+
- Simon Courtois
|
|
47
|
+
- Tien ([@tiendo1011][gh-user-tiendo1011])
|
|
48
|
+
- Tomas Jura
|
|
49
|
+
- Vít Ondruch
|
|
50
|
+
|
|
51
|
+
[gh-user-halostatue]: https://github.com/halostatue
|
|
52
|
+
[gh-user-ginriki]: https://github.com/ginriki
|
|
53
|
+
[gh-user-joshbronson]: https://github.com/joshbronson
|
|
54
|
+
[gh-user-kevinmook]: https://github.com/kevinmook
|
|
55
|
+
[gh-user-mckaz]: https://github.com/mckaz
|
|
56
|
+
[gh-user-annih]: https://github.com/annih
|
|
57
|
+
[gh-user-earlopain]: https://github.com/earlopain
|
|
58
|
+
[gh-user-apuratepp]: https://github.com/apuratepp
|
|
59
|
+
[gh-user-tiendo1011]: https://github.com/tiendo1011
|
data/LICENCE.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Licence
|
|
2
|
+
|
|
3
|
+
- SPDX-License-Identifier: [MIT][mit] OR [GPL-2.0-or-later][gpl2-or-later] OR
|
|
4
|
+
[Artistic-1.0-Perl][artistic-perl]
|
|
5
|
+
|
|
6
|
+
This software is available under three disjunctive licences: the GNU GPL version
|
|
7
|
+
2 (or at your option, a later version), the Perl Artistic license, or the MIT
|
|
8
|
+
license. Note that my preference for licensing is the MIT license, but
|
|
9
|
+
Algorithm::Diff was dually originally licensed with the Perl Artistic and the
|
|
10
|
+
GNU GPL ("the same terms as Perl itself") and given that the Ruby implementation
|
|
11
|
+
originally hewed pretty closely to the Perl version, I must maintain the
|
|
12
|
+
additional licensing terms.
|
|
13
|
+
|
|
14
|
+
- Copyright 2004-2026 Austin Ziegler and contributors.
|
|
15
|
+
- Adapted from Algorithm::Diff (Perl) by Ned Konz and a Smalltalk version by
|
|
16
|
+
Mario I. Wolczko.
|
|
17
|
+
|
|
18
|
+
## MIT License
|
|
19
|
+
|
|
20
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
21
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
22
|
+
the Software without restriction, including without limitation the rights to
|
|
23
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
24
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
25
|
+
subject to the following conditions:
|
|
26
|
+
|
|
27
|
+
The above copyright notice and this permission notice shall be included in all
|
|
28
|
+
copies or substantial portions of the Software.
|
|
29
|
+
|
|
30
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
32
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
33
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
34
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
35
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
36
|
+
|
|
37
|
+
## Perl Artistic License
|
|
38
|
+
|
|
39
|
+
See [licences/artistic.txt](licences/artistic.txt) in the main distribution.
|
|
40
|
+
|
|
41
|
+
## GNU GPL version 2
|
|
42
|
+
|
|
43
|
+
See the file [licences/COPYING.txt](licences/COPYING.txt) in the main
|
|
44
|
+
distribution.
|
|
45
|
+
|
|
46
|
+
## Developer Certificate of Origin
|
|
47
|
+
|
|
48
|
+
All contributors **must** certify they are willing and able to provide their
|
|
49
|
+
contributions under the terms of _all_ of this project's licences with the
|
|
50
|
+
certification of the [Developer Certificate of Origin (Version 1.1)][dco].
|
|
51
|
+
|
|
52
|
+
Such certification is provided by ensuring that a `Signed-off-by`
|
|
53
|
+
[commit trailer][trailer] is present on every commit:
|
|
54
|
+
|
|
55
|
+
Signed-off-by: FirstName LastName <email@example.org>
|
|
56
|
+
|
|
57
|
+
The `Signed-off-by` trailer can be automatically added by git with the `-s` or
|
|
58
|
+
`--signoff` option on `git commit`:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
git commit --signoff
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
[artistic-perl]: https://spdx.org/licenses/Artistic-1.0-Perl.html
|
|
65
|
+
[gpl2-or-later]: https://spdx.org/licenses/GPL-2.0-or-later.html
|
|
66
|
+
[mit]: https://spdx.org/licenses/MIT.html
|
|
67
|
+
[trailer]: https://git-scm.com/docs/git-interpret-trailers
|
|
68
|
+
[dco]: licences/dco.txt
|
data/Manifest.txt
CHANGED
|
@@ -1,53 +1,35 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
CHANGELOG.md
|
|
2
|
+
CODE_OF_CONDUCT.md
|
|
3
|
+
CONTRIBUTING.md
|
|
4
|
+
CONTRIBUTORS.md
|
|
5
|
+
LICENCE.md
|
|
6
6
|
Manifest.txt
|
|
7
|
-
README.
|
|
7
|
+
README.md
|
|
8
8
|
Rakefile
|
|
9
|
-
|
|
9
|
+
SECURITY.md
|
|
10
10
|
bin/ldiff
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
integration/compare/array_diff_spec.rb
|
|
12
|
+
integration/compare/hash_diff_spec.rb
|
|
13
|
+
integration/compare/string_diff_spec.rb
|
|
14
|
+
integration/rspec_differ_spec.rb
|
|
15
|
+
integration/rspec_expectations_spec.rb
|
|
16
|
+
integration/runner
|
|
13
17
|
lib/diff-lcs.rb
|
|
14
18
|
lib/diff/lcs.rb
|
|
15
19
|
lib/diff/lcs/array.rb
|
|
16
|
-
lib/diff/lcs/backports.rb
|
|
17
20
|
lib/diff/lcs/block.rb
|
|
18
21
|
lib/diff/lcs/callbacks.rb
|
|
19
22
|
lib/diff/lcs/change.rb
|
|
20
|
-
lib/diff/lcs/htmldiff.rb
|
|
21
23
|
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
|
+
licenses/COPYING.txt
|
|
29
|
+
licenses/artistic.txt
|
|
30
|
+
licenses/dco.txt
|
|
25
31
|
spec/change_spec.rb
|
|
26
32
|
spec/diff_spec.rb
|
|
27
|
-
spec/fixtures/aX
|
|
28
|
-
spec/fixtures/bXaX
|
|
29
|
-
spec/fixtures/ds1.csv
|
|
30
|
-
spec/fixtures/ds2.csv
|
|
31
|
-
spec/fixtures/ldiff/output.diff
|
|
32
|
-
spec/fixtures/ldiff/output.diff-c
|
|
33
|
-
spec/fixtures/ldiff/output.diff-e
|
|
34
|
-
spec/fixtures/ldiff/output.diff-f
|
|
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
|
|
51
33
|
spec/hunk_spec.rb
|
|
52
34
|
spec/issues_spec.rb
|
|
53
35
|
spec/lcs_spec.rb
|
|
@@ -57,3 +39,85 @@ spec/sdiff_spec.rb
|
|
|
57
39
|
spec/spec_helper.rb
|
|
58
40
|
spec/traverse_balanced_spec.rb
|
|
59
41
|
spec/traverse_sequences_spec.rb
|
|
42
|
+
test/fixtures/123_x
|
|
43
|
+
test/fixtures/456_x
|
|
44
|
+
test/fixtures/aX
|
|
45
|
+
test/fixtures/bXaX
|
|
46
|
+
test/fixtures/ds1.csv
|
|
47
|
+
test/fixtures/ds2.csv
|
|
48
|
+
test/fixtures/empty
|
|
49
|
+
test/fixtures/file1.bin
|
|
50
|
+
test/fixtures/file2.bin
|
|
51
|
+
test/fixtures/four_lines
|
|
52
|
+
test/fixtures/four_lines_with_missing_new_line
|
|
53
|
+
test/fixtures/ldiff/diff.missing_new_line1-e
|
|
54
|
+
test/fixtures/ldiff/diff.missing_new_line1-f
|
|
55
|
+
test/fixtures/ldiff/diff.missing_new_line2-e
|
|
56
|
+
test/fixtures/ldiff/diff.missing_new_line2-f
|
|
57
|
+
test/fixtures/ldiff/error.diff.chef-e
|
|
58
|
+
test/fixtures/ldiff/error.diff.chef-f
|
|
59
|
+
test/fixtures/ldiff/error.diff.missing_new_line1-e
|
|
60
|
+
test/fixtures/ldiff/error.diff.missing_new_line1-f
|
|
61
|
+
test/fixtures/ldiff/error.diff.missing_new_line2-e
|
|
62
|
+
test/fixtures/ldiff/error.diff.missing_new_line2-f
|
|
63
|
+
test/fixtures/ldiff/output.diff
|
|
64
|
+
test/fixtures/ldiff/output.diff-c
|
|
65
|
+
test/fixtures/ldiff/output.diff-u
|
|
66
|
+
test/fixtures/ldiff/output.diff.bin1
|
|
67
|
+
test/fixtures/ldiff/output.diff.bin1-c
|
|
68
|
+
test/fixtures/ldiff/output.diff.bin1-e
|
|
69
|
+
test/fixtures/ldiff/output.diff.bin1-f
|
|
70
|
+
test/fixtures/ldiff/output.diff.bin1-u
|
|
71
|
+
test/fixtures/ldiff/output.diff.bin2
|
|
72
|
+
test/fixtures/ldiff/output.diff.bin2-c
|
|
73
|
+
test/fixtures/ldiff/output.diff.bin2-e
|
|
74
|
+
test/fixtures/ldiff/output.diff.bin2-f
|
|
75
|
+
test/fixtures/ldiff/output.diff.bin2-u
|
|
76
|
+
test/fixtures/ldiff/output.diff.chef
|
|
77
|
+
test/fixtures/ldiff/output.diff.chef-c
|
|
78
|
+
test/fixtures/ldiff/output.diff.chef-u
|
|
79
|
+
test/fixtures/ldiff/output.diff.chef2
|
|
80
|
+
test/fixtures/ldiff/output.diff.chef2-c
|
|
81
|
+
test/fixtures/ldiff/output.diff.chef2-d
|
|
82
|
+
test/fixtures/ldiff/output.diff.chef2-u
|
|
83
|
+
test/fixtures/ldiff/output.diff.empty.vs.four_lines
|
|
84
|
+
test/fixtures/ldiff/output.diff.empty.vs.four_lines-c
|
|
85
|
+
test/fixtures/ldiff/output.diff.empty.vs.four_lines-e
|
|
86
|
+
test/fixtures/ldiff/output.diff.empty.vs.four_lines-f
|
|
87
|
+
test/fixtures/ldiff/output.diff.empty.vs.four_lines-u
|
|
88
|
+
test/fixtures/ldiff/output.diff.four_lines.vs.empty
|
|
89
|
+
test/fixtures/ldiff/output.diff.four_lines.vs.empty-c
|
|
90
|
+
test/fixtures/ldiff/output.diff.four_lines.vs.empty-e
|
|
91
|
+
test/fixtures/ldiff/output.diff.four_lines.vs.empty-f
|
|
92
|
+
test/fixtures/ldiff/output.diff.four_lines.vs.empty-u
|
|
93
|
+
test/fixtures/ldiff/output.diff.issue95_trailing_context
|
|
94
|
+
test/fixtures/ldiff/output.diff.issue95_trailing_context-c
|
|
95
|
+
test/fixtures/ldiff/output.diff.issue95_trailing_context-e
|
|
96
|
+
test/fixtures/ldiff/output.diff.issue95_trailing_context-f
|
|
97
|
+
test/fixtures/ldiff/output.diff.issue95_trailing_context-u
|
|
98
|
+
test/fixtures/ldiff/output.diff.missing_new_line1
|
|
99
|
+
test/fixtures/ldiff/output.diff.missing_new_line1-c
|
|
100
|
+
test/fixtures/ldiff/output.diff.missing_new_line1-e
|
|
101
|
+
test/fixtures/ldiff/output.diff.missing_new_line1-f
|
|
102
|
+
test/fixtures/ldiff/output.diff.missing_new_line1-u
|
|
103
|
+
test/fixtures/ldiff/output.diff.missing_new_line2
|
|
104
|
+
test/fixtures/ldiff/output.diff.missing_new_line2-c
|
|
105
|
+
test/fixtures/ldiff/output.diff.missing_new_line2-e
|
|
106
|
+
test/fixtures/ldiff/output.diff.missing_new_line2-f
|
|
107
|
+
test/fixtures/ldiff/output.diff.missing_new_line2-u
|
|
108
|
+
test/fixtures/new-chef
|
|
109
|
+
test/fixtures/new-chef2
|
|
110
|
+
test/fixtures/old-chef
|
|
111
|
+
test/fixtures/old-chef2
|
|
112
|
+
test/test_block.rb
|
|
113
|
+
test/test_change.rb
|
|
114
|
+
test/test_diff.rb
|
|
115
|
+
test/test_helper.rb
|
|
116
|
+
test/test_hunk.rb
|
|
117
|
+
test/test_issues.rb
|
|
118
|
+
test/test_lcs.rb
|
|
119
|
+
test/test_ldiff.rb
|
|
120
|
+
test/test_patch.rb
|
|
121
|
+
test/test_sdiff.rb
|
|
122
|
+
test/test_traverse_balanced.rb
|
|
123
|
+
test/test_traverse_sequences.rb
|
data/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Diff::LCS
|
|
2
|
+
|
|
3
|
+
[![RubyGems Version][shield-gems]][rubygems] ![Coveralls][shield-coveralls]
|
|
4
|
+
[![Build Status][shield-ci]][ci-workflow]
|
|
5
|
+
|
|
6
|
+
- code :: <https://github.com/halostatue/diff-lcs>
|
|
7
|
+
- issues :: <https://github.com/halostatue/diff-lcs/issues>
|
|
8
|
+
- docs :: <https://halostatue.github.io/diff-lcs/>
|
|
9
|
+
- changelog :: <https://github.com/halostatue/diff-lcs/blob/main/CHANGELOG.md>
|
|
10
|
+
|
|
11
|
+
## Description
|
|
12
|
+
|
|
13
|
+
Diff::LCS computes the difference between two Enumerable sequences using the
|
|
14
|
+
McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities
|
|
15
|
+
to create a simple HTML diff output format and a standard diff-like tool.
|
|
16
|
+
|
|
17
|
+
This is release 2.0, which has significant breaking changes (removal of
|
|
18
|
+
deprecations and workarounds) and requires at least Ruby 3.2 or higher. See full
|
|
19
|
+
details in the `CHANGELOG`, but users of diff-lcs should not notice any
|
|
20
|
+
significant changes to the APIs.
|
|
21
|
+
|
|
22
|
+
### Performance and Compatibility
|
|
23
|
+
|
|
24
|
+
I have not run any benchmarks, but the use of immutable Data classes and the
|
|
25
|
+
removal of a number of inner loop conditionals related to encoding and String
|
|
26
|
+
handling (which have been unnecessary since at least Ruby 2.1 but kept for
|
|
27
|
+
strict compatibility) should allow better optimization by modern Ruby
|
|
28
|
+
implementations.
|
|
29
|
+
|
|
30
|
+
If you are using RSpec for your test suite, you are unlikely to be able to use
|
|
31
|
+
Diff::LCS 2.0 because of the minimum Ruby version unless the developers of RSpec
|
|
32
|
+
loosen their version constraints. I cannot control this and have raised
|
|
33
|
+
[rspec/rspec#290][rspec-issue-290].
|
|
34
|
+
|
|
35
|
+
## Synopsis
|
|
36
|
+
|
|
37
|
+
Using this module is quite simple. By default, Diff::LCS does not extend objects
|
|
38
|
+
with the Diff::LCS interface, but will be called as if it were a function:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
require 'diff/lcs'
|
|
42
|
+
|
|
43
|
+
seq1 = %w(a b c e h j l m n p)
|
|
44
|
+
seq2 = %w(b c d e f j k l m r s t)
|
|
45
|
+
|
|
46
|
+
lcs = Diff::LCS.LCS(seq1, seq2)
|
|
47
|
+
diffs = Diff::LCS.diff(seq1, seq2)
|
|
48
|
+
sdiff = Diff::LCS.sdiff(seq1, seq2)
|
|
49
|
+
seq = Diff::LCS.traverse_sequences(seq1, seq2, callback_obj)
|
|
50
|
+
bal = Diff::LCS.traverse_balanced(seq1, seq2, callback_obj)
|
|
51
|
+
seq2 == Diff::LCS.patch!(seq1, diffs)
|
|
52
|
+
seq1 == Diff::LCS.unpatch!(seq2, diffs)
|
|
53
|
+
seq2 == Diff::LCS.patch!(seq1, sdiff)
|
|
54
|
+
seq1 == Diff::LCS.unpatch!(seq2, sdiff)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Objects can be extended with Diff::LCS:
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
seq1.extend(Diff::LCS)
|
|
61
|
+
lcs = seq1.lcs(seq2)
|
|
62
|
+
diffs = seq1.diff(seq2)
|
|
63
|
+
sdiff = seq1.sdiff(seq2)
|
|
64
|
+
seq = seq1.traverse_sequences(seq2, callback_obj)
|
|
65
|
+
bal = seq1.traverse_balanced(seq2, callback_obj)
|
|
66
|
+
seq2 == seq1.patch!(diffs)
|
|
67
|
+
seq1 == seq2.unpatch!(diffs)
|
|
68
|
+
seq2 == seq1.patch!(sdiff)
|
|
69
|
+
seq1 == seq2.unpatch!(sdiff)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
By requiring 'diff/lcs/array' or 'diff/lcs/string', Array or String will be
|
|
73
|
+
extended for use this way.
|
|
74
|
+
|
|
75
|
+
Note that Diff::LCS requires a sequenced enumerable container, which means that
|
|
76
|
+
the order of enumeration is both predictable and consistent for the same set of
|
|
77
|
+
data. While it is theoretically possible to generate a diff for an unordered
|
|
78
|
+
hash, it will only be meaningful if the enumeration of the hashes is consistent.
|
|
79
|
+
In general, this will mean that containers that behave like String or Array will
|
|
80
|
+
perform best.
|
|
81
|
+
|
|
82
|
+
## History
|
|
83
|
+
|
|
84
|
+
Diff::LCS is a port of Perl's Algorithm::Diff that uses the McIlroy-Hunt longest
|
|
85
|
+
common subsequence (LCS) algorithm to compute intelligent differences between
|
|
86
|
+
two sequenced enumerable containers. The implementation is based on Mario I.
|
|
87
|
+
Wolczko's [Smalltalk version 1.2][smalltalk] (1993) and Ned Konz's Perl version
|
|
88
|
+
[Algorithm::Diff 1.15][perl]. `Diff::LCS#sdiff` and
|
|
89
|
+
`Diff::LCS#traverse_balanced` were originally written for the Perl version by
|
|
90
|
+
Mike Schilli.
|
|
91
|
+
|
|
92
|
+
The algorithm is described in <em>A Fast Algorithm for Computing Longest Common
|
|
93
|
+
Subsequences</em>, CACM, vol.20, no.5, pp.350-353, May 1977, with a few minor
|
|
94
|
+
improvements to improve the speed. A simplified description of the algorithm,
|
|
95
|
+
originally written for the Perl version, was written by Mark-Jason Dominus.
|
|
96
|
+
|
|
97
|
+
[ci-workflow]: https://github.com/halostatue/diff-lcs/actions/workflows/ci.yml
|
|
98
|
+
[coveralls]: https://coveralls.io/github/halostatue/diff-lcs?branch=main
|
|
99
|
+
[perl]: https://search.cpan.org/~nedkonz/Algorithm-Diff-1.15/
|
|
100
|
+
[rspec-issue-290]: https://github.com/rspec/rspec/issues/290
|
|
101
|
+
[rubygems]: https://rubygems.org/gems/diff-lcs
|
|
102
|
+
[shield-ci]: https://img.shields.io/github/actions/workflow/status/halostatue/diff-lcs/ci.yml?style=for-the-badge "Build Status"
|
|
103
|
+
[shield-coveralls]: https://img.shields.io/coverallsCoverage/github/halostatue/diff-lcs?style=for-the-badge
|
|
104
|
+
[shield-gems]: https://img.shields.io/gem/v/diff-lcs?style=for-the-badge "Version"
|
|
105
|
+
[smalltalk]: ftp://st.cs.uiuc.edu/pub/Smalltalk/MANCHESTER/manchester/4.0/diff.st
|