Browse files

Merge pull request #4538 from kennyj/should_use_uri_parse

Convert URI.parser.parse to URI.parse, and remove ruby 1.8.x code.
  • Loading branch information...
2 parents 2c7ded3 + d8b06dc commit 01cde0b246d47b2aedcd2568990fb61d384ca173 @tenderlove tenderlove committed Jan 19, 2012
View
4 activeresource/lib/active_resource/base.rb
@@ -939,12 +939,12 @@ def instantiate_record(record, prefix_options = {})
# Accepts a URI and creates the site URI from that.
def create_site_uri_from(site)
- site.is_a?(URI) ? site.dup : URI.parser.parse(site)
+ site.is_a?(URI) ? site.dup : URI.parse(site)
end
# Accepts a URI and creates the proxy URI from that.
def create_proxy_uri_from(proxy)
- proxy.is_a?(URI) ? proxy.dup : URI.parser.parse(proxy)
+ proxy.is_a?(URI) ? proxy.dup : URI.parse(proxy)
end
# contains a set of the current prefix parameters.
View
4 activeresource/lib/active_resource/connection.rb
@@ -39,14 +39,14 @@ def initialize(site, format = ActiveResource::Formats::JsonFormat)
# Set URI for remote service.
def site=(site)
- @site = site.is_a?(URI) ? site : URI.parser.parse(site)
+ @site = site.is_a?(URI) ? site : URI.parse(site)
@user = URI.parser.unescape(@site.user) if @site.user
@password = URI.parser.unescape(@site.password) if @site.password
end
# Set the proxy for remote service.
def proxy=(proxy)
- @proxy = proxy.is_a?(URI) ? proxy : URI.parser.parse(proxy)
+ @proxy = proxy.is_a?(URI) ? proxy : URI.parse(proxy)
end
# Sets the user for remote service.
View
2 activesupport/lib/active_support/core_ext/uri.rb
@@ -20,7 +20,7 @@ def unescape(str, escaped = /%[a-fA-F\d]{2}/)
module URI
class << self
def parser
- @parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
+ @parser ||= URI::Parser.new
end
end
end
View
8 activesupport/test/core_ext/uri_ext_test.rb
@@ -7,11 +7,7 @@ class URIExtTest < ActiveSupport::TestCase
def test_uri_decode_handle_multibyte
str = "\xE6\x97\xA5\xE6\x9C\xAC\xE8\xAA\x9E" # Ni-ho-nn-go in UTF-8, means Japanese.
- if URI.const_defined?(:Parser)
- parser = URI::Parser.new
- assert_equal str, parser.unescape(parser.escape(str))
- else
- assert_equal str, URI.unescape(URI.escape(str))
- end
+ parser = URI::Parser.new
+ assert_equal str, parser.unescape(parser.escape(str))
end
end

0 comments on commit 01cde0b

Please sign in to comment.