rack-timeout 0.0.3 → 0.0.4

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjU4ZjQzOTJjZTcwNDdiZGZiZmU0YWI5NDMyMDRlYzU3Y2M3MTRjNQ==
5
+ data.tar.gz: !binary |-
6
+ ZGRlNjU2ZGExNWY2NTYxODU5ZTgyYmMxYWM4MmM2NmYxZDZlNzQ2Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZWIyMTg0ODVmM2JkMDE0YzUxZjcxZmNiZTYzMjQxZWZmMzc2YTJlMGQ4OTAz
10
+ NDBlMzczYTY5MDM4YTlkY2JiMTYwOGNjNDNhYTE3YzhiZDQyNjEwOTgxZjVi
11
+ ZjYxZDQxZWNiZDMxNzM5NzI4ZmUwMDU2NWJlNzJjNWM0YzM5M2Q=
12
+ data.tar.gz: !binary |-
13
+ YzQzMzU3MDAxMWY3Y2U4YzY3MjZhYmU4YmRlOGEzOTVjOTNkZWZjNjRiMDlk
14
+ NWZmMWQ1Zjk4ZjdiNThhOTJiMjQ0N2RhODYwNmQyZTYxM2I0NTM4ZTAzYjQ3
15
+ M2EwNmEzMzc1OWM4NmY3ZjhkYTgzMGJiYjNlODJmZGEyNWM2MWI=
data/README.markdown CHANGED
@@ -7,7 +7,12 @@ Abort requests that are taking too long; a Timeout::Error will be raised.
7
7
  Usage
8
8
  -----
9
9
 
10
- ### Rails 3 app or Rails 2.3 app with Bundler
10
+ ### Rails 3 app or Rails 2.3 app with Ruby 1.9 and Bundler
11
+
12
+ # Gemfile
13
+ gem "rack-timeout"
14
+
15
+ ### Rails 3 app or Rails 2.3 app with Ruby 1.8 and Bundler
11
16
 
12
17
  # Gemfile
13
18
  gem "SystemTimer", :require => "system_timer", :platforms => :ruby_18
@@ -17,18 +22,17 @@ Usage
17
22
  ### Rails 2.3 app without Bundler
18
23
 
19
24
  # config/environment.rb
20
- config.gem "SystemTimer", :require => "system_timer" if RUBY_VERSION < "1.9"
25
+ config.gem "SystemTimer", :lib => "system_timer" if RUBY_VERSION < "1.9"
21
26
  config.gem "rack-timeout"
22
27
 
23
28
 
24
29
  ### Sinatra and other Rack apps
25
30
 
26
31
  # config.ru
27
- require 'rack/timeout'
28
- use Rack::Timeout
32
+ require "rack/timeout"
33
+ use Rack::Timeout # call as early as possible so rack-timeout runs before other middlewares.
29
34
  Rack::Timeout.timeout = 10 # this line is optional. if omitted, default is 15 seconds.
30
35
 
31
-
32
36
  ### Setting a custom timeout for Rails apps
33
37
 
34
38
  # config/initializers/timeout.rb
@@ -37,10 +41,24 @@ Usage
37
41
 
38
42
  ### Here be dragons
39
43
 
40
- SystemTimer/timeout rely on threads. If your app or any of the libraries it depends on is
41
- not thread-safe, you may run into issues using rack-timeout.
44
+ SystemTimer/timeout rely on threads. If your app or any of the libraries it depends on is not thread-safe,
45
+ you may run into issues using rack-timeout.
46
+
47
+ Concurrent web servers such as [Unicorn][] and [Puma][] should work fine with rack-timeout.
48
+
49
+ [Unicorn]: http://unicorn.bogomips.org/
50
+ [Puma]: http://puma.io/
51
+
52
+ #### A note about testing timeouts in Rails apps
53
+
54
+ If you're trying to test that a `Timeout::Error` is being raised in your Rails application, please note that
55
+ it's **not possible in functional tests**. You *can*, however, test `assert_raises Rack::Timeout::Error`
56
+ in integration tests.
57
+
58
+ There are more details about general rack middleware testing with Rails in this [@pablobm's answer on Stack Overflow][pablobm].
42
59
 
60
+ [pablobm]: http://stackoverflow.com/a/8681208/13989
43
61
 
44
62
  ---
45
- Copyright © 2010 Caio Chassot, released under the MIT license
63
+ Copyright © 2010 Caio Chassot, released under the MIT license
46
64
  <http://github.com/kch/rack-timeout>
data/lib/rack-timeout.rb CHANGED
@@ -2,10 +2,10 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'rack/timeout')
2
2
 
3
3
  if defined? Rails
4
4
  case Rails::VERSION::MAJOR
5
- when 2; Rails.configuration.middleware.use Rack::Timeout
5
+ when 2; Rails.configuration.middleware.insert 0, Rack::Timeout
6
6
  when 3
7
7
  class Rack::Timeout::Railtie < Rails::Railtie
8
- initializer("rack-timeout.insert-rack-timeout") { |app| app.config.middleware.use Rack::Timeout }
8
+ initializer("rack-timeout.insert-rack-timeout") { |app| app.config.middleware.insert 0, Rack::Timeout }
9
9
  end
10
10
  end
11
11
  end
data/lib/rack/timeout.rb CHANGED
@@ -1,4 +1,4 @@
1
- require RUBY_VERSION < '1.9' ? 'system_timer' : 'timeout'
1
+ require RUBY_VERSION < '1.9' && RUBY_PLATFORM != 'java' ? 'system_timer' : 'timeout'
2
2
  SystemTimer ||= Timeout
3
3
 
4
4
  module Rack
metadata CHANGED
@@ -1,67 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-timeout
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Caio Chassot
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-07-13 00:00:00 -07:00
18
- default_executable:
11
+ date: 2013-04-25 00:00:00.000000000 Z
19
12
  dependencies: []
20
-
21
- description:
13
+ description: Rack middleware which aborts requests that have been running for longer
14
+ than a specified timeout.
22
15
  email: dev@caiochassot.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - MIT-LICENSE
31
21
  - README.markdown
32
22
  - lib/rack/timeout.rb
33
23
  - lib/rack-timeout.rb
34
- has_rdoc: true
35
24
  homepage: http://github.com/kch/rack-timeout
36
- licenses: []
37
-
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
38
28
  post_install_message:
39
29
  rdoc_options: []
40
-
41
- require_paths:
30
+ require_paths:
42
31
  - lib
43
- required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- segments:
49
- - 0
50
- version: "0"
51
- required_rubygems_version: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
- version: "0"
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
59
42
  requirements: []
60
-
61
43
  rubyforge_project:
62
- rubygems_version: 1.3.7
44
+ rubygems_version: 2.0.3
63
45
  signing_key:
64
- specification_version: 3
46
+ specification_version: 4
65
47
  summary: Abort requests that are taking too long
66
48
  test_files: []
67
-