lyre 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/lyre/app.rb +26 -7
  2. data/lib/lyre/version.rb +1 -1
  3. 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
- Capybara::Server.new(instance).tap do |server|
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
- instance.host = server.host
29
- instance.port = server.port
30
-
31
- setup_block.call(instance) if setup_block
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
@@ -1,3 +1,3 @@
1
1
  module Lyre
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: