Skip to content

Commit

Permalink
Remove warning "URI.unescape is obsolete" from actionpack.
Browse files Browse the repository at this point in the history
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information
miloops authored and spastorino committed Sep 27, 2010
1 parent 8be911c commit 2f326b7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_controller.rb
Expand Up @@ -8,6 +8,7 @@ module ActionController
autoload :Caching autoload :Caching
autoload :Metal autoload :Metal
autoload :Middleware autoload :Middleware
autoload :UriParser


autoload_under "metal" do autoload_under "metal" do
autoload :Compatibility autoload :Compatibility
Expand Down
6 changes: 2 additions & 4 deletions actionpack/lib/action_controller/caching/actions.rb
Expand Up @@ -141,6 +141,8 @@ def filter(controller)
end end


class ActionCachePath class ActionCachePath
include UriParser

attr_reader :path, :extension attr_reader :path, :extension


# If +infer_extension+ is true, the cache path extension is looked up from the request's # If +infer_extension+ is true, the cache path extension is looked up from the request's
Expand All @@ -163,10 +165,6 @@ def normalize!(path)
path << ".#{extension}" if extension and !path.ends_with?(extension) path << ".#{extension}" if extension and !path.ends_with?(extension)
uri_parser.unescape(path) uri_parser.unescape(path)
end end

def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end end
end end
end end
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/caching/pages.rb
@@ -1,5 +1,4 @@
require 'fileutils' require 'fileutils'
require 'uri'
require 'active_support/core_ext/class/attribute_accessors' require 'active_support/core_ext/class/attribute_accessors'


module ActionController #:nodoc: module ActionController #:nodoc:
Expand Down Expand Up @@ -58,6 +57,8 @@ module Pages
end end


module ClassMethods module ClassMethods
include UriParser

# Expires the page that was cached with the +path+ as a key. Example: # Expires the page that was cached with the +path+ as a key. Example:
# expire_page "/lists/show" # expire_page "/lists/show"
def expire_page(path) def expire_page(path)
Expand Down
4 changes: 0 additions & 4 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -129,10 +129,6 @@ def to_s() join '/' end
def self.new_escaped(strings) def self.new_escaped(strings)
new strings.collect {|str| uri_parser.unescape str} new strings.collect {|str| uri_parser.unescape str}
end end

def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end end


def assign_parameters(routes, controller_path, action, parameters = {}) def assign_parameters(routes, controller_path, action, parameters = {})
Expand Down
9 changes: 9 additions & 0 deletions actionpack/lib/action_controller/uri_parser.rb
@@ -0,0 +1,9 @@
require 'uri'

module ActionController #:nodoc:
module UriParser
def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end
end
6 changes: 2 additions & 4 deletions actionpack/lib/action_dispatch/routing/route_set.rb
Expand Up @@ -5,6 +5,8 @@
module ActionDispatch module ActionDispatch
module Routing module Routing
class RouteSet #:nodoc: class RouteSet #:nodoc:
include ActionController::UriParser

PARAMETERS_KEY = 'action_dispatch.request.path_parameters' PARAMETERS_KEY = 'action_dispatch.request.path_parameters'


class Dispatcher #:nodoc: class Dispatcher #:nodoc:
Expand Down Expand Up @@ -68,10 +70,6 @@ def merge_default_action!(params)
def split_glob_param!(params) def split_glob_param!(params)
params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) } params[@glob_param] = params[@glob_param].split('/').map { |v| uri_parser.unescape(v) }
end end

def uri_parser
@uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI
end
end end


# A NamedRouteCollection instance is a collection of named routes, and also # A NamedRouteCollection instance is a collection of named routes, and also
Expand Down

1 comment on commit 2f326b7

@josevalim
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to me more like an Active Support concern (note we will need this same logic in Active Resource). Maybe add URI.parser to active_support/core_ext/uri.rb and make them all depend on it?

Please sign in to comment.