Request Routing Plugin Update - Feedback? Interest? Help?

I have an update to the request plugin that I would like feedback or
help with. I have contacted the author but have not heard anything
back, which is why I am posting this here.

My goal was to allow for sites that could have unlimited user
subdomains, but would like to reserve some subdomains for other uses.
To do this I changed the plugin to allow for either multiple
subdomains or to exclude single or multiple subdomains (or domains).
It works pretty well (but could be cleaned up, I am not a great ruby
coder, still pretty new).

Below is the code, please let me know if I can approve it ( I did try
a case/switch statement, but it always seemed to throw and error in
the routes):

module ActionController
module Routing
class Route

  TESTABLE_REQUEST_METHODS =

[:subdomain, :domain, :method, :port, :remote_ip,
:content_type, :accepts, :request_uri,
:protocol,
:exclude_subdomain, :exclude_domain ]

  def recognition_conditions
    result = ["(match =

#{Regexp.new(recognition_pattern).inspect}.match(path))"]
conditions.each do |method, value|
if TESTABLE_REQUEST_METHODS.include? method
if method.to_s[0,7] === ‘exclude’
prefix = “!”
env_name =
method.to_s[8,method.to_s.length-8].to_sym.inspect
else
prefix =""
env_name = method.inspect
end
condition_name = method.inspect
result << “conditions[#{condition_name}] =~
env[#{env_name}]” if value.is_a? Regexp
result << “#{prefix}conditions[#{condition_name}].include?
(env[#{env_name}])” if value.is_a? Array
result << “conditions[#{condition_name}] ===
env[#{env_name}]” if !value.is_a?(Regexp) && !value.is_a?(Array)
else
end
end
result
end
end

class RouteSet

  def extract_request_environment(request)
    {
      :method => request.method,
      :subdomain => request.subdomains.first.to_s,
      :domain => request.domain,
      :port => request.port,
      :remote_ip => request.remote_ip,
      :content_type => request.content_type,
      :accepts => request.accepts.map(&:to_s).join(','),
      :request_uri => request.request_uri,
      :protocol => request.protocol
    }
  end

end

end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs