sinatra 0.3.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/AUTHORS +40 -0
- data/CHANGES +189 -0
- data/README.rdoc +146 -117
- data/Rakefile +33 -10
- data/{test → compat}/app_test.rb +11 -10
- data/{test → compat}/application_test.rb +10 -5
- data/compat/builder_test.rb +101 -0
- data/{test → compat}/custom_error_test.rb +0 -0
- data/compat/erb_test.rb +136 -0
- data/{test → compat}/events_test.rb +16 -3
- data/compat/filter_test.rb +30 -0
- data/compat/haml_test.rb +233 -0
- data/compat/helper.rb +30 -0
- data/compat/mapped_error_test.rb +72 -0
- data/{test → compat}/pipeline_test.rb +9 -4
- data/{test → compat}/public/foo.xml +0 -0
- data/compat/sass_test.rb +57 -0
- data/{test → compat}/sessions_test.rb +0 -0
- data/{test → compat}/streaming_test.rb +4 -1
- data/{test → compat}/sym_params_test.rb +0 -0
- data/{test → compat}/template_test.rb +0 -0
- data/{test → compat}/use_in_file_templates_test.rb +0 -0
- data/{test → compat}/views/foo.builder +0 -0
- data/{test → compat}/views/foo.erb +0 -0
- data/{test → compat}/views/foo.haml +0 -0
- data/{test → compat}/views/foo.sass +0 -0
- data/{test → compat}/views/foo_layout.erb +0 -0
- data/{test → compat}/views/foo_layout.haml +0 -0
- data/{test → compat}/views/layout_test/foo.builder +0 -0
- data/{test → compat}/views/layout_test/foo.erb +0 -0
- data/{test → compat}/views/layout_test/foo.haml +0 -0
- data/{test → compat}/views/layout_test/foo.sass +0 -0
- data/{test → compat}/views/layout_test/layout.builder +0 -0
- data/{test → compat}/views/layout_test/layout.erb +0 -0
- data/{test → compat}/views/layout_test/layout.haml +0 -0
- data/{test → compat}/views/layout_test/layout.sass +0 -0
- data/{test → compat}/views/no_layout/no_layout.builder +0 -0
- data/{test → compat}/views/no_layout/no_layout.haml +0 -0
- data/lib/sinatra.rb +6 -1484
- data/lib/sinatra/base.rb +838 -0
- data/lib/sinatra/compat.rb +239 -0
- data/{images → lib/sinatra/images}/404.png +0 -0
- data/{images → lib/sinatra/images}/500.png +0 -0
- data/lib/sinatra/main.rb +48 -0
- data/lib/sinatra/test.rb +114 -0
- data/lib/sinatra/test/bacon.rb +17 -0
- data/lib/sinatra/test/rspec.rb +7 -8
- data/lib/sinatra/test/spec.rb +3 -4
- data/lib/sinatra/test/unit.rb +3 -5
- data/sinatra.gemspec +68 -35
- data/test/base_test.rb +68 -0
- data/test/builder_test.rb +50 -87
- data/test/data/reload_app_file.rb +3 -0
- data/test/erb_test.rb +38 -124
- data/test/filter_test.rb +27 -22
- data/test/haml_test.rb +51 -216
- data/test/helper.rb +22 -6
- data/test/helpers_test.rb +361 -0
- data/test/mapped_error_test.rb +137 -49
- data/test/middleware_test.rb +58 -0
- data/test/options_test.rb +97 -0
- data/test/reload_test.rb +61 -0
- data/test/request_test.rb +18 -0
- data/test/result_test.rb +88 -0
- data/test/routing_test.rb +391 -0
- data/test/sass_test.rb +27 -48
- data/test/sinatra_test.rb +13 -0
- data/test/static_test.rb +57 -0
- data/test/templates_test.rb +88 -0
- data/test/views/hello.builder +1 -0
- data/test/views/hello.erb +1 -0
- data/test/views/hello.haml +1 -0
- data/test/views/hello.sass +2 -0
- data/test/views/hello.test +1 -0
- data/test/views/layout2.builder +3 -0
- data/test/views/layout2.erb +2 -0
- data/test/views/layout2.haml +2 -0
- data/test/views/layout2.test +1 -0
- metadata +80 -48
- data/ChangeLog +0 -96
- data/lib/sinatra/test/methods.rb +0 -76
- data/test/event_context_test.rb +0 -15
data/test/static_test.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
describe 'Static' do
|
4
|
+
F = ::File
|
5
|
+
|
6
|
+
before do
|
7
|
+
mock_app {
|
8
|
+
set :static, true
|
9
|
+
set :public, F.dirname(__FILE__)
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'serves GET requests for files in the public directory' do
|
14
|
+
get "/#{F.basename(__FILE__)}"
|
15
|
+
assert ok?
|
16
|
+
assert_equal File.read(__FILE__), body
|
17
|
+
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
18
|
+
assert response.headers.include?('Last-Modified')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'serves HEAD requests for files in the public directory' do
|
22
|
+
head "/#{F.basename(__FILE__)}"
|
23
|
+
assert ok?
|
24
|
+
assert_equal '', body
|
25
|
+
assert_equal File.size(__FILE__).to_s, response['Content-Length']
|
26
|
+
assert response.headers.include?('Last-Modified')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'serves files in preference to custom routes' do
|
30
|
+
@app.get("/#{F.basename(__FILE__)}") { 'Hello World' }
|
31
|
+
get "/#{F.basename(__FILE__)}"
|
32
|
+
assert ok?
|
33
|
+
assert body != 'Hello World'
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'does not serve directories' do
|
37
|
+
get "/"
|
38
|
+
assert not_found?
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'passes to the next handler when the static option is disabled' do
|
42
|
+
@app.set :static, false
|
43
|
+
get "/#{F.basename(__FILE__)}"
|
44
|
+
assert not_found?
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'passes to the next handler when the public option is nil' do
|
48
|
+
@app.set :public, nil
|
49
|
+
get "/#{F.basename(__FILE__)}"
|
50
|
+
assert not_found?
|
51
|
+
end
|
52
|
+
|
53
|
+
it '404s when a file is not found' do
|
54
|
+
get "/foobarbaz.txt"
|
55
|
+
assert not_found?
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
describe 'Templating' do
|
4
|
+
def render_app(&block)
|
5
|
+
mock_app {
|
6
|
+
def render_test(template, data, options, &block)
|
7
|
+
inner = block ? block.call : ''
|
8
|
+
data + inner
|
9
|
+
end
|
10
|
+
set :views, File.dirname(__FILE__) + '/views'
|
11
|
+
get '/', &block
|
12
|
+
template(:layout3) { "Layout 3!\n" }
|
13
|
+
}
|
14
|
+
get '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_default_layout
|
18
|
+
layout = File.dirname(__FILE__) + '/views/layout.test'
|
19
|
+
File.open(layout, 'wb') { |io| io.write "Layout!\n" }
|
20
|
+
yield
|
21
|
+
ensure
|
22
|
+
File.unlink(layout) rescue nil
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'renders String templates directly' do
|
26
|
+
render_app { render :test, 'Hello World' }
|
27
|
+
assert ok?
|
28
|
+
assert_equal 'Hello World', body
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'renders Proc templates using the call result' do
|
32
|
+
render_app { render :test, Proc.new {'Hello World'} }
|
33
|
+
assert ok?
|
34
|
+
assert_equal 'Hello World', body
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'looks up Symbol templates in views directory' do
|
38
|
+
render_app { render :test, :hello }
|
39
|
+
assert ok?
|
40
|
+
assert_equal "Hello World!\n", body
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'uses the default layout template if not explicitly overridden' do
|
44
|
+
with_default_layout do
|
45
|
+
render_app { render :test, :hello }
|
46
|
+
assert ok?
|
47
|
+
assert_equal "Layout!\nHello World!\n", body
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'uses the default layout template if not really overriden' do
|
52
|
+
with_default_layout do
|
53
|
+
render_app { render :test, :hello, :layout => true }
|
54
|
+
assert ok?
|
55
|
+
assert_equal "Layout!\nHello World!\n", body
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'uses the layout template specified' do
|
60
|
+
render_app { render :test, :hello, :layout => :layout2 }
|
61
|
+
assert ok?
|
62
|
+
assert_equal "Layout 2!\nHello World!\n", body
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'uses layout templates defined with the #template method' do
|
66
|
+
render_app { render :test, :hello, :layout => :layout3 }
|
67
|
+
assert ok?
|
68
|
+
assert_equal "Layout 3!\nHello World!\n", body
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'loads templates from source file with use_in_file_templates!' do
|
72
|
+
mock_app {
|
73
|
+
use_in_file_templates!
|
74
|
+
}
|
75
|
+
assert_equal "this is foo\n\n", @app.templates[:foo]
|
76
|
+
assert_equal "X\n= yield\nX\n", @app.templates[:layout]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
__END__
|
81
|
+
|
82
|
+
@@ foo
|
83
|
+
this is foo
|
84
|
+
|
85
|
+
@@ layout
|
86
|
+
X
|
87
|
+
= yield
|
88
|
+
X
|
@@ -0,0 +1 @@
|
|
1
|
+
xml.exclaim "You're my boy, #{@name}!"
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello <%= 'World' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 Hello From Haml
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello World!
|
@@ -0,0 +1 @@
|
|
1
|
+
Layout 2!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,12 +18,12 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.9.1
|
24
24
|
version:
|
25
25
|
description: Classy web-development dressed in a DSL
|
26
|
-
email:
|
26
|
+
email: sinatrarb@googlegroups.com
|
27
27
|
executables: []
|
28
28
|
|
29
29
|
extensions: []
|
@@ -32,53 +32,85 @@ extra_rdoc_files:
|
|
32
32
|
- README.rdoc
|
33
33
|
- LICENSE
|
34
34
|
files:
|
35
|
-
-
|
35
|
+
- AUTHORS
|
36
|
+
- CHANGES
|
36
37
|
- LICENSE
|
37
38
|
- README.rdoc
|
38
39
|
- Rakefile
|
39
|
-
-
|
40
|
-
-
|
40
|
+
- compat/app_test.rb
|
41
|
+
- compat/application_test.rb
|
42
|
+
- compat/builder_test.rb
|
43
|
+
- compat/custom_error_test.rb
|
44
|
+
- compat/erb_test.rb
|
45
|
+
- compat/events_test.rb
|
46
|
+
- compat/filter_test.rb
|
47
|
+
- compat/haml_test.rb
|
48
|
+
- compat/helper.rb
|
49
|
+
- compat/mapped_error_test.rb
|
50
|
+
- compat/pipeline_test.rb
|
51
|
+
- compat/public/foo.xml
|
52
|
+
- compat/sass_test.rb
|
53
|
+
- compat/sessions_test.rb
|
54
|
+
- compat/streaming_test.rb
|
55
|
+
- compat/sym_params_test.rb
|
56
|
+
- compat/template_test.rb
|
57
|
+
- compat/use_in_file_templates_test.rb
|
58
|
+
- compat/views/foo.builder
|
59
|
+
- compat/views/foo.erb
|
60
|
+
- compat/views/foo.haml
|
61
|
+
- compat/views/foo.sass
|
62
|
+
- compat/views/foo_layout.erb
|
63
|
+
- compat/views/foo_layout.haml
|
64
|
+
- compat/views/layout_test/foo.builder
|
65
|
+
- compat/views/layout_test/foo.erb
|
66
|
+
- compat/views/layout_test/foo.haml
|
67
|
+
- compat/views/layout_test/foo.sass
|
68
|
+
- compat/views/layout_test/layout.builder
|
69
|
+
- compat/views/layout_test/layout.erb
|
70
|
+
- compat/views/layout_test/layout.haml
|
71
|
+
- compat/views/layout_test/layout.sass
|
72
|
+
- compat/views/no_layout/no_layout.builder
|
73
|
+
- compat/views/no_layout/no_layout.haml
|
41
74
|
- lib/sinatra.rb
|
42
|
-
- lib/sinatra/
|
75
|
+
- lib/sinatra/base.rb
|
76
|
+
- lib/sinatra/compat.rb
|
77
|
+
- lib/sinatra/images/404.png
|
78
|
+
- lib/sinatra/images/500.png
|
79
|
+
- lib/sinatra/main.rb
|
80
|
+
- lib/sinatra/test.rb
|
81
|
+
- lib/sinatra/test/bacon.rb
|
43
82
|
- lib/sinatra/test/rspec.rb
|
44
83
|
- lib/sinatra/test/spec.rb
|
45
84
|
- lib/sinatra/test/unit.rb
|
46
85
|
- sinatra.gemspec
|
47
|
-
- test/
|
48
|
-
- test/application_test.rb
|
86
|
+
- test/base_test.rb
|
49
87
|
- test/builder_test.rb
|
50
|
-
- test/
|
88
|
+
- test/data/reload_app_file.rb
|
51
89
|
- test/erb_test.rb
|
52
|
-
- test/event_context_test.rb
|
53
|
-
- test/events_test.rb
|
54
90
|
- test/filter_test.rb
|
55
91
|
- test/haml_test.rb
|
56
92
|
- test/helper.rb
|
93
|
+
- test/helpers_test.rb
|
57
94
|
- test/mapped_error_test.rb
|
58
|
-
- test/
|
59
|
-
- test/
|
95
|
+
- test/middleware_test.rb
|
96
|
+
- test/options_test.rb
|
97
|
+
- test/reload_test.rb
|
98
|
+
- test/request_test.rb
|
99
|
+
- test/result_test.rb
|
100
|
+
- test/routing_test.rb
|
60
101
|
- test/sass_test.rb
|
61
|
-
- test/
|
62
|
-
- test/
|
63
|
-
- test/
|
64
|
-
- test/
|
65
|
-
- test/
|
66
|
-
- test/views/
|
67
|
-
- test/views/
|
68
|
-
- test/views/
|
69
|
-
- test/views/
|
70
|
-
- test/views/
|
71
|
-
- test/views/
|
72
|
-
- test/views/
|
73
|
-
- test/views/layout_test/foo.erb
|
74
|
-
- test/views/layout_test/foo.haml
|
75
|
-
- test/views/layout_test/foo.sass
|
76
|
-
- test/views/layout_test/layout.builder
|
77
|
-
- test/views/layout_test/layout.erb
|
78
|
-
- test/views/layout_test/layout.haml
|
79
|
-
- test/views/layout_test/layout.sass
|
80
|
-
- test/views/no_layout/no_layout.builder
|
81
|
-
- test/views/no_layout/no_layout.haml
|
102
|
+
- test/sinatra_test.rb
|
103
|
+
- test/static_test.rb
|
104
|
+
- test/templates_test.rb
|
105
|
+
- test/views/hello.builder
|
106
|
+
- test/views/hello.erb
|
107
|
+
- test/views/hello.haml
|
108
|
+
- test/views/hello.sass
|
109
|
+
- test/views/hello.test
|
110
|
+
- test/views/layout2.builder
|
111
|
+
- test/views/layout2.erb
|
112
|
+
- test/views/layout2.haml
|
113
|
+
- test/views/layout2.test
|
82
114
|
has_rdoc: true
|
83
115
|
homepage: http://sinatra.rubyforge.org
|
84
116
|
post_install_message:
|
@@ -111,20 +143,20 @@ signing_key:
|
|
111
143
|
specification_version: 2
|
112
144
|
summary: Classy web-development dressed in a DSL
|
113
145
|
test_files:
|
114
|
-
- test/
|
115
|
-
- test/application_test.rb
|
146
|
+
- test/base_test.rb
|
116
147
|
- test/builder_test.rb
|
117
|
-
- test/custom_error_test.rb
|
118
148
|
- test/erb_test.rb
|
119
|
-
- test/event_context_test.rb
|
120
|
-
- test/events_test.rb
|
121
149
|
- test/filter_test.rb
|
122
150
|
- test/haml_test.rb
|
151
|
+
- test/helpers_test.rb
|
123
152
|
- test/mapped_error_test.rb
|
124
|
-
- test/
|
153
|
+
- test/middleware_test.rb
|
154
|
+
- test/options_test.rb
|
155
|
+
- test/reload_test.rb
|
156
|
+
- test/request_test.rb
|
157
|
+
- test/result_test.rb
|
158
|
+
- test/routing_test.rb
|
125
159
|
- test/sass_test.rb
|
126
|
-
- test/
|
127
|
-
- test/
|
128
|
-
- test/
|
129
|
-
- test/template_test.rb
|
130
|
-
- test/use_in_file_templates_test.rb
|
160
|
+
- test/sinatra_test.rb
|
161
|
+
- test/static_test.rb
|
162
|
+
- test/templates_test.rb
|
data/ChangeLog
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
= 0.3.3 / 2009-01-06
|
2
|
-
|
3
|
-
* Pin to Rack 0.4.0 (this is the last release on Rack 0.4)
|
4
|
-
|
5
|
-
* Log unhandled exception backtraces to rack.errors.
|
6
|
-
|
7
|
-
* Use RACK_ENV environment variable to establish Sinatra
|
8
|
-
environment when given. Thin sets this when started with
|
9
|
-
the -e argument.
|
10
|
-
|
11
|
-
* BUG: raising Sinatra::NotFound resulted in a 500 response
|
12
|
-
code instead of 404.
|
13
|
-
|
14
|
-
* BUG: use_in_file_templates! failes with CR/LF (#45)
|
15
|
-
|
16
|
-
* BUG: Sinatra detects the app file and root path when run under
|
17
|
-
thin/passenger.
|
18
|
-
|
19
|
-
= 0.3.2
|
20
|
-
|
21
|
-
* BUG: Static and send_file read entire file into String before
|
22
|
-
sending. Updated to stream with 8K chunks instead.
|
23
|
-
|
24
|
-
* Rake tasks and assets for building basic documentation website.
|
25
|
-
See http://sinatra.rubyforge.org
|
26
|
-
|
27
|
-
* Various minor doc fixes.
|
28
|
-
|
29
|
-
= 0.3.1
|
30
|
-
|
31
|
-
* Unbreak optional path parameters [jeremyevans]
|
32
|
-
|
33
|
-
= 0.3.0
|
34
|
-
|
35
|
-
* Add sinatra.gemspec w/ support for github gem builds. Forks can now
|
36
|
-
enable the build gem option in github to get free username-sinatra.gem
|
37
|
-
builds: gem install username-sinatra.gem --source=http://gems.github.com/
|
38
|
-
|
39
|
-
* Require rack-0.4 gem; removes frozen rack dir.
|
40
|
-
|
41
|
-
* Basic RSpec support; require 'sinatra/test/rspec' instead of
|
42
|
-
'sinatra/test/spec' to use. [avdi]
|
43
|
-
|
44
|
-
* before filters can modify request environment vars used for
|
45
|
-
routing (e.g., PATH_INFO, REQUEST_METHOD, etc.) for URL rewriting
|
46
|
-
type functionality.
|
47
|
-
|
48
|
-
* In-file templates now uses @@ instead of ## as template separator.
|
49
|
-
|
50
|
-
* Top-level environment test predicates: development?, test?, production?
|
51
|
-
|
52
|
-
* Top-level "set", "enable", and "disable" methods for tweaking
|
53
|
-
app options. [rtomayko]
|
54
|
-
|
55
|
-
* Top-level "use" method for building Rack middleware pipelines
|
56
|
-
leading to app. See README for usage. [rtomayko]
|
57
|
-
|
58
|
-
* New "reload" option - set false to disable reloading in development.
|
59
|
-
|
60
|
-
* New "host" option - host/ip to bind to [cschneid]
|
61
|
-
|
62
|
-
* New "app_file" option - override the file to reload in development
|
63
|
-
mode [cschneid]
|
64
|
-
|
65
|
-
* Development error/not_found page cleanup [sr, adamwiggins]
|
66
|
-
|
67
|
-
* Remove a bunch of core extensions (String#to_param, String#from_param,
|
68
|
-
Hash#from_params, Hash#to_params, Hash#symbolize_keys, Hash#pass)
|
69
|
-
|
70
|
-
* Various grammar and formatting fixes to README; additions on
|
71
|
-
community and contributing [cypher]
|
72
|
-
|
73
|
-
* Build RDoc using Hanna template: http://sinatrarb.rubyforge.org/api
|
74
|
-
|
75
|
-
* Specs, documentation and fixes for splat'n routes [vic]
|
76
|
-
|
77
|
-
* Fix whitespace errors across all source files. [rtomayko]
|
78
|
-
|
79
|
-
* Fix streaming issues with Mongrel (body not closed). [bmizerany]
|
80
|
-
|
81
|
-
* Fix various issues with environment not being set properly (configure
|
82
|
-
blocks not running, error pages not registering, etc.) [cypher]
|
83
|
-
|
84
|
-
* Fix to allow locals to be passed to ERB templates [cschneid]
|
85
|
-
|
86
|
-
* Fix locking issues causing random errors during reload in development.
|
87
|
-
|
88
|
-
* Fix for escaped paths not resolving static files [Matthew Walker]
|
89
|
-
|
90
|
-
= 0.2.1
|
91
|
-
|
92
|
-
* File upload fix and minor tweaks.
|
93
|
-
|
94
|
-
= 0.2.0
|
95
|
-
|
96
|
-
* Initial gem release of 0.2 coebase.
|