diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-09-25 21:40:55 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-09-25 21:40:55 -0500 |
commit | dfbd3b94094d54483a47faa9d927370df476f572 (patch) | |
tree | a51a222e698722ecb4a4618dd73a0b691ca0098d /actionpack/lib/action_dispatch | |
parent | accd9b4634f1a2f220bc3e38cf5c4add04186fe6 (diff) | |
download | rails-dfbd3b94094d54483a47faa9d927370df476f572.tar.gz rails-dfbd3b94094d54483a47faa9d927370df476f572.tar.bz2 rails-dfbd3b94094d54483a47faa9d927370df476f572.zip |
Extract "parse_config" into AD
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/utils.rb | 20 |
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 |