From a4a8bf7604d1c15c5a8fb9cb6be37e8bccb32e52 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 28 Feb 2010 19:20:11 -0800 Subject: respect user's encoding in config.ru in 1.9 Do not assume the user wants config.ru to be Encoding::BINARY for 1.9. --- lib/unicorn.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/unicorn.rb b/lib/unicorn.rb index 43ef9e8..8c0ff6e 100644 --- a/lib/unicorn.rb +++ b/lib/unicorn.rb @@ -35,15 +35,13 @@ module Unicorn def builder(ru, opts) if ru =~ /\.ru\z/ # parse embedded command-line options in config.ru comments - if File.open(ru, "rb") { |fp| fp.sysread(fp.stat.size) } =~ /^#\\(.*)/ - opts.parse! $1.split(/\s+/) - end + /^#\\(.*)/ =~ File.read(ru) and opts.parse!($1.split(/\s+/)) end lambda do || inner_app = case ru when /\.ru$/ - raw = File.open(ru, "rb") { |fp| fp.sysread(fp.stat.size) } + raw = File.read(ru) raw.sub!(/^__END__\n.*/, '') eval("Rack::Builder.new {(#{raw}\n)}.to_app", TOPLEVEL_BINDING, ru) else -- cgit v1.2.3-24-ge0c7