diff-lcs 1.6.0 → 1.6.2

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/CONTRIBUTING.md +9 -12
  4. data/CONTRIBUTORS.md +1 -0
  5. data/LICENCE.md +15 -16
  6. data/Manifest.txt +54 -1
  7. data/README.md +1 -1
  8. data/Rakefile +44 -27
  9. data/lib/diff/lcs/backports.rb +4 -0
  10. data/lib/diff/lcs/change.rb +2 -2
  11. data/lib/diff/lcs/htmldiff.rb +3 -3
  12. data/lib/diff/lcs/ldiff.rb +14 -8
  13. data/lib/diff/lcs/version.rb +7 -0
  14. data/lib/diff/lcs.rb +3 -3
  15. data/mise.toml +5 -0
  16. data/spec/fixtures/123_x +2 -0
  17. data/spec/fixtures/456_x +2 -0
  18. data/spec/fixtures/empty +0 -0
  19. data/spec/fixtures/file1.bin +0 -0
  20. data/spec/fixtures/file2.bin +0 -0
  21. data/spec/fixtures/four_lines +4 -0
  22. data/spec/fixtures/four_lines_with_missing_new_line +4 -0
  23. data/spec/fixtures/ldiff/diff.missing_new_line1-e +1 -0
  24. data/spec/fixtures/ldiff/diff.missing_new_line1-f +1 -0
  25. data/spec/fixtures/ldiff/diff.missing_new_line2-e +1 -0
  26. data/spec/fixtures/ldiff/diff.missing_new_line2-f +1 -0
  27. data/spec/fixtures/ldiff/error.diff.chef-e +2 -0
  28. data/spec/fixtures/ldiff/error.diff.chef-f +2 -0
  29. data/spec/fixtures/ldiff/error.diff.missing_new_line1-e +1 -0
  30. data/spec/fixtures/ldiff/error.diff.missing_new_line1-f +1 -0
  31. data/spec/fixtures/ldiff/error.diff.missing_new_line2-e +1 -0
  32. data/spec/fixtures/ldiff/error.diff.missing_new_line2-f +1 -0
  33. data/spec/fixtures/ldiff/output.diff.bin1 +0 -0
  34. data/spec/fixtures/ldiff/output.diff.bin1-c +0 -0
  35. data/spec/fixtures/ldiff/output.diff.bin1-e +0 -0
  36. data/spec/fixtures/ldiff/output.diff.bin1-f +0 -0
  37. data/spec/fixtures/ldiff/output.diff.bin1-u +0 -0
  38. data/spec/fixtures/ldiff/output.diff.bin2 +1 -0
  39. data/spec/fixtures/ldiff/output.diff.bin2-c +1 -0
  40. data/spec/fixtures/ldiff/output.diff.bin2-e +1 -0
  41. data/spec/fixtures/ldiff/output.diff.bin2-f +1 -0
  42. data/spec/fixtures/ldiff/output.diff.bin2-u +1 -0
  43. data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines +5 -0
  44. data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-c +9 -0
  45. data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-e +6 -0
  46. data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-f +6 -0
  47. data/spec/fixtures/ldiff/output.diff.empty.vs.four_lines-u +7 -0
  48. data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty +5 -0
  49. data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-c +9 -0
  50. data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-e +1 -0
  51. data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-f +1 -0
  52. data/spec/fixtures/ldiff/output.diff.four_lines.vs.empty-u +7 -0
  53. data/spec/fixtures/ldiff/output.diff.issue95_trailing_context +4 -0
  54. data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-c +9 -0
  55. data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-e +3 -0
  56. data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-f +3 -0
  57. data/spec/fixtures/ldiff/output.diff.issue95_trailing_context-u +6 -0
  58. data/spec/fixtures/ldiff/output.diff.missing_new_line1 +5 -0
  59. data/spec/fixtures/ldiff/output.diff.missing_new_line1-c +14 -0
  60. data/spec/fixtures/ldiff/output.diff.missing_new_line1-e +0 -0
  61. data/spec/fixtures/ldiff/output.diff.missing_new_line1-f +0 -0
  62. data/spec/fixtures/ldiff/output.diff.missing_new_line1-u +9 -0
  63. data/spec/fixtures/ldiff/output.diff.missing_new_line2 +5 -0
  64. data/spec/fixtures/ldiff/output.diff.missing_new_line2-c +14 -0
  65. data/spec/fixtures/ldiff/output.diff.missing_new_line2-e +0 -0
  66. data/spec/fixtures/ldiff/output.diff.missing_new_line2-f +0 -0
  67. data/spec/fixtures/ldiff/output.diff.missing_new_line2-u +9 -0
  68. data/spec/spec_helper.rb +93 -93
  69. metadata +67 -63
  70. data/Contributing.md +0 -74
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5809a8a19bbbf227168d81fa0dcfe681aff17a494b16cd6af723f7dd665ed0d0
4
- data.tar.gz: 844c07fe8cdc69183f0c0bb8f16cdfadae58d099eb3ab5927ac2aa9b50133948
3
+ metadata.gz: 34fc249139fb5ed40b525cf33d8e4e3d3702384f74d1e67e63d8eed54a09133c
4
+ data.tar.gz: 46739e6b242db46dd6d01c4bb26d7c51fc07ccaebd7ecd58c305d758f30dfc33
5
5
  SHA512:
6
- metadata.gz: 219465ac1abcd2636a39e4425a0a84d64759b6818fa7b885ebfdd941af52344658568b52485c343e74b6dab7a300cf2109a38094ff94aca3f51bef31a3e13987
7
- data.tar.gz: '082bd353ec1fb53cb848a435162ed9dd152f526cab697353de8fd8b9b319fdd319d90a7b1ec45f1259f2cf525fe81aba88f892c43712ff92d09da411391ace76'
6
+ metadata.gz: c482d6b11cb38b840ee4a4c11785c592a7a537e5f855cca99739a578e8d833b05ad43cba4ac8e40e4ae1fa876633d9d96c18c29acef63bf72532c352d98b05e6
7
+ data.tar.gz: 7c6da2681b6a2ddf4ebda85deb24aeaeea29218cfa452d40717e1963c117c95230da2c01c18b806cb0916a804263aa7ac0230c4adcbb8fb1b30a95faee5a4dda
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.2 / 2025-05-12
4
+
5
+ - Handle upcoming changes to the `cgi` gem in Ruby 3.5 ([#147][pull-147])
6
+
7
+ - Fix issues found with `htmldiff` in Ruby 1.8 (which is used approximately
8
+ never, since the code change which broke Ruby 1.8 was made 6 years ago).
9
+ [#148][pull-148]
10
+
11
+ - Fixed some standardrb formatting and configuration issues.
12
+
13
+ ## 1.6.1 / 2025-03-25
14
+
15
+ - Performed further work on `Diff::LCS::Ldiff` improvements ([#46][issue-46])
16
+ and resolve several thread safety issues cleanly by making it a class.
17
+ [#129][pull-129]
18
+
19
+ - Restructure the project to be more consistent with the rest of the projects
20
+ that I manage.
21
+
22
+ - Increased GitHub action security.
23
+
24
+ - Added [trusted publishing][tp] for fully automated releases.
25
+
3
26
  ## 1.6.0 / 2025-02-13
4
27
 
5
28
  - Baptiste Courtois (@annih) has done significant work on making `bin/ldiff`
@@ -481,6 +504,9 @@
481
504
  [pull-103]: https://github.com/halostatue/diff-lcs/pull/103
482
505
  [pull-104]: https://github.com/halostatue/diff-lcs/pull/104
483
506
  [pull-105]: https://github.com/halostatue/diff-lcs/pull/105
507
+ [pull-129]: https://github.com/halostatue/diff-lcs/pull/129
508
+ [pull-147]: https://github.com/halostatue/diff-lcs/pull/147
509
+ [pull-148]: https://github.com/halostatue/diff-lcs/pull/148
484
510
  [rspec-expectations#200]: https://github.com/rspec/rspec-expectations/pull/200
485
511
  [rspec-expectations#219]: https://github.com/rspec/rspec-expectations/issues/219
486
512
  [rspec-expectations#238]: https://github.com/rspec/rspec-expectations/issues/238
@@ -489,3 +515,4 @@
489
515
  [rubinius#2268]: https://github.com/rubinius/rubinius/issues/2268
490
516
  [standard ruby]: https://github.com/standardrb/standard
491
517
  [tidelift]: https://tidelift.com/security
518
+ [tp]: https://guides.rubygems.org/trusted-publishing/
data/CONTRIBUTING.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Contribution to diff-lcs is encouraged in any form: a bug report, a feature
4
4
  request, or code contributions. There are a few DOs and DON'Ts for
5
+ contributions.
5
6
 
6
7
  - DO:
7
8
 
@@ -17,16 +18,19 @@ request, or code contributions. There are a few DOs and DON'Ts for
17
18
  `CHANGELOG.md` as a separate commit from your main change. (Follow the style
18
19
  in the `CHANGELOG.md` and provide a link to your PR.)
19
20
 
20
- - Add or update tests, written in [RSpec][rspec], as appropriate.
21
+ - Add or update tests as appropriate for your change. The test suite is
22
+ written in [RSpec][rspec].
21
23
 
22
- - Add or update documentation, as appropriate.
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.
23
27
 
24
28
  - DO NOT:
25
29
 
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.
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.
28
32
 
29
- - Modify `diff-lcs.gemspect`; it is a generated file. (You _may_ use
33
+ - Modify `diff-lcs.gemspec`; it is a generated file. (You _may_ use
30
34
  `rake gemspec` to regenerate it if your change involves metadata related to
31
35
  gem itself).
32
36
 
@@ -60,13 +64,6 @@ Here's the most direct way to get your work merged into the project:
60
64
  - Create a pull request against halostatue/diff-lcs and describe what your
61
65
  change does and the why you think it should be merged.
62
66
 
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
67
  [hoe]: https://github.com/seattlerb/hoe
71
68
  [qcm]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
72
69
  [release-gem]: https://github.com/rubygems/release-gem
data/CONTRIBUTORS.md CHANGED
@@ -14,6 +14,7 @@ Thanks to everyone else who has contributed to diff-lcs over the years:
14
14
  - Baptiste Courtois (@annih)
15
15
  - Camille Drapier
16
16
  - Cédric Boutillier
17
+ - @earlopain
17
18
  - Gregg Kellogg
18
19
  - Jagdeep Singh
19
20
  - Jason Gladish
data/LICENCE.md CHANGED
@@ -1,15 +1,15 @@
1
- # License
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
- same terms as Perl itself") and given that the Ruby implementation originally
8
- hewed pretty closely to the Perl version, I must maintain the additional
9
- licensing terms.
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
- * Copyright 2004–2013 Austin Ziegler.
12
- * Adapted from Algorithm::Diff (Perl) by Ned Konz and a Smalltalk version by
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
- of the Software, and to permit persons to whom the Software is furnished to do
22
- so, subject to the following conditions:
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
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
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
@@ -3,7 +3,6 @@ CHANGELOG.md
3
3
  CODE_OF_CONDUCT.md
4
4
  CONTRIBUTING.md
5
5
  CONTRIBUTORS.md
6
- Contributing.md
7
6
  LICENCE.md
8
7
  Manifest.txt
9
8
  README.md
@@ -25,17 +24,46 @@ lib/diff/lcs/hunk.rb
25
24
  lib/diff/lcs/internals.rb
26
25
  lib/diff/lcs/ldiff.rb
27
26
  lib/diff/lcs/string.rb
27
+ lib/diff/lcs/version.rb
28
+ mise.toml
28
29
  spec/change_spec.rb
29
30
  spec/diff_spec.rb
31
+ spec/fixtures/123_x
32
+ spec/fixtures/456_x
30
33
  spec/fixtures/aX
31
34
  spec/fixtures/bXaX
32
35
  spec/fixtures/ds1.csv
33
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
34
52
  spec/fixtures/ldiff/output.diff
35
53
  spec/fixtures/ldiff/output.diff-c
36
54
  spec/fixtures/ldiff/output.diff-e
37
55
  spec/fixtures/ldiff/output.diff-f
38
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
39
67
  spec/fixtures/ldiff/output.diff.chef
40
68
  spec/fixtures/ldiff/output.diff.chef-c
41
69
  spec/fixtures/ldiff/output.diff.chef-e
@@ -47,6 +75,31 @@ spec/fixtures/ldiff/output.diff.chef2-d
47
75
  spec/fixtures/ldiff/output.diff.chef2-e
48
76
  spec/fixtures/ldiff/output.diff.chef2-f
49
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
50
103
  spec/fixtures/new-chef
51
104
  spec/fixtures/new-chef2
52
105
  spec/fixtures/old-chef
data/README.md CHANGED
@@ -16,7 +16,7 @@ Diff::LCS computes the difference between two Enumerable sequences using the
16
16
  McIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities
17
17
  to create a simple HTML diff output format and a standard diff-like tool.
18
18
 
19
- This is release 1.4.3, providing a simple extension that allows for
19
+ This is release 1.6.1, providing a simple extension that allows for
20
20
  Diff::LCS::Change objects to be treated implicitly as arrays and fixes a number
21
21
  of formatting issues.
22
22
 
data/Rakefile CHANGED
@@ -4,12 +4,18 @@ require "rspec/core/rake_task"
4
4
  require "hoe"
5
5
  require "rake/clean"
6
6
 
7
- Hoe.plugin :cov
8
- Hoe.plugin :doofus
9
- Hoe.plugin :gemspec2
10
- Hoe.plugin :git2
7
+ MAINTENANCE = ENV["MAINTENANCE"] == "true"
8
+ BUILD_DOCS = MAINTENANCE || ENV["DOCS"] == "true"
9
+ TRUSTED_RELEASE = ENV["rubygems_release_gem"] == "true"
10
+
11
+ Hoe.plugin :halostatue
11
12
  Hoe.plugin :rubygems
12
13
 
14
+ Hoe.plugins.delete :debug
15
+ Hoe.plugins.delete :newb
16
+ Hoe.plugins.delete :signing
17
+ Hoe.plugins.delete :publish unless BUILD_DOCS
18
+
13
19
  if RUBY_VERSION < "1.9"
14
20
  class Array # :nodoc:
15
21
  def to_h
@@ -35,33 +41,45 @@ end
35
41
  _spec = Hoe.spec "diff-lcs" do
36
42
  developer("Austin Ziegler", "halostatue@gmail.com")
37
43
 
44
+ self.trusted_release = TRUSTED_RELEASE
45
+
46
+ require_ruby_version ">= 1.8"
47
+
38
48
  self.history_file = "CHANGELOG.md"
39
49
  self.readme_file = "README.md"
40
50
  self.licenses = ["MIT", "Artistic-1.0-Perl", "GPL-2.0-or-later"]
41
51
 
42
- require_ruby_version ">= 1.8"
43
-
44
52
  spec_extras[:metadata] = ->(val) {
45
53
  val["rubygems_mfa_required"] = "true"
46
- val["changelog_uri"] = "https://github.com/halostatue/diff-lcs/blob/main/CHANGELOG.md"
47
54
  }
48
55
 
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"]
56
+ extra_dev_deps << ["hoe", "~> 4.0"]
57
+ extra_dev_deps << ["hoe-halostatue", "~> 2.0"]
53
58
  extra_dev_deps << ["hoe-rubygems", "~> 1.0"]
54
59
  extra_dev_deps << ["rspec", ">= 2.0", "< 4"]
55
60
  extra_dev_deps << ["rake", ">= 10.0", "< 14"]
56
61
  extra_dev_deps << ["rdoc", ">= 6.3.1", "< 7"]
57
62
  end
58
63
 
64
+ if BUILD_DOCS
65
+ rake_tasks = Rake.application.instance_variable_get(:@tasks)
66
+ tasks = ["publish_docs", "publish_on_announce", "debug_email", "post_blog", "announce"]
67
+ tasks.each do |task|
68
+ rake_tasks.delete(task)
69
+ end
70
+ end
71
+
59
72
  desc "Run all specifications"
60
73
  RSpec::Core::RakeTask.new(:spec) do |t|
61
74
  rspec_dirs = %w[spec lib].join(":")
62
75
  t.rspec_opts = ["-I#{rspec_dirs}"]
63
76
  end
64
77
 
78
+ task :version do
79
+ require "diff/lcs/version"
80
+ puts Diff::LCS::VERSION
81
+ end
82
+
65
83
  Rake::Task["spec"].actions.uniq! { |a| a.source_location }
66
84
 
67
85
  # standard:disable Style/HashSyntax
@@ -69,30 +87,29 @@ task :default => :spec unless Rake::Task["default"].prereqs.include?("spec")
69
87
  task :test => :spec unless Rake::Task["test"].prereqs.include?("spec")
70
88
  # standard:enable Style/HashSyntax
71
89
 
72
- if RUBY_VERSION >= "2.0" && RUBY_ENGINE == "ruby"
90
+ if RUBY_VERSION >= "3.0" && RUBY_ENGINE == "ruby"
73
91
  namespace :spec do
74
92
  desc "Runs test coverage. Only works Ruby 2.0+ and assumes 'simplecov' is installed."
75
93
  task :coverage do
76
- ENV["COVERAGE"] = "yes"
94
+ ENV["COVERAGE"] = "true"
77
95
  Rake::Task["spec"].execute
78
96
  end
79
97
  end
80
98
  end
81
99
 
82
- task :ruby18 do
83
- # standard:disable Layout/HeredocIndentation
84
- puts <<-MESSAGE
85
- You are starting a barebones Ruby 1.8 docker environment. You will need to
86
- do the following:
87
-
88
- - mv Gemfile.lock{,.v2}
89
- - gem install bundler --version 1.17.2 --no-ri --no-rdoc
90
- - ruby -S bundle
91
- - rake
100
+ if MAINTENANCE
101
+ task ruby18: :package do
102
+ require "diff/lcs/version"
103
+ # standard:disable Layout/HeredocIndentation
104
+ puts <<-MESSAGE
105
+ You are starting a barebones Ruby 1.8 docker environment for testing.
106
+ A snapshot package has been built, so install it with:
92
107
 
93
- Don't forget to restore your Gemfile.lock after testing.
108
+ cd diff-lcs
109
+ gem install pkg/diff-lcs-#{Diff::LCS::VERSION}
94
110
 
95
- MESSAGE
96
- # standard:enable Layout/HeredocIndentation
97
- sh "docker run -it --rm -v #{Dir.pwd}:/root/diff-lcs bellbind/docker-ruby18-rails2 bash -l"
111
+ MESSAGE
112
+ # standard:enable Layout/HeredocIndentation
113
+ sh "docker run -it --rm -v #{Dir.pwd}:/root/diff-lcs bellbind/docker-ruby18-rails2 bash -l"
114
+ end
98
115
  end
@@ -5,5 +5,9 @@ unless 0.respond_to?(:positive?)
5
5
  def positive?
6
6
  self > 0
7
7
  end
8
+
9
+ def negative?
10
+ self < 0
11
+ end
8
12
  end
9
13
  end
@@ -45,9 +45,9 @@ class Diff::LCS::Change
45
45
  arr = arr.flatten(1)
46
46
  case arr.size
47
47
  when 5
48
- Diff::LCS::ContextChange.new(*(arr[0...5]))
48
+ Diff::LCS::ContextChange.new(*arr[0...5])
49
49
  when 3
50
- Diff::LCS::Change.new(*(arr[0...3]))
50
+ Diff::LCS::Change.new(*arr[0...3])
51
51
  else
52
52
  fail "Invalid change array format provided."
53
53
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "cgi"
3
+ require "erb"
4
4
 
5
5
  # Produce a simple HTML diff view.
6
6
  class Diff::LCS::HTMLDiff
@@ -126,8 +126,8 @@ h1 { margin-left: 2em; }
126
126
  @right.map! { |line| formatter.expand(line.chomp) }
127
127
  end
128
128
 
129
- @left.map! { |line| CGI.escapeHTML(line.chomp) }
130
- @right.map! { |line| CGI.escapeHTML(line.chomp) }
129
+ @left.map! { |line| ERB::Util.html_escape(line.chomp) }
130
+ @right.map! { |line| ERB::Util.html_escape(line.chomp) }
131
131
 
132
132
  # standard:disable Layout/HeredocIndentation
133
133
  @options[:output] << <<-OUTPUT
@@ -3,11 +3,11 @@
3
3
  require "optparse"
4
4
  require "diff/lcs/hunk"
5
5
 
6
- module Diff::LCS::Ldiff # :nodoc:
6
+ class Diff::LCS::Ldiff # :nodoc:
7
7
  # standard:disable Layout/HeredocIndentation
8
8
  BANNER = <<-COPYRIGHT
9
9
  ldiff #{Diff::LCS::VERSION}
10
- Copyright 2004-2019 Austin Ziegler
10
+ Copyright 2004-2025 Austin Ziegler
11
11
 
12
12
  Part of Diff::LCS.
13
13
  https://github.com/halostatue/diff-lcs
@@ -24,15 +24,21 @@ ldiff #{Diff::LCS::VERSION}
24
24
  end
25
25
  end
26
26
 
27
- class << self
28
- attr_reader :format, :lines # :nodoc:
29
- attr_reader :file_old, :file_new # :nodoc:
30
- attr_reader :data_old, :data_new # :nodoc:
27
+ attr_reader :format, :lines # :nodoc:
28
+ attr_reader :file_old, :file_new # :nodoc:
29
+ attr_reader :data_old, :data_new # :nodoc:
30
+
31
+ def self.run(args, input = $stdin, output = $stdout, error = $stderr) # :nodoc:
32
+ new.run(args, input, output, error)
31
33
  end
32
34
 
33
- def self.run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
35
+ def initialize
34
36
  @binary = nil
37
+ @format = :old
38
+ @lines = 0
39
+ end
35
40
 
41
+ def run(args, _input = $stdin, output = $stdout, error = $stderr) # :nodoc:
36
42
  args.options do |o|
37
43
  o.banner = "Usage: #{File.basename($0)} [options] oldfile newfile"
38
44
  o.separator ""
@@ -101,7 +107,7 @@ ldiff #{Diff::LCS::VERSION}
101
107
  ) ? 1 : 0
102
108
  end
103
109
 
104
- def self.diff?(info_old, info_new, format, output, binary: nil, lines: 0)
110
+ def diff?(info_old, info_new, format, output, binary: nil, lines: 0)
105
111
  case format
106
112
  when :context
107
113
  char_old = "*" * 3
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Diff
4
+ module LCS
5
+ VERSION = "1.6.2"
6
+ end
7
+ end
data/lib/diff/lcs.rb CHANGED
@@ -49,9 +49,9 @@ module Diff; end unless defined? Diff
49
49
  # a x b y c z p d q
50
50
  # a b c a x b y c z
51
51
  module Diff::LCS
52
- VERSION = "1.6.0"
53
52
  end
54
53
 
54
+ require "diff/lcs/version"
55
55
  require "diff/lcs/callbacks"
56
56
  require "diff/lcs/internals"
57
57
 
@@ -333,7 +333,7 @@ class << Diff::LCS
333
333
  if callbacks.respond_to?(:finished_a) && !run_finished_a
334
334
  ax = string ? seq1[-1, 1] : seq1[-1]
335
335
  bx = string ? seq2[bj, 1] : seq2[bj]
336
- event = Diff::LCS::ContextChange.new(">", (a_size - 1), ax, bj, bx)
336
+ event = Diff::LCS::ContextChange.new(">", a_size - 1, ax, bj, bx)
337
337
  event = yield event if block_given?
338
338
  callbacks.finished_a(event)
339
339
  run_finished_a = true
@@ -355,7 +355,7 @@ class << Diff::LCS
355
355
  if callbacks.respond_to?(:finished_b) && !run_finished_b
356
356
  ax = string ? seq1[ai, 1] : seq1[ai]
357
357
  bx = string ? seq2[-1, 1] : seq2[-1]
358
- event = Diff::LCS::ContextChange.new("<", ai, ax, (b_size - 1), bx)
358
+ event = Diff::LCS::ContextChange.new("<", ai, ax, b_size - 1, bx)
359
359
  event = yield event if block_given?
360
360
  callbacks.finished_b(event)
361
361
  run_finished_b = true
data/mise.toml ADDED
@@ -0,0 +1,5 @@
1
+ [tools]
2
+ ruby = "3.4"
3
+
4
+ [env]
5
+ MAINTENANCE = "true"
@@ -0,0 +1,2 @@
1
+ 123
2
+ x
@@ -0,0 +1,2 @@
1
+ 456
2
+ x
File without changes
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ one
2
+ two
3
+ three
4
+ four
@@ -0,0 +1,4 @@
1
+ one
2
+ two
3
+ three
4
+ four
@@ -0,0 +1 @@
1
+ No newline at end of file
@@ -0,0 +1 @@
1
+ No newline at end of file
@@ -0,0 +1 @@
1
+ No newline at end of file
@@ -0,0 +1 @@
1
+ No newline at end of file
@@ -0,0 +1,2 @@
1
+ <old_file>: No newline at end of file
2
+ <new_file>: No newline at end of file
@@ -0,0 +1,2 @@
1
+ <old_file>: No newline at end of file
2
+ <new_file>: No newline at end of file
@@ -0,0 +1 @@
1
+ <new_file>: No newline at end of file
@@ -0,0 +1 @@
1
+ <new_file>: No newline at end of file
@@ -0,0 +1 @@
1
+ <old_file>: No newline at end of file
@@ -0,0 +1 @@
1
+ <old_file>: No newline at end of file
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
@@ -0,0 +1 @@
1
+ Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
@@ -0,0 +1 @@
1
+ Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
@@ -0,0 +1 @@
1
+ Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
@@ -0,0 +1 @@
1
+ Binary files spec/fixtures/file1.bin and spec/fixtures/file2.bin differ
@@ -0,0 +1,5 @@
1
+ 0a1,4
2
+ > one
3
+ > two
4
+ > three
5
+ > four
@@ -0,0 +1,9 @@
1
+ *** spec/fixtures/empty 2025-01-31 12:14:52.856031635 +0100
2
+ --- spec/fixtures/four_lines 2025-01-31 12:13:45.476036544 +0100
3
+ ***************
4
+ *** 0 ****
5
+ --- 1,4 ----
6
+ + one
7
+ + two
8
+ + three
9
+ + four
@@ -0,0 +1,6 @@
1
+ 0a
2
+ one
3
+ two
4
+ three
5
+ four
6
+ .
@@ -0,0 +1,6 @@
1
+ a0
2
+ one
3
+ two
4
+ three
5
+ four
6
+ .