aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/http/utils.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/utils.rb20
1 files changed, 20 insertions, 0 deletions
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