cramp 0.15 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,12 +15,15 @@ require 'active_support/buffered_logger'
15
15
 
16
16
  require 'rack'
17
17
 
18
- if RUBY_VERSION >= '1.9.1'
18
+ begin
19
+ require 'fiber'
19
20
  require File.join(File.dirname(__FILE__), 'vendor/fiber_pool')
21
+ rescue LoadError
22
+ # No fibers available!
20
23
  end
21
24
 
22
25
  module Cramp
23
- VERSION = '0.15'
26
+ VERSION = '0.15.1'
24
27
 
25
28
  mattr_accessor :logger
26
29
 
@@ -44,7 +44,9 @@ module Cramp
44
44
  end
45
45
 
46
46
  def build_headers
47
- respond_to?(:respond_with, true) ? respond_with : [200, {'Content-Type' => 'text/html'}]
47
+ status, headers = respond_to?(:respond_with, true) ? respond_with.dup : [200, {'Content-Type' => 'text/html'}]
48
+ headers['Connection'] ||= 'keep-alive'
49
+ [status, headers]
48
50
  end
49
51
 
50
52
  def init_async_body
@@ -88,7 +90,7 @@ module Cramp
88
90
  end
89
91
 
90
92
  def route_params
91
- @env['router.params'] || @env['usher.params']
93
+ @env['router.params'] || {}
92
94
  end
93
95
 
94
96
  private
@@ -38,9 +38,12 @@ module Cramp
38
38
  [status, headers.merge(self.default_sse_headers)]
39
39
  when :chunked
40
40
  status, headers = respond_to?(:respond_with, true) ? respond_with : [200, {}]
41
+
42
+ headers = headers.merge(self.default_chunked_headers)
41
43
  headers['Content-Type'] ||= 'text/html'
44
+ headers['Cache-Control'] ||= 'no-cache'
42
45
 
43
- [status, headers.merge(self.default_chunked_headers)]
46
+ [status, headers]
44
47
  else
45
48
  super
46
49
  end
@@ -109,7 +112,7 @@ module Cramp
109
112
  end
110
113
 
111
114
  def websockets_protocol_10?
112
- [8, 9, 10].include?(@env['HTTP_SEC_WEBSOCKET_VERSION'].to_i)
115
+ [7, 8, 9, 10].include?(@env['HTTP_SEC_WEBSOCKET_VERSION'].to_i)
113
116
  end
114
117
 
115
118
  def protocol10_parser
@@ -8,8 +8,8 @@ module Cramp
8
8
 
9
9
  module ClassMethods
10
10
  def use_fiber_pool(options = {})
11
- if RUBY_VERSION < '1.9.1'
12
- raise "Fibers are supported only for Rubies >= 1.9.1"
11
+ unless defined?(::FiberPool)
12
+ raise "Fiber support is only available for Rubies >= 1.9.2"
13
13
  end
14
14
 
15
15
  self.fiber_pool = ::FiberPool.new(options[:size] || 100)
@@ -14,10 +14,10 @@ gem 'async-rack'
14
14
  # For async Active Record models
15
15
  <% if active_record? -%>
16
16
  gem 'mysql2', '~> 0.2.11'
17
- gem 'activerecord'
17
+ gem 'activerecord', :require => 'active_record'
18
18
  <% else -%>
19
19
  # gem 'mysql2', '~> 0.2.11'
20
- # gem 'activerecord'
20
+ # gem 'activerecord', :require => 'active_record'
21
21
  <% end -%>
22
22
 
23
23
  # Using Fibers + async callbacks to emulate synchronous programming
@@ -10,7 +10,7 @@ module Cramp
10
10
  end
11
11
 
12
12
  def websocket?
13
- @env['HTTP_CONNECTION'] == 'Upgrade' && ['WebSocket', 'websocket'].include?(@env['HTTP_UPGRADE'])
13
+ ['WebSocket', 'websocket'].include?(@env['HTTP_UPGRADE'])
14
14
  end
15
15
 
16
16
  def secure_websocket?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cramp
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.15'
4
+ version: 0.15.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-13 00:00:00.000000000 +01:00
13
- default_executable:
12
+ date: 2011-08-30 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
- requirement: &2156847620 !ruby/object:Gem::Requirement
16
+ requirement: &2155605620 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: 3.0.9
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2156847620
24
+ version_requirements: *2155605620
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: rack
28
- requirement: &2156847100 !ruby/object:Gem::Requirement
27
+ requirement: &2155604860 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
@@ -33,10 +32,10 @@ dependencies:
33
32
  version: 1.3.2
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2156847100
35
+ version_requirements: *2155604860
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: eventmachine
39
- requirement: &2156846640 !ruby/object:Gem::Requirement
38
+ requirement: &2155604140 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -44,10 +43,10 @@ dependencies:
44
43
  version: 1.0.0.beta.3
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *2156846640
46
+ version_requirements: *2155604140
48
47
  - !ruby/object:Gem::Dependency
49
48
  name: thor
50
- requirement: &2156846160 !ruby/object:Gem::Requirement
49
+ requirement: &2155603680 !ruby/object:Gem::Requirement
51
50
  none: false
52
51
  requirements:
53
52
  - - ~>
@@ -55,7 +54,7 @@ dependencies:
55
54
  version: 0.14.6
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *2156846160
57
+ version_requirements: *2155603680
59
58
  description: Cramp is a framework for developing asynchronous web applications.
60
59
  email: pratiknaik@gmail.com
61
60
  executables:
@@ -92,7 +91,6 @@ files:
92
91
  - lib/cramp.rb
93
92
  - lib/vendor/fiber_pool.rb
94
93
  - bin/cramp
95
- has_rdoc: false
96
94
  homepage: http://cramp.in
97
95
  licenses: []
98
96
  post_install_message:
@@ -113,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
111
  version: '0'
114
112
  requirements: []
115
113
  rubyforge_project:
116
- rubygems_version: 1.6.2
114
+ rubygems_version: 1.8.6
117
115
  signing_key:
118
116
  specification_version: 3
119
117
  summary: Asynchronous web framework.