lyre 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lyre/app.rb +26 -7
- data/lib/lyre/version.rb +1 -1
- metadata +1 -1
data/lib/lyre/app.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'capybara'
|
3
|
+
require 'rack/handler/thin'
|
3
4
|
|
4
5
|
module Lyre
|
5
6
|
|
@@ -22,16 +23,22 @@ module Lyre
|
|
22
23
|
def boot
|
23
24
|
instance = self.new! #maybe just new
|
24
25
|
|
25
|
-
|
26
|
+
instance.startup
|
27
|
+
|
28
|
+
instance
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def startup
|
33
|
+
with_thin_runner do
|
34
|
+
Capybara::Server.new(self).tap do |server|
|
26
35
|
server.boot
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
setup_block.call(
|
37
|
+
self.host = server.host
|
38
|
+
self.port = server.port
|
39
|
+
|
40
|
+
self.class.setup_block.call(self) if self.class.setup_block
|
32
41
|
end
|
33
|
-
|
34
|
-
instance
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -42,6 +49,18 @@ module Lyre
|
|
42
49
|
def endpoint
|
43
50
|
"http://#{host}:#{port}"
|
44
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def with_thin_runner
|
56
|
+
default_server_process = Capybara.server
|
57
|
+
Capybara.server do |app, port|
|
58
|
+
Rack::Handler::Thin.run(app, :Port => port)
|
59
|
+
end
|
60
|
+
yield
|
61
|
+
ensure
|
62
|
+
Capybara.server(&default_server_process)
|
63
|
+
end
|
45
64
|
end
|
46
65
|
|
47
66
|
end
|
data/lib/lyre/version.rb
CHANGED