Skip to content

Commit

Permalink
Add Gem::Dependency#identity method
Browse files Browse the repository at this point in the history
  • Loading branch information
bronzdoc committed Sep 29, 2019
1 parent 3c276a2 commit 05146bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/rubygems/dependency.rb
Expand Up @@ -334,4 +334,18 @@ def to_spec
matches.first
end

def identity
if prerelease?
if specific?
:complete
else
:abs_latest
end
elsif latest_version?
:latest
else
:released
end
end

end
7 changes: 7 additions & 0 deletions test/rubygems/test_gem_dependency.rb
Expand Up @@ -385,4 +385,11 @@ def test_to_specs_indicates_total_gem_set_size
assert_match "Could not find 'b' (= 2.0) among 1 total gem(s)", e.message
end

def test_identity
assert_equal dep("a", "= 1").identity, :released
assert_equal dep("a", "= 1.a").identity, :complete
assert_equal dep("a", " >= 1.a").identity, :abs_latest
assert_equal dep("a").identity, :latest
end

end

0 comments on commit 05146bb

Please sign in to comment.