Generate a config.ru stub

This commit is contained in:
Joshua Peek 2009-09-25 21:10:00 -05:00
parent f14ad41456
commit 382870f763
3 changed files with 11 additions and 13 deletions

View File

@ -60,21 +60,16 @@ end
ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
if File.exist?(options[:config])
config = options[: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)
config = options[: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 RAILS_ROOT + "/config/environment"
inner_app = ActionController::Dispatcher.new
require config
inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
end
if options[:path].nil?

View File

@ -56,6 +56,7 @@ module Rails::Generators
def create_root_files
copy_file "Rakefile"
copy_file "README"
copy_file "config.ru"
end
def create_app_files

View File

@ -0,0 +1,2 @@
require File.dirname(__FILE__) + '/config/environment'
run ActionController::Dispatcher.new