Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

**Note:** This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.1] - 2025-03-27
### Fixed
- Fixed a global namespace collision with diff-lcs over the `Diff` constant

### Added
- Loading `invoca/utils/diff` now gives access to both `invoca-utils` and `diff-lcs` diff helpers

## [0.6.0] - 2024-07-10
### Added
- Require Ruby > 3.1
Expand Down
5 changes: 3 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
invoca-utils (0.6.0)
activesupport (>= 6.0)
diff-lcs (>= 1.6.1)

GEM
remote: https://rubygems.org/
Expand All @@ -27,7 +28,7 @@ GEM
bigdecimal (3.1.8)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
diff-lcs (1.5.1)
diff-lcs (1.6.1)
drb (2.2.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
Expand All @@ -40,7 +41,7 @@ GEM
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
Expand Down
1 change: 1 addition & 0 deletions invoca-utils.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 3.1"

spec.add_dependency "activesupport", ">= 6.0"
spec.add_dependency "diff-lcs", ">= 1.6.1"

# Specify this gem's development and test dependencies in Gemfile
end
4 changes: 1 addition & 3 deletions lib/invoca/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ module Utils
require "invoca/utils/guaranteed_utf8_string"
require "invoca/utils/version"

unless defined?(Diff)
Diff = Invoca::Utils::Diff
end
Diff = Invoca::Utils::Diff
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the side-effect of adding a "previously initialized constant" warning to the logs whenever invoca-utils is loaded. See the demo for an example. Is that amount of noise a deal breaker?


unless defined?(Diffable)
Diffable = Invoca::Utils::Diffable
Expand Down
4 changes: 4 additions & 0 deletions lib/invoca/utils/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

# adapted from http://users.cybercity.dk/~dsl8950/ruby/diff-0.3.tar.gz

require "diff/lcs"

module Invoca
module Utils
class Diff

LCS = ::Diff::LCS

VERSION = 0.3

def self.lcs(a, b)
Expand Down
9 changes: 7 additions & 2 deletions spec/unit/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@
load 'invoca/utils.rb'
end

it "not define Diff as Invoca::Utils::Diff" do
expect(@class).to eq(::Diff)
it "define Diff as Invoca::Utils::Diff" do
expect(Invoca::Utils::Diff).to eq(::Diff)
end

it "still allows access to diff-lcs methods" do
expect(defined?(Diff::LCS)).to eq("constant")
expect(Diff::LCS).to respond_to(:diff)
end
end

Expand Down