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 CHANGED
Binary file
File without changes
@@ -1,4 +1,13 @@
1
- === 0.4.0 / <%= Time.new.strftime("%Y-%m-%d") %>
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
 
@@ -1,3 +1,4 @@
1
+ .gemtest
1
2
  CHANGELOG.rdoc
2
3
  Manifest.txt
3
4
  README.rdoc
@@ -6,4 +7,5 @@ examples/basic.ru
6
7
  lib/async_sinatra.rb
7
8
  lib/sinatra/async.rb
8
9
  lib/sinatra/async/test.rb
10
+ test/gemloader.rb
9
11
  test/test_async.rb
@@ -2,5 +2,5 @@ require 'sinatra/async'
2
2
  # This is just a stub module for documentation and versioning. Please see
3
3
  # Sinatra::Async.
4
4
  module AsyncSinatra
5
- VERSION = '0.4.0'
6
- end
5
+ VERSION = '0.5.0'
6
+ end
@@ -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}".to_sym
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 options.environment == :test
93
- options.set :async_schedules, [] unless options.respond_to? :async_schedules
94
- options.async_schedules << lambda { async_catch_execute(&b) }
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 options.show_exceptions?
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
@@ -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
@@ -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
@@ -1,11 +1,11 @@
1
- gem 'test-unit'
2
- require "test/unit"
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 < Test::Unit::TestCase
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(Test::Unit::AssertionFailedError) do
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
- end
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: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.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-01-02 00:00:00 -05:00
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: 15
81
+ hash: 11
82
82
  segments:
83
- - 1
84
- - 6
83
+ - 2
85
84
  - 0
86
- version: 1.6.0
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: 47
203
+ hash: 41
204
204
  segments:
205
205
  - 2
206
- - 8
207
- - 0
208
- version: 2.8.0
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.4.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