[rubygems/rubygems] Rename `Gem::PrintableUri#parsed_uri?` to `Gem::PrintableUri#valid_uri?`

https://github.com/rubygems/rubygems/commit/a5177709c9
This commit is contained in:
Daniel Niknam 2021-08-22 11:39:06 +10:00 коммит произвёл Hiroshi SHIBATA
Родитель e3c319ad53
Коммит fafd9d280a
2 изменённых файлов: 15 добавлений и 15 удалений

Просмотреть файл

@ -21,7 +21,7 @@ class Gem::PrintableUri
self
end
def parsed_uri?
def valid_uri?
@uri.is_a? URI::Generic
end
@ -30,7 +30,7 @@ class Gem::PrintableUri
end
def original_password
return unless parsed_uri?
return unless valid_uri?
@original_uri.password
end
@ -56,25 +56,25 @@ class Gem::PrintableUri
end
def redactable_credential?
return false unless parsed_uri?
return false unless valid_uri?
password? || oauth_basic? || token?
end
def password?
return false unless parsed_uri?
return false unless valid_uri?
!!@uri.password
end
def oauth_basic?
return false unless parsed_uri?
return false unless valid_uri?
@uri.password == 'x-oauth-basic'
end
def token?
return false unless parsed_uri?
return false unless valid_uri?
!@uri.user.nil? && @uri.password.nil?
end

Просмотреть файл

@ -4,23 +4,23 @@ require 'rubygems/printable_uri'
class TestPrintableUri < Gem::TestCase
def test_parsed_uri
assert_equal true, Gem::PrintableUri.parse_uri("https://www.example.com").parsed_uri?
assert_equal true, Gem::PrintableUri.parse_uri("https://www.example.com").valid_uri?
end
def test_parsed_uri_with_empty_uri_object
assert_equal true, Gem::PrintableUri.parse_uri(URI("")).parsed_uri?
def test_valid_uri_with_empty_uri_object
assert_equal true, Gem::PrintableUri.parse_uri(URI("")).valid_uri?
end
def test_parsed_uri_with_valid_uri_object
assert_equal true, Gem::PrintableUri.parse_uri(URI("https://www.example.com")).parsed_uri?
def test_valid_uri_with_valid_uri_object
assert_equal true, Gem::PrintableUri.parse_uri(URI("https://www.example.com")).valid_uri?
end
def test_parsed_uri_with_other_objects
assert_equal false, Gem::PrintableUri.parse_uri(Object.new).parsed_uri?
def test_valid_uri_with_other_objects
assert_equal false, Gem::PrintableUri.parse_uri(Object.new).valid_uri?
end
def test_parsed_uri_with_invalid_uri
assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com:80index").parsed_uri?
def test_valid_uri_with_invalid_uri
assert_equal false, Gem::PrintableUri.parse_uri("https://www.example.com:80index").valid_uri?
end
def test_credential_redacted_with_user_pass