18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/rubygems_plugin.rb', line 18
def accept_uri_http
Gem::OptionParser.accept Gem::URI::HTTP do |value|
next value if value.to_s.end_with?(".gemv")
begin
uri = Gem::URI.parse value
rescue Gem::URI::InvalidURIError
raise Gem::OptionParser::InvalidArgument, value
end
valid_uri_schemes = ["http", "https", "file", "s3"]
unless valid_uri_schemes.include?(uri.scheme)
msg = "Invalid uri scheme for #{value}\nPreface URLs with one of #{valid_uri_schemes.map { |s| "#{s}://" }}"
raise ArgumentError, msg
end
value
end
end
|