[rubygems/rubygems] Introduce Gem::Specification.find_by_full_name for finding conbination of name and version for gemspec
https://github.com/rubygems/rubygems/commit/0430551215
This commit is contained in:
parent
fc5482d088
commit
bab809d98f
@ -1021,6 +1021,12 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
Gem::Dependency.new(name, *requirements).to_spec
|
Gem::Dependency.new(name, *requirements).to_spec
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Find the best specification matching a +full_name+.
|
||||||
|
def self.find_by_full_name(full_name)
|
||||||
|
stubs.find {|s| s.full_name == full_name }&.to_spec
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Return the best specification that contains the file matching +path+.
|
# Return the best specification that contains the file matching +path+.
|
||||||
|
|
||||||
|
@ -3726,6 +3726,23 @@ end
|
|||||||
assert Gem::Specification.find_by_name "b", ">1"
|
assert Gem::Specification.find_by_name "b", ">1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_by_full_name
|
||||||
|
pl = Gem::Platform.new "x86_64-linux"
|
||||||
|
|
||||||
|
a = util_spec "a", "1"
|
||||||
|
install_specs a
|
||||||
|
|
||||||
|
a_pl = util_spec("a", "1") {|s| s.platform = pl }
|
||||||
|
install_specs a_pl
|
||||||
|
|
||||||
|
assert_equal a, Gem::Specification.find_by_full_name("a-1")
|
||||||
|
assert_equal a_pl, Gem::Specification.find_by_full_name("a-1-x86_64-linux")
|
||||||
|
|
||||||
|
assert_nil Gem::Specification.find_by_full_name("a-2")
|
||||||
|
assert_nil Gem::Specification.find_by_full_name("b-1")
|
||||||
|
assert_nil Gem::Specification.find_by_full_name("a-1-arm64-linux")
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_by_path
|
def test_find_by_path
|
||||||
a = util_spec "foo", "1", nil, "lib/foo.rb"
|
a = util_spec "foo", "1", nil, "lib/foo.rb"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user