sinatra-more-server 0.4.0.a

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/README.md ADDED
@@ -0,0 +1,64 @@
1
+ Sinatra::MoreServer
2
+ ===================
3
+
4
+ Adds support for more web servers to [Sinatra](http://sinatrarb.com)::Base#run!
5
+
6
+ Also, adds a helper method to ensure the server used from #run! supports async.callback, so all the
7
+ fancy comet implementations work.
8
+
9
+ BigBand
10
+ -------
11
+
12
+ Sinatra::MoreServer is part of the [BigBand](http://github.com/rkh/big_band) stack.
13
+ Check it out if you are looking for other fancy Sinatra extensions.
14
+
15
+ Additional Servers
16
+ ------------------
17
+
18
+ Out of the box, Sinatra supports:
19
+
20
+ * [Webrick](http://www.ruby-doc.org/stdlib/libdoc/webrick/rdoc/)
21
+ * [Thin](http://code.macournoyer.com/thin/)
22
+ * [Mongrel](http://mongrel.rubyforge.org/)
23
+
24
+ Currently, this extensions adds support for:
25
+
26
+ * [Unicorn](http://unicorn.bogomips.org/)
27
+ * [Rainbows!](http://rainbows.bogomips.org/)
28
+ * [Zbatery](http://zbatery.bogomip.org/)
29
+ * [Ebb](http://ebb.rubyforge.org/)
30
+
31
+ Usage
32
+ -----
33
+
34
+ Classic style:
35
+
36
+ require "sinatra"
37
+ require "sinatra/more_server"
38
+
39
+ Or in your own subclass:
40
+
41
+ require "sinatra/base"
42
+ require "sinatra/more_server"
43
+
44
+ class Foo < Sinatra::Base
45
+ register Sinatra::MoreServer
46
+ end
47
+
48
+ Async only, please!
49
+ -------------------
50
+
51
+ You use `async.callback`? Maybe via a library like [async\_sinatra](http://github.com/raggi/async_sinatra)
52
+ or [pusher](http://github.com/macournoyer/pusher)? Then you might want to make sure we only use a server
53
+ that supports it:
54
+
55
+ require "sinatra"
56
+ require "sinatra/more_server"
57
+
58
+ configure do
59
+ has_async_callback!
60
+ end
61
+
62
+ As mentioned above, this will only have effect on running your script directly. However, in any other case,
63
+ you will choose your server manually, anyway. (Hint: As far as I know, only thin- and rainbows!-based implementations
64
+ support async.callback at the moment.)
@@ -0,0 +1,13 @@
1
+ require "sinatra/more_server/unicorn"
2
+ require "rainbows"
3
+
4
+ class Sinatra
5
+ module MoreServer
6
+ # Rack Handler to use Rainbows for Sinatra::Base.run!
7
+ module Rainbows
8
+ def self.run(app, options = {})
9
+ Sinatra::MoreServer::Unicorn.run app, options.merge(:Backend => ::Rainbows)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require "sinatra/base"
2
+ require "unicorn"
3
+ require "rack/content_length"
4
+ require "rack/chunked"
5
+
6
+ class Sinatra
7
+ module MoreServer
8
+ # Rack Handler to use Unicorn for Sinatra::Base.run!
9
+ module Unicorn
10
+ def self.run(app, options={})
11
+ app = Rack::Builder.new do
12
+ # TODO: env dependend stuff.
13
+ use Rack::CommonLogger, $stderr
14
+ use Rack::ShowExceptions
15
+ run app
16
+ end.to_app
17
+ options[:Backend] ||= ::Unicorn
18
+ options[:Host] ||= ::Unicorn::Const::DEFAULT_HOST
19
+ options[:Port] ||= ::Unicorn::Const::DEFAULT_PORT
20
+ options[:listeners] = ["#{options.delete :Host}:#{options.delete :Port}"]
21
+ server = options.delete(:Backend)::HttpServer.new app, options
22
+ yield server if block_given?
23
+ server.start.join
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ require "sinatra/more_server/unicorn"
2
+ require "zbatery"
3
+
4
+ class Sinatra
5
+ module MoreServer
6
+ # Rack Handler to use Rainbows for Sinatra::Base.run!
7
+ module Rainbows
8
+ def self.run(app, options = {})
9
+ Sinatra::MoreServer::Unicorn.run app, options.merge(:Backend => ::Zbatery)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require "sinatra/base"
2
+
3
+ module Sinatra
4
+ # Adds more servers to Sinatra::Base#run! (currently unicorn and rainbows).
5
+ module MoreServer
6
+ autoload :Unicorn, "sinatra/more_server/unicorn"
7
+ autoload :Rainbows, "sinatra/more_server/rainbows"
8
+ autoload :Zbatery, "sinatra/more_server/zbatery"
9
+
10
+ def self.registered(klass)
11
+ ::Rack::Handler.register "unicorn", "::Sinatra::MoreServer::Unicorn"
12
+ ::Rack::Handler.register "rainbows", "::Sinatra::MoreServer::Rainbows"
13
+ ::Rack::Handler.register "zbatery", "::Sinatra::MoreServer::Zbatery"
14
+ ::Rack::Handler.register "ebb", "::Rack::Handler::Ebb"
15
+ ::Rack::Handler.autoload :Ebb, "ebb"
16
+ klass.server += ["ebb", "zbatery", "rainbows", "unicorn"]
17
+ klass.set :async_server, ["thin", "zbatery", "rainbows"]
18
+ end
19
+
20
+ def has_async_callback!
21
+ set :server, async_server
22
+ end
23
+
24
+ end
25
+
26
+ register MoreServer
27
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(__FILE__ + "/../../spec_helper.rb")
2
+
3
+ describe Sinatra::MoreServer do
4
+ before { app :MoreServer }
5
+
6
+ describe "additional server" do
7
+ it("should offer unicorn") { app.server.should include("unicorn") }
8
+ it("should offer rainbows") { app.server.should include("rainbows") }
9
+ it("should offer zbatery") { app.server.should include("zbatery") }
10
+ it("should offer ebb") { app.server.should include("ebb") }
11
+ end
12
+
13
+ describe "async_server" do
14
+ it("should not offer ebb as an async server") { app.async_server.should_not include("ebb") }
15
+ it("should not offer mongrel as an async server") { app.async_server.should_not include("mongrel") }
16
+ it("should not offer webrick as an async server") { app.async_server.should_not include("webrick") }
17
+ it("should not offer unicorn as an async server") { app.async_server.should_not include("unicorn") }
18
+
19
+ it("should offer thin as an async server") { app.async_server.should include("thin") }
20
+ it("should offer rainbows as an async server") { app.async_server.should include("rainbows") }
21
+ it("should offer zbatery as an async server") { app.async_server.should include("zbatery") }
22
+
23
+ it "uses async_server instead of server when async support is requested" do
24
+ app.has_async_callback!
25
+ app.server.should == app.async_server
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ require "sinatra/rspec"
2
+ require "sinatra/more_server"
3
+ Sinatra::Base.set :environment, :test
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra-more-server
3
+ version: &id001 !ruby/object:Gem::Version
4
+ version: 0.4.0.a
5
+ platform: ruby
6
+ authors:
7
+ - Konstantin Haase
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-15 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: monkey-lib
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "="
22
+ - *id001
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: sinatra-sugar
26
+ type: :runtime
27
+ version_requirement:
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "="
31
+ - *id001
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: sinatra-test-helper
35
+ type: :development
36
+ version_requirement:
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "="
40
+ - *id001
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: sinatra
44
+ type: :runtime
45
+ version_requirement:
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.9.4
51
+ version:
52
+ - !ruby/object:Gem::Dependency
53
+ name: rspec
54
+ type: :development
55
+ version_requirement:
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.3.0
61
+ version:
62
+ description: Adds more server to Sinatra::Base#run! (part of BigBand).
63
+ email: konstantin.mailinglists@googlemail.com
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ extra_rdoc_files: []
69
+
70
+ files:
71
+ - lib/sinatra/more_server/rainbows.rb
72
+ - lib/sinatra/more_server/unicorn.rb
73
+ - lib/sinatra/more_server/zbatery.rb
74
+ - lib/sinatra/more_server.rb
75
+ - spec/sinatra/more_server_spec.rb
76
+ - spec/spec_helper.rb
77
+ - README.md
78
+ has_rdoc: yard
79
+ homepage: http://github.com/rkh/sinatra-more-server
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">"
96
+ - !ruby/object:Gem::Version
97
+ version: 1.3.1
98
+ version:
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.3.5
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Adds more server to Sinatra::Base#run! (part of BigBand).
106
+ test_files: []
107
+