Skip to content

Commit

Permalink
Remove trimming of space from requirements
Browse files Browse the repository at this point in the history
also fixes token used for split.
rubygems.org (Dependency) and rubygems (Gem::Requirement) use `, `
to join list of requirements.

updated dep test to capture intended behaviour of preserving space
in requirements.
  • Loading branch information
sonalkr132 committed May 25, 2020
1 parent 4d2c3ee commit 5e581e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/compact_index/gem_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def deps_line
end

def join_multiple(requirements)
requirements.gsub(/[[:space:]]/, "").split(",").sort.join("&")
requirements.split(", ").sort.join("&")
end
end
end
6 changes: 3 additions & 3 deletions spec/compact_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
it "dependencies have platform" do
param = [build_version(:number => "1.0.1", :dependencies => [
CompactIndex::Dependency.new("a", "=1.1", "jruby", "abc123"),
CompactIndex::Dependency.new("b", "=1.2", "darwin-13", "abc123"),
CompactIndex::Dependency.new("b", "= 1.2", "darwin-13", "abc123"),
])]
expect(CompactIndex.info(param)).to eq("---\n1.0.1 a:=1.1-jruby,b:=1.2-darwin-13|checksum:sum+test_gem+1.0.1\n")
expect(CompactIndex.info(param)).to eq("---\n1.0.1 a:=1.1-jruby,b:= 1.2-darwin-13|checksum:sum+test_gem+1.0.1\n")
end

it "show ruby required version" do
Expand All @@ -95,7 +95,7 @@

it "show ruby required version with multiple requirements" do
param = [build_version(:number => "1.0.1", :ruby_version => "< 2.5, >=2.2")]
expect(CompactIndex.info(param)).to eq("---\n1.0.1 |checksum:sum+test_gem+1.0.1,ruby:<2.5&>=2.2\n")
expect(CompactIndex.info(param)).to eq("---\n1.0.1 |checksum:sum+test_gem+1.0.1,ruby:< 2.5&>=2.2\n")
end

it "show rubygems required version" do
Expand Down

0 comments on commit 5e581e8

Please sign in to comment.