sinatra 1.3.0 → 1.3.1
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/CHANGES +7 -2
- data/lib/sinatra/base.rb +10 -7
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +4 -4
- data/test/routing_test.rb +2 -0
- data/test/streaming_test.rb +15 -0
- metadata +17 -10
- data/.gitignore +0 -6
- data/.travis.yml +0 -16
data/CHANGES
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
= 1.3.
|
1
|
+
= 1.3.1 / Not Yet Released
|
2
|
+
|
3
|
+
* Support adding more than one callback to the stream object. (Konstantin
|
4
|
+
Haase)
|
5
|
+
|
6
|
+
= 1.3.0 / 2011-09-30
|
2
7
|
|
3
8
|
* Added `stream` helper method for easily creating streaming APIs, Server
|
4
9
|
Sent Events or even WebSockets. See README for more on that topic.
|
@@ -125,7 +130,7 @@
|
|
125
130
|
* Fix handling of broken query params when displaying exceptions. (Luke
|
126
131
|
Jahnke)
|
127
132
|
|
128
|
-
= 1.2.7 (backports release) /
|
133
|
+
= 1.2.7 (backports release) / 2011-09-30
|
129
134
|
|
130
135
|
Custom changes:
|
131
136
|
|
data/lib/sinatra/base.rb
CHANGED
@@ -247,11 +247,14 @@ module Sinatra
|
|
247
247
|
def self.defer(*) yield end
|
248
248
|
|
249
249
|
def initialize(scheduler = self.class, keep_open = false, &back)
|
250
|
-
@back, @scheduler, @
|
250
|
+
@back, @scheduler, @keep_open = back.to_proc, scheduler, keep_open
|
251
|
+
@callbacks, @closed = [], false
|
251
252
|
end
|
252
253
|
|
253
254
|
def close
|
254
|
-
|
255
|
+
return if @closed
|
256
|
+
@closed = true
|
257
|
+
@scheduler.schedule { @callbacks.each { |c| c.call }}
|
255
258
|
end
|
256
259
|
|
257
260
|
def each(&front)
|
@@ -272,7 +275,7 @@ module Sinatra
|
|
272
275
|
end
|
273
276
|
|
274
277
|
def callback(&block)
|
275
|
-
@
|
278
|
+
@callbacks << block
|
276
279
|
end
|
277
280
|
|
278
281
|
alias errback callback
|
@@ -845,7 +848,7 @@ module Sinatra
|
|
845
848
|
return unless path.start_with?(public_dir) and File.file?(path)
|
846
849
|
|
847
850
|
env['sinatra.static_file'] = path
|
848
|
-
cache_control
|
851
|
+
cache_control(*settings.static_cache_control) if settings.static_cache_control?
|
849
852
|
send_file path, :disposition => nil
|
850
853
|
end
|
851
854
|
|
@@ -1213,7 +1216,7 @@ module Sinatra
|
|
1213
1216
|
keys = []
|
1214
1217
|
if path.respond_to? :to_str
|
1215
1218
|
pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c) }
|
1216
|
-
pattern.gsub!
|
1219
|
+
pattern.gsub!(/((:\w+)|\*)/) do |match|
|
1217
1220
|
if match == "*"
|
1218
1221
|
keys << 'splat'
|
1219
1222
|
"(.*?)"
|
@@ -1360,8 +1363,8 @@ module Sinatra
|
|
1360
1363
|
|
1361
1364
|
def setup_protection(builder)
|
1362
1365
|
return unless protection?
|
1363
|
-
options = Hash === protection ? protection.dup : {
|
1364
|
-
options[:except] = Array
|
1366
|
+
options = Hash === protection ? protection.dup : {}
|
1367
|
+
options[:except] = Array(options[:except] || :escaped_params)
|
1365
1368
|
options[:except] += [:session_hijacking, :remote_token] unless sessions?
|
1366
1369
|
builder.use Rack::Protection, options
|
1367
1370
|
end
|
data/lib/sinatra/version.rb
CHANGED
data/sinatra.gemspec
CHANGED
@@ -7,12 +7,12 @@ Gem::Specification.new 'sinatra', Sinatra::VERSION do |s|
|
|
7
7
|
s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
|
8
8
|
s.email = "sinatrarb@googlegroups.com"
|
9
9
|
s.homepage = "http://www.sinatrarb.com/"
|
10
|
-
s.files = `git ls-files`.split("\n")
|
10
|
+
s.files = `git ls-files`.split("\n") - %w[.gitignore .travis.yml]
|
11
11
|
s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
|
12
12
|
s.extra_rdoc_files = s.files.select { |p| p =~ /^README/ } << 'LICENSE'
|
13
13
|
s.rdoc_options = %w[--line-numbers --inline-source --title Sinatra --main README.rdoc]
|
14
14
|
|
15
|
-
s.add_dependency 'rack', '~> 1.3'
|
16
|
-
s.add_dependency 'rack-protection', '~> 1.1'
|
17
|
-
s.add_dependency 'tilt', '~> 1.3'
|
15
|
+
s.add_dependency 'rack', '~> 1.3', '>= 1.3.4'
|
16
|
+
s.add_dependency 'rack-protection', '~> 1.1', '>= 1.1.2'
|
17
|
+
s.add_dependency 'tilt', '~> 1.3', '>= 1.3.3'
|
18
18
|
end
|
data/test/routing_test.rb
CHANGED
data/test/streaming_test.rb
CHANGED
@@ -56,6 +56,16 @@ class StreamingTest < Test::Unit::TestCase
|
|
56
56
|
assert_equal 0, final
|
57
57
|
end
|
58
58
|
|
59
|
+
it 'allows adding more than one callback' do
|
60
|
+
a = b = false
|
61
|
+
stream = Stream.new { }
|
62
|
+
stream.callback { a = true }
|
63
|
+
stream.callback { b = true }
|
64
|
+
stream.each { |str| }
|
65
|
+
assert a, 'should trigger first callback'
|
66
|
+
assert b, 'should trigger second callback'
|
67
|
+
end
|
68
|
+
|
59
69
|
class MockScheduler
|
60
70
|
def initialize(*) @schedule, @defer = [], [] end
|
61
71
|
def schedule(&block) @schedule << block end
|
@@ -97,4 +107,9 @@ class StreamingTest < Test::Unit::TestCase
|
|
97
107
|
scheduler.defer!
|
98
108
|
assert_raise(RuntimeError) { scheduler.schedule! }
|
99
109
|
end
|
110
|
+
|
111
|
+
it 'does not trigger an infinite loop if you call close in a callback' do
|
112
|
+
stream = Stream.new { |out| out.callback { out.close }}
|
113
|
+
stream.each { |str| }
|
114
|
+
end
|
100
115
|
end
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,41 +12,50 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2011-10-
|
15
|
+
date: 2011-10-05 00:00:00.000000000Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|
19
|
-
requirement: &
|
19
|
+
requirement: &2156366140 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ~>
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: '1.3'
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.3.4
|
25
28
|
type: :runtime
|
26
29
|
prerelease: false
|
27
|
-
version_requirements: *
|
30
|
+
version_requirements: *2156366140
|
28
31
|
- !ruby/object:Gem::Dependency
|
29
32
|
name: rack-protection
|
30
|
-
requirement: &
|
33
|
+
requirement: &2156364800 !ruby/object:Gem::Requirement
|
31
34
|
none: false
|
32
35
|
requirements:
|
33
36
|
- - ~>
|
34
37
|
- !ruby/object:Gem::Version
|
35
38
|
version: '1.1'
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.2
|
36
42
|
type: :runtime
|
37
43
|
prerelease: false
|
38
|
-
version_requirements: *
|
44
|
+
version_requirements: *2156364800
|
39
45
|
- !ruby/object:Gem::Dependency
|
40
46
|
name: tilt
|
41
|
-
requirement: &
|
47
|
+
requirement: &2156363420 !ruby/object:Gem::Requirement
|
42
48
|
none: false
|
43
49
|
requirements:
|
44
50
|
- - ~>
|
45
51
|
- !ruby/object:Gem::Version
|
46
52
|
version: '1.3'
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.3.3
|
47
56
|
type: :runtime
|
48
57
|
prerelease: false
|
49
|
-
version_requirements: *
|
58
|
+
version_requirements: *2156363420
|
50
59
|
description: Sinatra is a DSL for quickly creating web applications in Ruby with minimal
|
51
60
|
effort.
|
52
61
|
email: sinatrarb@googlegroups.com
|
@@ -65,8 +74,6 @@ extra_rdoc_files:
|
|
65
74
|
- README.zh.rdoc
|
66
75
|
- LICENSE
|
67
76
|
files:
|
68
|
-
- .gitignore
|
69
|
-
- .travis.yml
|
70
77
|
- .yardopts
|
71
78
|
- AUTHORS
|
72
79
|
- CHANGES
|
data/.gitignore
DELETED