sinatra 1.4.8 → 2.0.0.beta1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -47
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +37 -49
- data/MAINTENANCE.md +42 -0
- data/README.de.md +5 -5
- data/README.es.md +5 -5
- data/README.fr.md +9 -9
- data/README.hu.md +3 -3
- data/README.ja.md +19 -8
- data/README.ko.md +8 -8
- data/README.md +90 -61
- data/README.pt-br.md +3 -3
- data/README.pt-pt.md +2 -2
- data/README.ru.md +42 -26
- data/README.zh.md +8 -8
- data/Rakefile +0 -6
- data/SECURITY.md +35 -0
- data/lib/sinatra/base.rb +113 -161
- data/lib/sinatra/main.rb +1 -0
- data/lib/sinatra/show_exceptions.rb +8 -8
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +7 -4
- metadata +34 -168
- data/lib/sinatra/ext.rb +0 -17
- data/test/asciidoctor_test.rb +0 -72
- data/test/base_test.rb +0 -167
- data/test/builder_test.rb +0 -91
- data/test/coffee_test.rb +0 -96
- data/test/compile_test.rb +0 -183
- data/test/contest.rb +0 -91
- data/test/creole_test.rb +0 -65
- data/test/delegator_test.rb +0 -160
- data/test/encoding_test.rb +0 -20
- data/test/erb_test.rb +0 -116
- data/test/extensions_test.rb +0 -98
- data/test/filter_test.rb +0 -487
- data/test/haml_test.rb +0 -109
- data/test/helper.rb +0 -132
- data/test/helpers_test.rb +0 -1917
- data/test/integration/app.rb +0 -79
- data/test/integration_helper.rb +0 -236
- data/test/integration_test.rb +0 -104
- data/test/less_test.rb +0 -69
- data/test/liquid_test.rb +0 -77
- data/test/mapped_error_test.rb +0 -285
- data/test/markaby_test.rb +0 -80
- data/test/markdown_test.rb +0 -85
- data/test/mediawiki_test.rb +0 -68
- data/test/middleware_test.rb +0 -68
- data/test/nokogiri_test.rb +0 -67
- data/test/public/favicon.ico +0 -0
- data/test/public/hello+world.txt +0 -1
- data/test/rabl_test.rb +0 -89
- data/test/rack_test.rb +0 -45
- data/test/radius_test.rb +0 -59
- data/test/rdoc_test.rb +0 -66
- data/test/readme_test.rb +0 -130
- data/test/request_test.rb +0 -100
- data/test/response_test.rb +0 -63
- data/test/result_test.rb +0 -76
- data/test/route_added_hook_test.rb +0 -59
- data/test/routing_test.rb +0 -1456
- data/test/sass_test.rb +0 -115
- data/test/scss_test.rb +0 -88
- data/test/server_test.rb +0 -56
- data/test/settings_test.rb +0 -582
- data/test/sinatra_test.rb +0 -12
- data/test/slim_test.rb +0 -102
- data/test/static_test.rb +0 -266
- data/test/streaming_test.rb +0 -149
- data/test/stylus_test.rb +0 -90
- data/test/templates_test.rb +0 -382
- data/test/textile_test.rb +0 -65
- data/test/views/a/in_a.str +0 -1
- data/test/views/ascii.erb +0 -2
- data/test/views/b/in_b.str +0 -1
- data/test/views/calc.html.erb +0 -1
- data/test/views/error.builder +0 -3
- data/test/views/error.erb +0 -3
- data/test/views/error.haml +0 -3
- data/test/views/error.sass +0 -2
- data/test/views/explicitly_nested.str +0 -1
- data/test/views/foo/hello.test +0 -1
- data/test/views/hello.asciidoc +0 -1
- data/test/views/hello.builder +0 -1
- data/test/views/hello.coffee +0 -1
- data/test/views/hello.creole +0 -1
- data/test/views/hello.erb +0 -1
- data/test/views/hello.haml +0 -1
- data/test/views/hello.less +0 -5
- data/test/views/hello.liquid +0 -1
- data/test/views/hello.mab +0 -1
- data/test/views/hello.md +0 -1
- data/test/views/hello.mediawiki +0 -1
- data/test/views/hello.nokogiri +0 -1
- data/test/views/hello.rabl +0 -2
- data/test/views/hello.radius +0 -1
- data/test/views/hello.rdoc +0 -1
- data/test/views/hello.sass +0 -2
- data/test/views/hello.scss +0 -3
- data/test/views/hello.slim +0 -1
- data/test/views/hello.str +0 -1
- data/test/views/hello.styl +0 -2
- data/test/views/hello.test +0 -1
- data/test/views/hello.textile +0 -1
- data/test/views/hello.wlang +0 -1
- data/test/views/hello.yajl +0 -1
- data/test/views/layout2.builder +0 -3
- data/test/views/layout2.erb +0 -2
- data/test/views/layout2.haml +0 -2
- data/test/views/layout2.liquid +0 -2
- data/test/views/layout2.mab +0 -2
- data/test/views/layout2.nokogiri +0 -3
- data/test/views/layout2.rabl +0 -3
- data/test/views/layout2.radius +0 -2
- data/test/views/layout2.slim +0 -3
- data/test/views/layout2.str +0 -2
- data/test/views/layout2.test +0 -1
- data/test/views/layout2.wlang +0 -2
- data/test/views/nested.str +0 -1
- data/test/views/utf8.erb +0 -2
- data/test/wlang_test.rb +0 -87
- data/test/yajl_test.rb +0 -86
data/test/textile_test.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'redcloth'
|
5
|
-
|
6
|
-
class TextileTest < Minitest::Test
|
7
|
-
def textile_app(&block)
|
8
|
-
mock_app do
|
9
|
-
set :views, File.dirname(__FILE__) + '/views'
|
10
|
-
get('/', &block)
|
11
|
-
end
|
12
|
-
get '/'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'renders inline textile strings' do
|
16
|
-
textile_app { textile('h1. Hiya') }
|
17
|
-
assert ok?
|
18
|
-
assert_equal "<h1>Hiya</h1>", body
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders .textile files in views path' do
|
22
|
-
textile_app { textile(:hello) }
|
23
|
-
assert ok?
|
24
|
-
assert_equal "<h1>Hello From Textile</h1>", body
|
25
|
-
end
|
26
|
-
|
27
|
-
it "raises error if template not found" do
|
28
|
-
mock_app { get('/') { textile(:no_such_template) } }
|
29
|
-
assert_raises(Errno::ENOENT) { get('/') }
|
30
|
-
end
|
31
|
-
|
32
|
-
it "renders with inline layouts" do
|
33
|
-
mock_app do
|
34
|
-
layout { 'THIS. IS. #{yield.upcase}!' }
|
35
|
-
get('/') { textile('Sparta', :layout_engine => :str) }
|
36
|
-
end
|
37
|
-
get '/'
|
38
|
-
assert ok?
|
39
|
-
assert_like 'THIS. IS. <P>SPARTA</P>!', body
|
40
|
-
end
|
41
|
-
|
42
|
-
it "renders with file layouts" do
|
43
|
-
textile_app {
|
44
|
-
textile('Hello World', :layout => :layout2, :layout_engine => :erb)
|
45
|
-
}
|
46
|
-
assert ok?
|
47
|
-
assert_body "ERB Layout!\n<p>Hello World</p>"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "can be used in a nested fashion for partials and whatnot" do
|
51
|
-
mock_app do
|
52
|
-
template(:inner) { "hi" }
|
53
|
-
template(:outer) { "<outer><%= textile :inner %></outer>" }
|
54
|
-
get('/') { erb :outer }
|
55
|
-
end
|
56
|
-
|
57
|
-
get '/'
|
58
|
-
assert ok?
|
59
|
-
assert_like '<outer><p>hi</p></outer>', body
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
rescue LoadError
|
64
|
-
warn "#{$!.to_s}: skipping textile tests"
|
65
|
-
end
|
data/test/views/a/in_a.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Gimme an A!
|
data/test/views/ascii.erb
DELETED
data/test/views/b/in_b.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Gimme a B!
|
data/test/views/calc.html.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<%= 1 + 1 %>
|
data/test/views/error.builder
DELETED
data/test/views/error.erb
DELETED
data/test/views/error.haml
DELETED
data/test/views/error.sass
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<content>#{render :str, :hello, :layout => :layout2}</content>
|
data/test/views/foo/hello.test
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
from another views directory
|
data/test/views/hello.asciidoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
== Hello from AsciiDoc
|
data/test/views/hello.builder
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
xml.exclaim "You're my boy, #{@name}!"
|
data/test/views/hello.coffee
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
alert "Aye!"
|
data/test/views/hello.creole
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
= Hello From Creole
|
data/test/views/hello.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Hello <%= 'World' %>
|
data/test/views/hello.haml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
%h1 Hello From Haml
|
data/test/views/hello.less
DELETED
data/test/views/hello.liquid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Hello From Liquid</h1>
|
data/test/views/hello.mab
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
h1 "Hello From Markaby"
|
data/test/views/hello.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Hello From Markdown
|
data/test/views/hello.mediawiki
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
''Hello from MediaWiki''
|
data/test/views/hello.nokogiri
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
xml.exclaim "You're my boy, #{@name}!"
|
data/test/views/hello.rabl
DELETED
data/test/views/hello.radius
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Hello From Radius</h1>
|
data/test/views/hello.rdoc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
= Hello From RDoc
|
data/test/views/hello.sass
DELETED
data/test/views/hello.scss
DELETED
data/test/views/hello.slim
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
h1 Hello From Slim
|
data/test/views/hello.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<h1>Hello From String</h1>
|
data/test/views/hello.styl
DELETED
data/test/views/hello.test
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Hello World!
|
data/test/views/hello.textile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
h1. Hello From Textile
|
data/test/views/hello.wlang
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Hello from wlang!
|
data/test/views/hello.yajl
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
json = { :yajl => "hello" }
|
data/test/views/layout2.builder
DELETED
data/test/views/layout2.erb
DELETED
data/test/views/layout2.haml
DELETED
data/test/views/layout2.liquid
DELETED
data/test/views/layout2.mab
DELETED
data/test/views/layout2.nokogiri
DELETED
data/test/views/layout2.rabl
DELETED
data/test/views/layout2.radius
DELETED
data/test/views/layout2.slim
DELETED
data/test/views/layout2.str
DELETED
data/test/views/layout2.test
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Layout 2!
|
data/test/views/layout2.wlang
DELETED
data/test/views/nested.str
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
<content>#{render :str, :hello}</content>
|
data/test/views/utf8.erb
DELETED
data/test/wlang_test.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'wlang'
|
5
|
-
|
6
|
-
class WLangTest < Minitest::Test
|
7
|
-
def engine
|
8
|
-
Tilt::WLangTemplate
|
9
|
-
end
|
10
|
-
|
11
|
-
def wlang_app(&block)
|
12
|
-
mock_app {
|
13
|
-
set :views, File.dirname(__FILE__) + '/views'
|
14
|
-
get '/', &block
|
15
|
-
}
|
16
|
-
get '/'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'uses the correct engine' do
|
20
|
-
assert_equal engine, Tilt[:wlang]
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'renders .wlang files in views path' do
|
24
|
-
wlang_app { wlang :hello }
|
25
|
-
assert ok?
|
26
|
-
assert_equal "Hello from wlang!\n", body
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'renders in the app instance scope' do
|
30
|
-
mock_app do
|
31
|
-
helpers do
|
32
|
-
def who; "world"; end
|
33
|
-
end
|
34
|
-
get('/') { wlang 'Hello +{who}!' }
|
35
|
-
end
|
36
|
-
get '/'
|
37
|
-
assert ok?
|
38
|
-
assert_equal 'Hello world!', body
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'takes a :locals option' do
|
42
|
-
wlang_app do
|
43
|
-
locals = {:foo => 'Bar'}
|
44
|
-
wlang 'Hello ${foo}!', :locals => locals
|
45
|
-
end
|
46
|
-
assert ok?
|
47
|
-
assert_equal 'Hello Bar!', body
|
48
|
-
end
|
49
|
-
|
50
|
-
it "renders with inline layouts" do
|
51
|
-
mock_app do
|
52
|
-
layout { 'THIS. IS. +{yield.upcase}!' }
|
53
|
-
get('/') { wlang 'Sparta' }
|
54
|
-
end
|
55
|
-
get '/'
|
56
|
-
assert ok?
|
57
|
-
assert_equal 'THIS. IS. SPARTA!', body
|
58
|
-
end
|
59
|
-
|
60
|
-
it "renders with file layouts" do
|
61
|
-
wlang_app { wlang 'Hello World', :layout => :layout2 }
|
62
|
-
assert ok?
|
63
|
-
assert_body "WLang Layout!\nHello World"
|
64
|
-
end
|
65
|
-
|
66
|
-
it "can rendered truly nested layouts by accepting a layout and a block with the contents" do
|
67
|
-
mock_app do
|
68
|
-
template(:main_outer_layout) { "<h1>Title</h1>\n>{ yield }" }
|
69
|
-
template(:an_inner_layout) { "<h2>Subtitle</h2>\n>{ yield }" }
|
70
|
-
template(:a_page) { "<p>Contents.</p>\n" }
|
71
|
-
get('/') do
|
72
|
-
wlang :main_outer_layout, :layout => false do
|
73
|
-
wlang :an_inner_layout do
|
74
|
-
wlang :a_page
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
get '/'
|
80
|
-
assert ok?
|
81
|
-
assert_body "<h1>Title</h1>\n<h2>Subtitle</h2>\n<p>Contents.</p>\n"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
rescue LoadError
|
86
|
-
warn "#{$!.to_s}: skipping wlang tests"
|
87
|
-
end
|
data/test/yajl_test.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'yajl'
|
5
|
-
|
6
|
-
class YajlTest < Minitest::Test
|
7
|
-
def yajl_app(&block)
|
8
|
-
mock_app do
|
9
|
-
set :views, File.dirname(__FILE__) + '/views'
|
10
|
-
get('/', &block)
|
11
|
-
end
|
12
|
-
get '/'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'renders inline Yajl strings' do
|
16
|
-
yajl_app { yajl('json = { :foo => "bar" }') }
|
17
|
-
assert ok?
|
18
|
-
assert_body '{"foo":"bar"}'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'renders .yajl files in views path' do
|
22
|
-
yajl_app { yajl(:hello) }
|
23
|
-
assert ok?
|
24
|
-
assert_body '{"yajl":"hello"}'
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'raises error if template not found' do
|
28
|
-
mock_app { get('/') { yajl(:no_such_template) } }
|
29
|
-
assert_raises(Errno::ENOENT) { get('/') }
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'accepts a :locals option' do
|
33
|
-
yajl_app do
|
34
|
-
locals = { :object => { :foo => 'bar' } }
|
35
|
-
yajl 'json = object', :locals => locals
|
36
|
-
end
|
37
|
-
assert ok?
|
38
|
-
assert_body '{"foo":"bar"}'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'accepts a :scope option' do
|
42
|
-
yajl_app do
|
43
|
-
scope = { :object => { :foo => 'bar' } }
|
44
|
-
yajl 'json = self[:object]', :scope => scope
|
45
|
-
end
|
46
|
-
assert ok?
|
47
|
-
assert_body '{"foo":"bar"}'
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'decorates the json with a callback' do
|
51
|
-
yajl_app do
|
52
|
-
yajl(
|
53
|
-
'json = { :foo => "bar" }',
|
54
|
-
{ :callback => 'baz' }
|
55
|
-
)
|
56
|
-
end
|
57
|
-
assert ok?
|
58
|
-
assert_body 'baz({"foo":"bar"});'
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'decorates the json with a variable' do
|
62
|
-
yajl_app do
|
63
|
-
yajl(
|
64
|
-
'json = { :foo => "bar" }',
|
65
|
-
{ :variable => 'qux' }
|
66
|
-
)
|
67
|
-
end
|
68
|
-
assert ok?
|
69
|
-
assert_body 'var qux = {"foo":"bar"};'
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'decorates the json with a callback and a variable' do
|
73
|
-
yajl_app do
|
74
|
-
yajl(
|
75
|
-
'json = { :foo => "bar" }',
|
76
|
-
{ :callback => 'baz', :variable => 'qux' }
|
77
|
-
)
|
78
|
-
end
|
79
|
-
assert ok?
|
80
|
-
assert_body 'var qux = {"foo":"bar"}; baz(qux);'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
rescue LoadError
|
85
|
-
warn "#{$!.to_s}: skipping yajl tests"
|
86
|
-
end
|