From dfbd3b94094d54483a47faa9d927370df476f572 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 25 Sep 2009 21:40:55 -0500 Subject: Extract "parse_config" into AD --- actionpack/lib/action_dispatch/http/utils.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 actionpack/lib/action_dispatch/http/utils.rb (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/http/utils.rb b/actionpack/lib/action_dispatch/http/utils.rb new file mode 100644 index 0000000000..e04a39935e --- /dev/null +++ b/actionpack/lib/action_dispatch/http/utils.rb @@ -0,0 +1,20 @@ +module ActionDispatch + module Utils + # TODO: Pull this into rack core + # http://github.com/halorgium/rack/commit/feaf071c1de743fbd10bc316830180a9af607278 + def parse_config(config) + if config =~ /\.ru$/ + cfgfile = ::File.read(config) + if cfgfile[/^#\\(.*)/] + opts.parse! $1.split(/\s+/) + end + inner_app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app", + nil, config + else + require config + inner_app = Object.const_get(::File.basename(config, '.rb').capitalize) + end + end + module_function :parse_config + end +end -- cgit v1.2.3