Skip to content

Commit

Permalink
Merge pull request #58 from halostatue/fix-issue-57
Browse files Browse the repository at this point in the history
Fix an issue with negative hunk max_size
  • Loading branch information
halostatue committed Jun 23, 2020
2 parents 4168a8e + 4ccda50 commit cef2f82
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -60,4 +60,4 @@ jobs:
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rake
run: bundle exec ruby -S rake
11 changes: 0 additions & 11 deletions Rakefile
Expand Up @@ -24,22 +24,11 @@ _spec = Hoe.spec 'diff-lcs' do
extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
extra_dev_deps << ['hoe-git', '~> 1.6']
extra_dev_deps << ['hoe-rubygems', '~> 1.0']
extra_dev_deps << ['hoe-travis', '~> 1.2']
extra_dev_deps << ['rspec', '>= 2.0', '< 4']
extra_dev_deps << ['rake', '>= 10.0', '< 14']
extra_dev_deps << ['rdoc', '>= 0']
end

require "rspec/core/rake_task"

desc "Run all specifications"
RSpec::Core::RakeTask.new(:spec) do |t|
rspec_dirs = %w(spec lib)
t.rspec_opts = []
t.rspec_opts << "-I#{rspec_dirs.join(":")}" unless rspec_dirs.empty?
end
task :default => :spec

if RUBY_VERSION >= '2.0' && RUBY_ENGINE == 'ruby'
namespace :spec do
desc "Runs test coverage. Only works Ruby 2.0+ and assumes 'simplecov' is installed."
Expand Down
11 changes: 4 additions & 7 deletions diff-lcs.gemspec
@@ -1,16 +1,16 @@
# -*- encoding: utf-8 -*-
# stub: diff-lcs 1.4 ruby lib
# stub: diff-lcs 1.4.1 ruby lib

Gem::Specification.new do |s|
s.name = "diff-lcs".freeze
s.version = "1.4"
s.version = "1.4.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.metadata = { "bug_tracker_uri" => "https://github.com/halostatue/diff-lcs/issues", "homepage_uri" => "https://github.com/halostatue/diff-lcs", "source_code_uri" => "https://github.com/halostatue/diff-lcs" } if s.respond_to? :metadata=
s.require_paths = ["lib".freeze]
s.authors = ["Austin Ziegler".freeze]
s.date = "2020-06-22"
s.description = "Diff::LCS computes the difference between two Enumerable sequences using the\nMcIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities\nto create a simple HTML diff output format and a standard diff-like tool.\n\nThis is release 1.4, providing a simple extension that allows for\nDiff::LCS::Change objects to be treated implicitly as arrays. Ruby versions\nbelow 2.3 are soft-deprecated.\n\nThis means that older versions are no longer part of the CI test suite. If any\nchanges have been introduced that break those versions, bug reports and patches\nwill be accepted, but it will be up to the reporter to verify any fixes prior\nto release. A future release will completely break compatibility.".freeze
s.date = "2020-06-23"
s.description = "Diff::LCS computes the difference between two Enumerable sequences using the\nMcIlroy-Hunt longest common subsequence (LCS) algorithm. It includes utilities\nto create a simple HTML diff output format and a standard diff-like tool.\n\nThis is release 1.4, providing a simple extension that allows for\nDiff::LCS::Change objects to be treated implicitly as arrays. Ruby versions\nbelow 2.5 are soft-deprecated.\n\nThis means that older versions are no longer part of the CI test suite. If any\nchanges have been introduced that break those versions, bug reports and patches\nwill be accepted, but it will be up to the reporter to verify any fixes prior\nto release. A future release will completely break compatibility.".freeze
s.email = ["halostatue@gmail.com".freeze]
s.executables = ["htmldiff".freeze, "ldiff".freeze]
s.extra_rdoc_files = ["Code-of-Conduct.md".freeze, "Contributing.md".freeze, "History.md".freeze, "License.md".freeze, "Manifest.txt".freeze, "README.rdoc".freeze, "docs/COPYING.txt".freeze, "docs/artistic.txt".freeze]
Expand All @@ -30,7 +30,6 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<hoe-gemspec2>.freeze, ["~> 1.1"])
s.add_development_dependency(%q<hoe-git>.freeze, ["~> 1.6"])
s.add_development_dependency(%q<hoe-rubygems>.freeze, ["~> 1.0"])
s.add_development_dependency(%q<hoe-travis>.freeze, ["~> 1.2"])
s.add_development_dependency(%q<rspec>.freeze, [">= 2.0", "< 4"])
s.add_development_dependency(%q<rake>.freeze, [">= 10.0", "< 14"])
s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
Expand All @@ -40,7 +39,6 @@ Gem::Specification.new do |s|
s.add_dependency(%q<hoe-gemspec2>.freeze, ["~> 1.1"])
s.add_dependency(%q<hoe-git>.freeze, ["~> 1.6"])
s.add_dependency(%q<hoe-rubygems>.freeze, ["~> 1.0"])
s.add_dependency(%q<hoe-travis>.freeze, ["~> 1.2"])
s.add_dependency(%q<rspec>.freeze, [">= 2.0", "< 4"])
s.add_dependency(%q<rake>.freeze, [">= 10.0", "< 14"])
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
Expand All @@ -51,7 +49,6 @@ Gem::Specification.new do |s|
s.add_dependency(%q<hoe-gemspec2>.freeze, ["~> 1.1"])
s.add_dependency(%q<hoe-git>.freeze, ["~> 1.6"])
s.add_dependency(%q<hoe-rubygems>.freeze, ["~> 1.0"])
s.add_dependency(%q<hoe-travis>.freeze, ["~> 1.2"])
s.add_dependency(%q<rspec>.freeze, [">= 2.0", "< 4"])
s.add_dependency(%q<rake>.freeze, [">= 10.0", "< 14"])
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
Expand Down
2 changes: 1 addition & 1 deletion lib/diff/lcs.rb
Expand Up @@ -49,7 +49,7 @@ module Diff; end unless defined? Diff # rubocop:disable Style/Documentation
# a x b y c z p d q
# a b c a x b y c z
module Diff::LCS
VERSION = '1.4'
VERSION = '1.4.1'
end

require 'diff/lcs/callbacks'
Expand Down
2 changes: 1 addition & 1 deletion lib/diff/lcs/block.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(chunk)
end

def diff_size
@insert.size - @remove.size
(@insert.size - @remove.size).abs
end

def op
Expand Down
10 changes: 10 additions & 0 deletions spec/issues_spec.rb
Expand Up @@ -54,4 +54,14 @@
]
end
end

describe "issue #57" do
it 'should fail with a correct error' do
expect {
actual = {:category=>"app.rack.request"}
expected = {:category=>"rack.middleware", :title=>"Anonymous Middleware"}
expect(actual).to eq(expected)
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end
end
end
14 changes: 8 additions & 6 deletions spec/ldiff_spec.rb
Expand Up @@ -36,12 +36,14 @@ def read_fixture(flag = nil)
end

def clean_data(data, flag)
case flag
when '-c', '-u'
clean_output_timestamp(data)
else
data
end
data =
case flag
when '-c', '-u'
clean_output_timestamp(data)
else
data
end
data.gsub(/\r\n?/, "\n")
end

def clean_output_timestamp(data)
Expand Down

0 comments on commit cef2f82

Please sign in to comment.