async_sinatra 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/CHANGELOG.rdoc +10 -1
- data/Manifest.txt +2 -0
- data/lib/async_sinatra.rb +2 -2
- data/lib/sinatra/async.rb +8 -6
- data/lib/sinatra/async/test.rb +3 -3
- data/test/gemloader.rb +11 -0
- data/test/test_async.rb +35 -6
- metadata +15 -13
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/.gemtest
ADDED
File without changes
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
=== 0.
|
1
|
+
=== 0.5.0 / 2011-03-08
|
2
|
+
|
3
|
+
* Fix support for conditional routes!
|
4
|
+
* Modified assert_async assertion to add error message [JamesAlmond]
|
5
|
+
* Move to minitest and add dependency loader
|
6
|
+
* Support sinatra 1.2.0
|
7
|
+
* Add support for options (sinatra 1.2.0)
|
8
|
+
* Add support for gemtest
|
9
|
+
|
10
|
+
=== 0.4.0
|
2
11
|
|
3
12
|
* 1 major enhancement
|
4
13
|
|
data/Manifest.txt
CHANGED
data/lib/async_sinatra.rb
CHANGED
data/lib/sinatra/async.rb
CHANGED
@@ -56,10 +56,12 @@ module Sinatra #:nodoc:
|
|
56
56
|
def adelete(path, opts={}, &bk); aroute 'DELETE', path, opts, &bk; end
|
57
57
|
# See #aget.
|
58
58
|
def ahead(path, opts={}, &bk); aroute 'HEAD', path, opts, &bk; end
|
59
|
+
# See #aget
|
60
|
+
def aoptions(path, opts={}, &bk); aroute 'OPTIONS', path, opts, &bk; end
|
59
61
|
|
60
62
|
private
|
61
63
|
def aroute(verb, path, opts = {}, &block) #:nodoc:
|
62
|
-
method = "A#{verb} #{path}"
|
64
|
+
method = :"A#{verb} #{path} #{opts.hash}"
|
63
65
|
define_method method, &block
|
64
66
|
|
65
67
|
route(verb, path, opts) do |*bargs|
|
@@ -89,9 +91,9 @@ module Sinatra #:nodoc:
|
|
89
91
|
# is wrapped up so that exceptions and halts (redirect, etc) are handled
|
90
92
|
# correctly.
|
91
93
|
def async_schedule(&b)
|
92
|
-
if
|
93
|
-
|
94
|
-
|
94
|
+
if settings.environment == :test
|
95
|
+
settings.set :async_schedules, [] unless settings.respond_to? :async_schedules
|
96
|
+
settings.async_schedules << lambda { async_catch_execute(&b) }
|
95
97
|
else
|
96
98
|
native_async_schedule { async_catch_execute(&b) }
|
97
99
|
end
|
@@ -127,7 +129,7 @@ module Sinatra #:nodoc:
|
|
127
129
|
def async_handle_exception
|
128
130
|
yield
|
129
131
|
rescue ::Exception => boom
|
130
|
-
if
|
132
|
+
if settings.show_exceptions?
|
131
133
|
printer = Sinatra::ShowExceptions.new(proc{ raise boom })
|
132
134
|
s, h, b = printer.call(request.env)
|
133
135
|
response.status = s
|
@@ -159,4 +161,4 @@ module Sinatra #:nodoc:
|
|
159
161
|
app.helpers Helpers
|
160
162
|
end
|
161
163
|
end
|
162
|
-
end
|
164
|
+
end
|
data/lib/sinatra/async/test.rb
CHANGED
@@ -51,7 +51,7 @@ class Sinatra::Async::Test
|
|
51
51
|
module Methods
|
52
52
|
include Rack::Test::Methods
|
53
53
|
|
54
|
-
%w(get put post delete head).each do |m|
|
54
|
+
%w(get put post delete head options).each do |m|
|
55
55
|
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
|
56
56
|
def a#{m}(*args)
|
57
57
|
#{m}(*args)
|
@@ -66,7 +66,7 @@ class Sinatra::Async::Test
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def assert_async
|
69
|
-
assert last_response.async
|
69
|
+
assert last_response.async?, "response not asynchronous. expected a status of -1 got #{last_response.status}"
|
70
70
|
end
|
71
71
|
|
72
72
|
# Simulate a user closing the connection before a response is sent.
|
@@ -105,4 +105,4 @@ class Sinatra::Async::Test
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
|
-
end
|
108
|
+
end
|
data/test/gemloader.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
begin
|
3
|
+
project = File.basename(Dir['*.gemspec'].first, '.gemspec')
|
4
|
+
gemspec = File.expand_path("#{project}.gemspec", Dir.pwd)
|
5
|
+
spec = Gem::Specification.load(gemspec)
|
6
|
+
(spec.dependencies + spec.development_dependencies).each do |dep|
|
7
|
+
gem dep.name, dep.requirement.to_s
|
8
|
+
end
|
9
|
+
rescue
|
10
|
+
warn "#{__FILE__}: Can't preload project dependencies: #{$!}"
|
11
|
+
end
|
data/test/test_async.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
require 'gemloader'
|
2
|
+
require 'minitest/autorun'
|
3
3
|
|
4
4
|
require 'eventmachine'
|
5
5
|
|
6
6
|
require "sinatra/async/test"
|
7
7
|
|
8
|
-
class TestSinatraAsync <
|
8
|
+
class TestSinatraAsync < MiniTest::Unit::TestCase
|
9
9
|
include Sinatra::Async::Test::Methods
|
10
10
|
|
11
11
|
class TestApp < Sinatra::Base
|
@@ -78,6 +78,18 @@ class TestSinatraAsync < Test::Unit::TestCase
|
|
78
78
|
em_async_schedule { redirect '/' }
|
79
79
|
end
|
80
80
|
|
81
|
+
aget '/agents', :agent => /chrome/ do
|
82
|
+
body { 'chrome' }
|
83
|
+
end
|
84
|
+
|
85
|
+
aget '/agents', :agent => /firefox/ do
|
86
|
+
body { 'firefox' }
|
87
|
+
end
|
88
|
+
|
89
|
+
aget '/agents' do
|
90
|
+
body { 'other' }
|
91
|
+
end
|
92
|
+
|
81
93
|
# Defeat the test environment semantics, ensuring we actually follow the
|
82
94
|
# non-test branch of async_schedule. You would normally just call
|
83
95
|
# async_schedule in user apps, and use test helpers appropriately.
|
@@ -93,7 +105,7 @@ class TestSinatraAsync < Test::Unit::TestCase
|
|
93
105
|
def app
|
94
106
|
TestApp.new
|
95
107
|
end
|
96
|
-
|
108
|
+
|
97
109
|
def assert_redirect(path)
|
98
110
|
r = last_request.env
|
99
111
|
uri = r['rack.url_scheme'] + '://' + r['SERVER_NAME'] + path
|
@@ -119,7 +131,7 @@ class TestSinatraAsync < Test::Unit::TestCase
|
|
119
131
|
def test_em_async_continue_timeout
|
120
132
|
get '/em_timeout'
|
121
133
|
assert_async
|
122
|
-
assert_raises(
|
134
|
+
assert_raises(MiniTest::Assertion) do
|
123
135
|
em_async_continue(0.001)
|
124
136
|
end
|
125
137
|
end
|
@@ -194,4 +206,21 @@ class TestSinatraAsync < Test::Unit::TestCase
|
|
194
206
|
assert_equal 302, last_response.status
|
195
207
|
assert_redirect '/'
|
196
208
|
end
|
197
|
-
|
209
|
+
|
210
|
+
def test_route_conditions_no_match
|
211
|
+
aget '/agents'
|
212
|
+
assert_equal 'other', last_response.body
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_route_conditions_first
|
216
|
+
header "User-Agent", "chrome"
|
217
|
+
aget '/agents'
|
218
|
+
assert_equal 'chrome', last_response.body
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_route_conditions_second
|
222
|
+
header "User-Agent", "firefox"
|
223
|
+
aget '/agents'
|
224
|
+
assert_equal 'firefox', last_response.body
|
225
|
+
end
|
226
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async_sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- raggi
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
WjgTOJft4S4=
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
39
|
+
date: 2011-03-08 00:00:00 -08:00
|
40
40
|
default_executable:
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -78,12 +78,12 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
hash:
|
81
|
+
hash: 11
|
82
82
|
segments:
|
83
|
-
-
|
84
|
-
- 6
|
83
|
+
- 2
|
85
84
|
- 0
|
86
|
-
|
85
|
+
- 2
|
86
|
+
version: 2.0.2
|
87
87
|
type: :development
|
88
88
|
version_requirements: *id003
|
89
89
|
- !ruby/object:Gem::Dependency
|
@@ -200,12 +200,12 @@ dependencies:
|
|
200
200
|
requirements:
|
201
201
|
- - ">="
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
hash:
|
203
|
+
hash: 41
|
204
204
|
segments:
|
205
205
|
- 2
|
206
|
-
-
|
207
|
-
-
|
208
|
-
version: 2.
|
206
|
+
- 9
|
207
|
+
- 1
|
208
|
+
version: 2.9.1
|
209
209
|
type: :development
|
210
210
|
version_requirements: *id011
|
211
211
|
description: |-
|
@@ -231,6 +231,7 @@ extra_rdoc_files:
|
|
231
231
|
- CHANGELOG.rdoc
|
232
232
|
- README.rdoc
|
233
233
|
files:
|
234
|
+
- .gemtest
|
234
235
|
- CHANGELOG.rdoc
|
235
236
|
- Manifest.txt
|
236
237
|
- README.rdoc
|
@@ -239,6 +240,7 @@ files:
|
|
239
240
|
- lib/async_sinatra.rb
|
240
241
|
- lib/sinatra/async.rb
|
241
242
|
- lib/sinatra/async/test.rb
|
243
|
+
- test/gemloader.rb
|
242
244
|
- test/test_async.rb
|
243
245
|
has_rdoc: true
|
244
246
|
homepage: http://github.com/raggi/async_sinatra
|
@@ -271,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
273
|
requirements: []
|
272
274
|
|
273
275
|
rubyforge_project: libraggi
|
274
|
-
rubygems_version: 1.
|
276
|
+
rubygems_version: 1.6.0
|
275
277
|
signing_key:
|
276
278
|
specification_version: 3
|
277
279
|
summary: A Sinatra plugin to provide convenience whilst performing asynchronous responses inside of the Sinatra framework running under async webservers
|
metadata.gz.sig
CHANGED
Binary file
|