sinatra-synchrony 0.0.2 → 0.0.3
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.
- data/Gemfile +2 -8
- data/Gemfile.lock +18 -20
- data/README.markdown +12 -5
- data/Rakefile +15 -0
- data/lib/sinatra/synchrony.rb +3 -2
- data/spec/synchrony_spec.rb +16 -2
- metadata +30 -7
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sinatra-synchrony (0.0.3)
|
5
|
+
async-rack (= 0.5.1)
|
6
|
+
em-http-request (= 0.3.0)
|
7
|
+
em-resolv-replace (= 1.1.1)
|
8
|
+
em-synchrony (= 0.2.0)
|
9
|
+
rack-fiber_pool (= 0.9.1)
|
10
|
+
sinatra (>= 1.0)
|
11
|
+
|
1
12
|
GEM
|
2
13
|
remote: http://rubygems.org/
|
3
14
|
specs:
|
@@ -8,8 +19,8 @@ GEM
|
|
8
19
|
ZenTest (~> 4.3)
|
9
20
|
ZenTest (4.5.0)
|
10
21
|
addressable (2.2.5)
|
11
|
-
|
12
|
-
|
22
|
+
async-rack (0.5.1)
|
23
|
+
rack (~> 1.1)
|
13
24
|
diff-lcs (1.1.2)
|
14
25
|
em-http-request (0.3.0)
|
15
26
|
addressable (>= 2.0.0)
|
@@ -22,26 +33,16 @@ GEM
|
|
22
33
|
eventmachine (0.12.10)
|
23
34
|
file-tail (1.0.5)
|
24
35
|
spruz (>= 0.1.0)
|
25
|
-
|
26
|
-
ruby_core_source (>= 0.1.4)
|
36
|
+
minitest (2.1.0)
|
27
37
|
predicated (0.2.2)
|
28
38
|
rack (1.2.2)
|
29
39
|
rack-fiber_pool (0.9.1)
|
30
40
|
rack-test (0.5.7)
|
31
41
|
rack (>= 1.0)
|
32
|
-
|
33
|
-
columnize (>= 0.3.1)
|
34
|
-
linecache19 (>= 0.5.11)
|
35
|
-
ruby_core_source (>= 0.1.4)
|
36
|
-
ruby-debug19 (0.11.6)
|
37
|
-
columnize (>= 0.3.1)
|
38
|
-
linecache19 (>= 0.5.11)
|
39
|
-
ruby-debug-base19 (>= 0.11.19)
|
42
|
+
rake (0.8.7)
|
40
43
|
ruby2ruby (1.2.5)
|
41
44
|
ruby_parser (~> 2.0)
|
42
45
|
sexp_processor (~> 3.0)
|
43
|
-
ruby_core_source (0.1.5)
|
44
|
-
archive-tar-minitar (>= 0.5.2)
|
45
46
|
ruby_parser (2.0.6)
|
46
47
|
sexp_processor (~> 3.0)
|
47
48
|
sexp_processor (3.0.5)
|
@@ -69,11 +70,8 @@ PLATFORMS
|
|
69
70
|
ruby
|
70
71
|
|
71
72
|
DEPENDENCIES
|
72
|
-
|
73
|
-
em-resolv-replace (= 1.1.1)
|
74
|
-
em-synchrony (= 0.2.0)
|
75
|
-
rack-fiber_pool (= 0.9.1)
|
73
|
+
minitest
|
76
74
|
rack-test (= 0.5.7)
|
77
|
-
|
78
|
-
sinatra
|
75
|
+
rake
|
76
|
+
sinatra-synchrony!
|
79
77
|
wrong (= 0.5.0)
|
data/README.markdown
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Announcement ##
|
2
|
+
|
3
|
+
**There is work underway to make this a Rack middleware, and integrate that middleware with this plugin. That way, many other frameworks can take advantage of this. There is also work underway to provide support for non-EventMachine Reactor pattern implementations with this approach. Stay tuned, amazing stuff coming very soon!**
|
4
|
+
|
1
5
|
Sinatra::Synchrony
|
2
6
|
===
|
3
7
|
|
@@ -28,16 +32,19 @@ Install the gem:
|
|
28
32
|
|
29
33
|
Register with Sinatra __at the top, before any other middleware or plugins are loaded__:
|
30
34
|
|
35
|
+
require 'sinatra/base'
|
31
36
|
require 'sinatra/synchrony'
|
32
37
|
class App < Sinatra::Base
|
33
38
|
register Sinatra::Synchrony
|
34
39
|
end
|
35
|
-
|
36
|
-
One important thing: __do not use Sinatra's internal session code__. So no "enable :sessions". Instead, enable the sessions directly via the [Rack::Session::Cookie](http://rack.rubyforge.org/doc/classes/Rack/Session/Cookie.html) middleware (there is no consequence to doing this, Sinatra does the same thing under the hood.. it just does it in the wrong load order):
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
If you are developing with a classic style app, just require the gem and it will automatically load:
|
42
|
+
|
43
|
+
require 'sinatra'
|
44
|
+
require 'sinatra/synchrony'
|
45
|
+
|
46
|
+
get '/' do
|
47
|
+
'Sinatra::Synchrony is loaded automatically in classic mode, nothing needed'
|
41
48
|
end
|
42
49
|
|
43
50
|
Tests
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
Bundler.setup
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require "rake/testtask"
|
7
|
+
|
8
|
+
desc "Run all tests"
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.libs << "spec"
|
11
|
+
t.test_files = FileList['spec/*_spec.rb']
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :test
|
data/lib/sinatra/synchrony.rb
CHANGED
@@ -13,8 +13,9 @@ $VERBOSE = original_verbosity
|
|
13
13
|
|
14
14
|
module Sinatra
|
15
15
|
module Synchrony
|
16
|
-
def
|
17
|
-
|
16
|
+
def setup_sessions(builder)
|
17
|
+
builder.use Rack::FiberPool unless test?
|
18
|
+
super
|
18
19
|
end
|
19
20
|
end
|
20
21
|
register Synchrony
|
data/spec/synchrony_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe 'A mock app' do
|
|
17
17
|
include Rack::Test::Methods
|
18
18
|
it 'successfully completes a sleep call' do
|
19
19
|
mock_app {
|
20
|
-
get '
|
20
|
+
get '/' do
|
21
21
|
EM::Synchrony.sleep(0.0001)
|
22
22
|
'ok'
|
23
23
|
end
|
@@ -26,4 +26,18 @@ describe 'A mock app' do
|
|
26
26
|
expect { last_response.ok? }
|
27
27
|
expect { last_response.body == 'ok' }
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
|
+
it 'works with cookie' do
|
31
|
+
mock_app {
|
32
|
+
set :session_secret, 'secret'
|
33
|
+
enable :sessions
|
34
|
+
get '/' do
|
35
|
+
session[:key] = 'val'
|
36
|
+
'ok'
|
37
|
+
end
|
38
|
+
}
|
39
|
+
get '/'
|
40
|
+
expect { last_response.ok? }
|
41
|
+
expect { last_response.headers['Set-Cookie'] }
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sinatra-synchrony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kyle Drake
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-09 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -80,27 +80,49 @@ dependencies:
|
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id006
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
|
-
name:
|
83
|
+
name: rake
|
84
84
|
prerelease: false
|
85
85
|
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rack-test
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
86
97
|
none: false
|
87
98
|
requirements:
|
88
99
|
- - "="
|
89
100
|
- !ruby/object:Gem::Version
|
90
101
|
version: 0.5.7
|
91
102
|
type: :development
|
92
|
-
version_requirements: *
|
103
|
+
version_requirements: *id008
|
93
104
|
- !ruby/object:Gem::Dependency
|
94
105
|
name: wrong
|
95
106
|
prerelease: false
|
96
|
-
requirement: &
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
97
108
|
none: false
|
98
109
|
requirements:
|
99
110
|
- - "="
|
100
111
|
- !ruby/object:Gem::Version
|
101
112
|
version: 0.5.0
|
102
113
|
type: :development
|
103
|
-
version_requirements: *
|
114
|
+
version_requirements: *id009
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: minitest
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
type: :development
|
125
|
+
version_requirements: *id010
|
104
126
|
description: Bootstraps in code required to take advantage of EventMachine/EM-Synchrony's concurrency enhancements for slow IO. Patches TCPSocket, which makes anything based on it EM-aware (including RestClient). Includes patch for tests. Requires ruby 1.9.
|
105
127
|
email:
|
106
128
|
- kyledrake@gmail.com
|
@@ -116,6 +138,7 @@ files:
|
|
116
138
|
- spec/synchrony_spec.rb
|
117
139
|
- Gemfile
|
118
140
|
- Gemfile.lock
|
141
|
+
- Rakefile
|
119
142
|
- README.markdown
|
120
143
|
has_rdoc: true
|
121
144
|
homepage: https://github.com/kyledrake/sinatra-synchrony
|
@@ -141,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
164
|
requirements: []
|
142
165
|
|
143
166
|
rubyforge_project: sinatra-synchrony
|
144
|
-
rubygems_version: 1.
|
167
|
+
rubygems_version: 1.6.2
|
145
168
|
signing_key:
|
146
169
|
specification_version: 3
|
147
170
|
summary: Bootstraps Sinatra with EM-Synchrony code, make TCPSocket EM-aware, provides support for tests
|