sinatra 1.3.0.d → 1.3.0.e
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/.gitignore +6 -0
- data/.yardopts +4 -0
- data/CHANGES +80 -3
- data/Gemfile +18 -12
- data/README.de.rdoc +189 -381
- data/README.es.rdoc +193 -316
- data/README.fr.rdoc +327 -475
- data/README.jp.rdoc +7 -1
- data/README.rdoc +132 -101
- data/README.ru.rdoc +3 -3
- data/README.zh.rdoc +2 -2
- data/Rakefile +19 -27
- data/lib/sinatra/base.rb +186 -262
- data/lib/sinatra/version.rb +3 -0
- data/sinatra.gemspec +12 -128
- data/test/base_test.rb +1 -1
- data/test/builder_test.rb +1 -1
- data/test/coffee_test.rb +1 -1
- data/test/creole_test.rb +1 -1
- data/test/delegator_test.rb +9 -7
- data/test/encoding_test.rb +1 -1
- data/test/erb_test.rb +1 -1
- data/test/extensions_test.rb +1 -1
- data/test/filter_test.rb +7 -4
- data/test/haml_test.rb +1 -1
- data/test/helper.rb +16 -1
- data/test/helpers_test.rb +12 -1
- data/test/less_test.rb +1 -1
- data/test/liquid_test.rb +1 -1
- data/test/mapped_error_test.rb +44 -1
- data/test/markaby_test.rb +1 -1
- data/test/markdown_test.rb +1 -1
- data/test/middleware_test.rb +1 -1
- data/test/nokogiri_test.rb +1 -1
- data/test/radius_test.rb +1 -1
- data/test/rdoc_test.rb +2 -2
- data/test/readme_test.rb +136 -0
- data/test/request_test.rb +1 -1
- data/test/response_test.rb +13 -3
- data/test/result_test.rb +3 -3
- data/test/route_added_hook_test.rb +1 -1
- data/test/routing_test.rb +9 -2
- data/test/sass_test.rb +1 -1
- data/test/scss_test.rb +1 -1
- data/test/server_test.rb +1 -1
- data/test/settings_test.rb +55 -22
- data/test/sinatra_test.rb +1 -1
- data/test/slim_test.rb +1 -1
- data/test/static_test.rb +22 -1
- data/test/templates_test.rb +1 -1
- data/test/textile_test.rb +1 -1
- metadata +47 -59
- data/lib/sinatra/rack.rb +0 -44
data/sinatra.gemspec
CHANGED
@@ -1,132 +1,16 @@
|
|
1
|
-
|
2
|
-
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
1
|
+
load './lib/sinatra/version.rb'
|
4
2
|
|
5
|
-
|
6
|
-
s.
|
7
|
-
s.
|
3
|
+
Gem::Specification.new 'sinatra', Sinatra::VERSION do |s|
|
4
|
+
s.description = "Classy web-development dressed in a DSL"
|
5
|
+
s.summary = s.description
|
6
|
+
s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
|
7
|
+
s.email = "sinatrarb@googlegroups.com"
|
8
|
+
s.homepage = "http://www.sinatrarb.com/"
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
|
11
|
+
s.extra_rdoc_files = s.files.select { |p| p =~ /^README/ } << 'LICENSE'
|
12
|
+
s.rdoc_options = %w[--line-numbers --inline-source --title Sinatra --main README.rdoc]
|
8
13
|
|
9
|
-
s.
|
10
|
-
s.summary = "Classy web-development dressed in a DSL"
|
11
|
-
|
12
|
-
s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
|
13
|
-
s.email = "sinatrarb@googlegroups.com"
|
14
|
-
|
15
|
-
# = MANIFEST =
|
16
|
-
s.files = %w[
|
17
|
-
AUTHORS
|
18
|
-
CHANGES
|
19
|
-
Gemfile
|
20
|
-
LICENSE
|
21
|
-
README.de.rdoc
|
22
|
-
README.es.rdoc
|
23
|
-
README.fr.rdoc
|
24
|
-
README.hu.rdoc
|
25
|
-
README.jp.rdoc
|
26
|
-
README.pt-br.rdoc
|
27
|
-
README.pt-pt.rdoc
|
28
|
-
README.rdoc
|
29
|
-
README.ru.rdoc
|
30
|
-
README.zh.rdoc
|
31
|
-
Rakefile
|
32
|
-
lib/sinatra.rb
|
33
|
-
lib/sinatra/base.rb
|
34
|
-
lib/sinatra/images/404.png
|
35
|
-
lib/sinatra/images/500.png
|
36
|
-
lib/sinatra/main.rb
|
37
|
-
lib/sinatra/rack.rb
|
38
|
-
lib/sinatra/showexceptions.rb
|
39
|
-
sinatra.gemspec
|
40
|
-
test/base_test.rb
|
41
|
-
test/builder_test.rb
|
42
|
-
test/coffee_test.rb
|
43
|
-
test/contest.rb
|
44
|
-
test/creole_test.rb
|
45
|
-
test/delegator_test.rb
|
46
|
-
test/encoding_test.rb
|
47
|
-
test/erb_test.rb
|
48
|
-
test/extensions_test.rb
|
49
|
-
test/filter_test.rb
|
50
|
-
test/haml_test.rb
|
51
|
-
test/helper.rb
|
52
|
-
test/helpers_test.rb
|
53
|
-
test/less_test.rb
|
54
|
-
test/liquid_test.rb
|
55
|
-
test/mapped_error_test.rb
|
56
|
-
test/markaby_test.rb
|
57
|
-
test/markdown_test.rb
|
58
|
-
test/middleware_test.rb
|
59
|
-
test/nokogiri_test.rb
|
60
|
-
test/public/favicon.ico
|
61
|
-
test/radius_test.rb
|
62
|
-
test/rdoc_test.rb
|
63
|
-
test/request_test.rb
|
64
|
-
test/response_test.rb
|
65
|
-
test/result_test.rb
|
66
|
-
test/route_added_hook_test.rb
|
67
|
-
test/routing_test.rb
|
68
|
-
test/sass_test.rb
|
69
|
-
test/scss_test.rb
|
70
|
-
test/server_test.rb
|
71
|
-
test/settings_test.rb
|
72
|
-
test/sinatra_test.rb
|
73
|
-
test/slim_test.rb
|
74
|
-
test/static_test.rb
|
75
|
-
test/templates_test.rb
|
76
|
-
test/textile_test.rb
|
77
|
-
test/views/a/in_a.str
|
78
|
-
test/views/ascii.erb
|
79
|
-
test/views/b/in_b.str
|
80
|
-
test/views/calc.html.erb
|
81
|
-
test/views/error.builder
|
82
|
-
test/views/error.erb
|
83
|
-
test/views/error.haml
|
84
|
-
test/views/error.sass
|
85
|
-
test/views/explicitly_nested.str
|
86
|
-
test/views/foo/hello.test
|
87
|
-
test/views/hello.builder
|
88
|
-
test/views/hello.coffee
|
89
|
-
test/views/hello.creole
|
90
|
-
test/views/hello.erb
|
91
|
-
test/views/hello.haml
|
92
|
-
test/views/hello.less
|
93
|
-
test/views/hello.liquid
|
94
|
-
test/views/hello.mab
|
95
|
-
test/views/hello.md
|
96
|
-
test/views/hello.nokogiri
|
97
|
-
test/views/hello.radius
|
98
|
-
test/views/hello.rdoc
|
99
|
-
test/views/hello.sass
|
100
|
-
test/views/hello.scss
|
101
|
-
test/views/hello.slim
|
102
|
-
test/views/hello.str
|
103
|
-
test/views/hello.test
|
104
|
-
test/views/hello.textile
|
105
|
-
test/views/layout2.builder
|
106
|
-
test/views/layout2.erb
|
107
|
-
test/views/layout2.haml
|
108
|
-
test/views/layout2.liquid
|
109
|
-
test/views/layout2.mab
|
110
|
-
test/views/layout2.nokogiri
|
111
|
-
test/views/layout2.radius
|
112
|
-
test/views/layout2.slim
|
113
|
-
test/views/layout2.str
|
114
|
-
test/views/layout2.test
|
115
|
-
test/views/nested.str
|
116
|
-
test/views/utf8.erb
|
117
|
-
]
|
118
|
-
# = MANIFEST =
|
119
|
-
|
120
|
-
s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
|
121
|
-
|
122
|
-
s.extra_rdoc_files = %w[README.rdoc README.de.rdoc README.jp.rdoc README.fr.rdoc README.es.rdoc README.hu.rdoc README.zh.rdoc LICENSE]
|
123
|
-
s.add_dependency 'rack', '~> 1.2'
|
14
|
+
s.add_dependency 'rack', '~> 1.3'
|
124
15
|
s.add_dependency 'tilt', '~> 1.3'
|
125
|
-
s.add_development_dependency 'shotgun', '~> 0.6'
|
126
|
-
|
127
|
-
s.homepage = "http://sinatra.rubyforge.org"
|
128
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"]
|
129
|
-
s.require_paths = %w[lib]
|
130
|
-
s.rubyforge_project = 'sinatra'
|
131
|
-
s.rubygems_version = '1.1.1'
|
132
16
|
end
|
data/test/base_test.rb
CHANGED
data/test/builder_test.rb
CHANGED
data/test/coffee_test.rb
CHANGED
data/test/creole_test.rb
CHANGED
data/test/delegator_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
1
3
|
class DelegatorTest < Test::Unit::TestCase
|
2
4
|
class Mirror
|
3
5
|
attr_reader :last_call
|
@@ -10,18 +12,18 @@ class DelegatorTest < Test::Unit::TestCase
|
|
10
12
|
def self.delegates(name)
|
11
13
|
it "delegates #{name}" do
|
12
14
|
m = mirror { send name }
|
13
|
-
assert_equal
|
15
|
+
assert_equal [name.to_s], m.last_call
|
14
16
|
end
|
15
17
|
|
16
18
|
it "delegates #{name} with arguments" do
|
17
19
|
m = mirror { send name, "foo", "bar" }
|
18
|
-
assert_equal
|
20
|
+
assert_equal [name.to_s, "foo", "bar"], m.last_call
|
19
21
|
end
|
20
22
|
|
21
23
|
it "delegates #{name} with block" do
|
22
24
|
block = proc { }
|
23
25
|
m = mirror { send(name, &block) }
|
24
|
-
assert_equal
|
26
|
+
assert_equal [name.to_s, block], m.last_call
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -55,7 +57,7 @@ class DelegatorTest < Test::Unit::TestCase
|
|
55
57
|
end
|
56
58
|
|
57
59
|
it 'defaults to Sinatra::Application as target' do
|
58
|
-
assert_equal Sinatra::
|
60
|
+
assert_equal Sinatra::Application, Sinatra::Delegator.target
|
59
61
|
end
|
60
62
|
|
61
63
|
%w[get put post delete options patch].each do |verb|
|
@@ -91,19 +93,19 @@ class DelegatorTest < Test::Unit::TestCase
|
|
91
93
|
it "registers extensions with the delegation target" do
|
92
94
|
app, mixin = mirror, Module.new
|
93
95
|
Sinatra.register mixin
|
94
|
-
assert_equal
|
96
|
+
assert_equal ["register", mixin.to_s], app.last_call
|
95
97
|
end
|
96
98
|
|
97
99
|
it "registers helpers with the delegation target" do
|
98
100
|
app, mixin = mirror, Module.new
|
99
101
|
Sinatra.helpers mixin
|
100
|
-
assert_equal
|
102
|
+
assert_equal ["helpers", mixin.to_s], app.last_call
|
101
103
|
end
|
102
104
|
|
103
105
|
it "registers helpers with the delegation target" do
|
104
106
|
app, mixin = mirror, Module.new
|
105
107
|
Sinatra.use mixin
|
106
|
-
assert_equal
|
108
|
+
assert_equal ["use", mixin.to_s], app.last_call
|
107
109
|
end
|
108
110
|
|
109
111
|
it "should work with method_missing proxies for options" do
|
data/test/encoding_test.rb
CHANGED
data/test/erb_test.rb
CHANGED
data/test/extensions_test.rb
CHANGED
data/test/filter_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
3
|
class BeforeFilterTest < Test::Unit::TestCase
|
4
4
|
it "executes filters in the order defined" do
|
@@ -221,9 +221,12 @@ class AfterFilterTest < Test::Unit::TestCase
|
|
221
221
|
count = 2
|
222
222
|
base = Class.new(Sinatra::Base)
|
223
223
|
base.after { count *= 2 }
|
224
|
-
mock_app(base)
|
225
|
-
get('/foo')
|
226
|
-
|
224
|
+
mock_app(base) do
|
225
|
+
get('/foo') do
|
226
|
+
count += 2
|
227
|
+
"ok"
|
228
|
+
end
|
229
|
+
end
|
227
230
|
|
228
231
|
get '/foo'
|
229
232
|
assert_equal 8, count
|
data/test/haml_test.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -38,6 +38,13 @@ class Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
class << self
|
40
40
|
alias_method :it, :test
|
41
|
+
alias_method :section, :context
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.example(desc = nil, &block)
|
45
|
+
@example_count = 0 unless instance_variable_defined? :@example_count
|
46
|
+
@example_count += 1
|
47
|
+
it(desc || "Example #{@example_count}", &block)
|
41
48
|
end
|
42
49
|
|
43
50
|
alias_method :response, :last_response
|
@@ -66,7 +73,7 @@ class Test::Unit::TestCase
|
|
66
73
|
end
|
67
74
|
|
68
75
|
def assert_like(a,b)
|
69
|
-
pattern =
|
76
|
+
pattern = /id=['"][^"']*["']|\s+/
|
70
77
|
assert_equal a.strip.gsub(pattern, ""), b.strip.gsub(pattern, "")
|
71
78
|
end
|
72
79
|
|
@@ -74,6 +81,14 @@ class Test::Unit::TestCase
|
|
74
81
|
assert str.include?(substr), "expected #{str.inspect} to include #{substr.inspect}"
|
75
82
|
end
|
76
83
|
|
84
|
+
def options(uri, params = {}, env = {}, &block)
|
85
|
+
request(uri, env.merge(:method => "OPTIONS", :params => params), &block)
|
86
|
+
end
|
87
|
+
|
88
|
+
def patch(uri, params = {}, env = {}, &block)
|
89
|
+
request(uri, env.merge(:method => "PATCH", :params => params), &block)
|
90
|
+
end
|
91
|
+
|
77
92
|
# Delegate other missing methods to response.
|
78
93
|
def method_missing(name, *args, &block)
|
79
94
|
if response && response.respond_to?(name)
|
data/test/helpers_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
require 'date'
|
3
3
|
|
4
4
|
class HelpersTest < Test::Unit::TestCase
|
@@ -446,6 +446,7 @@ class HelpersTest < Test::Unit::TestCase
|
|
446
446
|
assert_equal content_type(:xml), 'application/xml;charset=utf-8'
|
447
447
|
assert_equal content_type(:xhtml), 'application/xhtml+xml;charset=utf-8'
|
448
448
|
assert_equal content_type(:js), 'application/javascript;charset=utf-8'
|
449
|
+
assert_equal content_type(:json), 'application/json;charset=utf-8'
|
449
450
|
assert_equal content_type(:bar), 'application/bar'
|
450
451
|
assert_equal content_type(:png), 'image/png'
|
451
452
|
assert_equal content_type(:baz), 'application/baz;charset=utf-8'
|
@@ -852,6 +853,16 @@ class HelpersTest < Test::Unit::TestCase
|
|
852
853
|
get '/'
|
853
854
|
assert_equal 'W/"FOO"', response['ETag']
|
854
855
|
end
|
856
|
+
|
857
|
+
it 'raises an ArgumentError for an invalid strength' do
|
858
|
+
mock_app do
|
859
|
+
get '/' do
|
860
|
+
etag 'FOO', :w00t
|
861
|
+
"that's weak, dude."
|
862
|
+
end
|
863
|
+
end
|
864
|
+
assert_raise(ArgumentError) { get '/' }
|
865
|
+
end
|
855
866
|
end
|
856
867
|
|
857
868
|
describe 'back' do
|
data/test/less_test.rb
CHANGED
data/test/liquid_test.rb
CHANGED
data/test/mapped_error_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
3
|
class FooError < RuntimeError
|
4
4
|
end
|
@@ -39,6 +39,36 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
39
39
|
assert_equal 'Exception!', body
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'walks down inheritance chain for errors' do
|
43
|
+
mock_app {
|
44
|
+
set :raise_errors, false
|
45
|
+
error(RuntimeError) { 'Exception!' }
|
46
|
+
get '/' do
|
47
|
+
raise FooError
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
get '/'
|
52
|
+
assert_equal 500, status
|
53
|
+
assert_equal 'Exception!', body
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'favors subclass handler over superclass handler if available' do
|
57
|
+
mock_app {
|
58
|
+
set :raise_errors, false
|
59
|
+
error(Exception) { 'Exception!' }
|
60
|
+
error(FooError) { 'FooError!' }
|
61
|
+
error(RuntimeError) { 'Exception!' }
|
62
|
+
get '/' do
|
63
|
+
raise FooError
|
64
|
+
end
|
65
|
+
}
|
66
|
+
|
67
|
+
get '/'
|
68
|
+
assert_equal 500, status
|
69
|
+
assert_equal 'FooError!', body
|
70
|
+
end
|
71
|
+
|
42
72
|
it "sets env['sinatra.error'] to the rescued exception" do
|
43
73
|
mock_app {
|
44
74
|
set :raise_errors, false
|
@@ -172,6 +202,19 @@ class MappedErrorTest < Test::Unit::TestCase
|
|
172
202
|
assert_equal 'Error: 507', body
|
173
203
|
end
|
174
204
|
|
205
|
+
it 'allows passing more than one range' do
|
206
|
+
mock_app {
|
207
|
+
set :raise_errors, false
|
208
|
+
error(409..411, 503..509) { "Error: #{response.status}" }
|
209
|
+
get '/' do
|
210
|
+
[507, {}, 'A very special error']
|
211
|
+
end
|
212
|
+
}
|
213
|
+
get '/'
|
214
|
+
assert_equal 507, status
|
215
|
+
assert_equal 'Error: 507', body
|
216
|
+
end
|
217
|
+
|
175
218
|
class FooError < RuntimeError
|
176
219
|
end
|
177
220
|
|
data/test/markaby_test.rb
CHANGED
data/test/markdown_test.rb
CHANGED
data/test/middleware_test.rb
CHANGED