sinatra-sinatra 0.9.0 → 0.9.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -72,6 +72,7 @@ task 'publish:doc' => 'doc/api/index.html' do
72
72
  sh 'scp -rp doc/* rubyforge.org:/var/www/gforge-projects/sinatra/'
73
73
  end
74
74
 
75
+ desc 'Publish gem and tarball to rubyforge'
75
76
  task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t|
76
77
  sh <<-end
77
78
  rubyforge add_release sinatra sinatra #{spec.version} #{package('.gem')} &&
data/lib/sinatra/base.rb CHANGED
@@ -4,7 +4,7 @@ require 'rack'
4
4
  require 'rack/builder'
5
5
 
6
6
  module Sinatra
7
- VERSION = '0.9.0'
7
+ VERSION = '0.9.0.1'
8
8
 
9
9
  class Request < Rack::Request
10
10
  def user_agent
@@ -328,7 +328,7 @@ module Sinatra
328
328
 
329
329
  private
330
330
  def dispatch!
331
- self.class.filters.each {|block| instance_eval(&block)}
331
+ self.class.filters.each { |block| invoke(block) }
332
332
  if routes = self.class.routes[@request.request_method]
333
333
  path = @request.path_info
334
334
  original_params = nested_params(@request.params)
@@ -382,6 +382,8 @@ module Sinatra
382
382
 
383
383
  def invoke(block)
384
384
  res = catch(:halt) { instance_eval(&block) }
385
+ return if res.nil?
386
+
385
387
  case
386
388
  when res.respond_to?(:to_str)
387
389
  @response.body = [res]
@@ -405,8 +407,6 @@ module Sinatra
405
407
  @response.body = res
406
408
  when (100...599) === res
407
409
  @response.status = res
408
- when res.nil?
409
- @response.body = []
410
410
  end
411
411
  res
412
412
  end
@@ -522,7 +522,7 @@ module Sinatra
522
522
  end
523
523
 
524
524
  def before(&block)
525
- @filters << block
525
+ @filters << lambda { instance_eval(&block) ; nil }
526
526
  end
527
527
 
528
528
  def condition(&block)
data/sinatra.gemspec CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'sinatra'
6
- s.version = '0.9.0'
6
+ s.version = '0.9.0.1'
7
7
  s.date = '2009-01-18'
8
8
 
9
9
  s.description = "Classy web-development dressed in a DSL"
data/test/filter_test.rb CHANGED
@@ -32,4 +32,29 @@ describe "Filters" do
32
32
  assert ok?
33
33
  assert_equal 'bar', body
34
34
  end
35
+
36
+ it "allows redirects in filters" do
37
+ mock_app {
38
+ before { redirect '/bar' }
39
+ get('/foo') { 'ORLY?!' }
40
+ }
41
+
42
+ get '/foo'
43
+ assert redirect?
44
+ assert_equal '/bar', response['Location']
45
+ end
46
+
47
+ it "does not modify the response with its return value" do
48
+ mock_app {
49
+ before { 'Hello World!' }
50
+ get '/foo' do
51
+ assert_equal [], response.body
52
+ 'cool'
53
+ end
54
+ }
55
+
56
+ get '/foo'
57
+ assert ok?
58
+ assert_equal 'cool', body
59
+ end
35
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany