From bd1ce8a01239a46dbdc97fd65249b797e2b34507 Mon Sep 17 00:00:00 2001 From: Max Hawkins Date: Tue, 28 Jun 2011 18:10:06 -0400 Subject: [PATCH] Edit Rack apps to return arrays instead of strings String#each was removed in Ruby 1.9.2. The content returned by a rack app must respond to #each. --- lib/sproutcore/rack/builder.rb | 2 +- lib/sproutcore/rack/dev.rb | 8 ++++---- lib/sproutcore/rack/filesystem.rb | 4 ++-- lib/sproutcore/rack/proxy.rb | 2 +- lib/sproutcore/rack/test_runner.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/sproutcore/rack/builder.rb b/lib/sproutcore/rack/builder.rb index fa4df149..5587492d 100644 --- a/lib/sproutcore/rack/builder.rb +++ b/lib/sproutcore/rack/builder.rb @@ -176,7 +176,7 @@ def not_found(reason) return [404, { "Content-Type" => "text/html", "Content-Length" => reason.size.to_s - }, reason] + }, [reason]] end # Reloads the project if reloading is enabled. At maximum this will diff --git a/lib/sproutcore/rack/dev.rb b/lib/sproutcore/rack/dev.rb index ba424d34..7f3fa911 100644 --- a/lib/sproutcore/rack/dev.rb +++ b/lib/sproutcore/rack/dev.rb @@ -28,15 +28,15 @@ def call(env) url = env['PATH_INFO'] case url when '/sc/targets.json' # returns description of targets - return [200, {}, get_targets_json] + return [200, {}, [get_targets_json]] when '/sc/greenhouseconf.json' #returns json of all valid design objects - return [200, {}, get_greenhouse_configs(env)] + return [200, {}, [get_greenhouse_configs(env)]] else - return [404, {}, "not found"] + return [404, {}, ["not found"]] end - return [404, {}, "not found"] + return [404, {}, ["not found"]] end def get_targets_json diff --git a/lib/sproutcore/rack/filesystem.rb b/lib/sproutcore/rack/filesystem.rb index 1b561322..f92df6bd 100644 --- a/lib/sproutcore/rack/filesystem.rb +++ b/lib/sproutcore/rack/filesystem.rb @@ -65,7 +65,7 @@ def call(env) body = rqust.body.read() path = env["PATH_INFO"] - return [404, {}, "not found"] unless path =~ regex + return [404, {}, ["not found"]] unless path =~ regex path = path.sub regex, '' # remove path prefix action = params['action'] @@ -292,7 +292,7 @@ def forbidden(body) end def success(msg) - [ 200, { 'Content-Type' => 'text/html' }, msg ] + [ 200, { 'Content-Type' => 'text/html' }, [msg] ] end def with_modifiable_path(path) diff --git a/lib/sproutcore/rack/proxy.rb b/lib/sproutcore/rack/proxy.rb index df28427b..38678b15 100644 --- a/lib/sproutcore/rack/proxy.rb +++ b/lib/sproutcore/rack/proxy.rb @@ -80,7 +80,7 @@ def call(env) end end - return [404, {}, "not found"] + return [404, {}, ["not found"]] end def chunked?(headers) diff --git a/lib/sproutcore/rack/test_runner.rb b/lib/sproutcore/rack/test_runner.rb index be52e79f..d8d09b78 100644 --- a/lib/sproutcore/rack/test_runner.rb +++ b/lib/sproutcore/rack/test_runner.rb @@ -17,7 +17,7 @@ def initialize(project) end def call(env) - return [404, {}, "not found"] + return [404, {}, ["not found"]] end end end