ruby-changes:58131
From: bronzdoc <ko1@a...>
Date: Sat, 5 Oct 2019 11:08:46 +0900 (JST)
Subject: [ruby-changes:58131] b659c1b92f (master): [rubygems/rubygems] Add Gem::Dependency#identity method
https://git.ruby-lang.org/ruby.git/commit/?id=b659c1b92f From b659c1b92f3d5f251a3436073cd60d955d5fc457 Mon Sep 17 00:00:00 2001 From: bronzdoc <lsagastume1990@g...> Date: Sun, 29 Sep 2019 08:41:49 -0600 Subject: [rubygems/rubygems] Add Gem::Dependency#identity method https://github.com/rubygems/rubygems/commit/05146bb2fd diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index b09a5fe..0c58815 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -334,4 +334,18 @@ class Gem::Dependency https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency.rb#L334 matches.first end + def identity + if prerelease? + if specific? + :complete + else + :abs_latest + end + elsif latest_version? + :latest + else + :released + end + end + end diff --git a/test/rubygems/test_gem_dependency.rb b/test/rubygems/test_gem_dependency.rb index bf2f065..0caab10 100644 --- a/test/rubygems/test_gem_dependency.rb +++ b/test/rubygems/test_gem_dependency.rb @@ -385,4 +385,11 @@ class TestGemDependency < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_dependency.rb#L385 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/