1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Add Gem::Dependency#identity method

https://github.com/rubygems/rubygems/commit/05146bb2fd
This commit is contained in:
bronzdoc 2019-09-29 08:41:49 -06:00 committed by Nobuyoshi Nakada
parent 871005bdd2
commit b659c1b92f
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 21 additions and 0 deletions

View file

@ -334,4 +334,18 @@ class Gem::Dependency
matches.first
end
def identity
if prerelease?
if specific?
:complete
else
:abs_latest
end
elsif latest_version?
:latest
else
:released
end
end
end

View file

@ -385,4 +385,11 @@ class TestGemDependency < Gem::TestCase
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