autobrewster 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/auto_brewster.rb +15 -11
- data/lib/auto_brewster/server.rb +5 -4
- metadata +3 -3
data/lib/auto_brewster.rb
CHANGED
@@ -4,18 +4,19 @@ require File.expand_path('../auto_brewster/cli', __FILE__)
|
|
4
4
|
|
5
5
|
module AutoBrewster
|
6
6
|
class << self
|
7
|
-
attr_accessor :server, :server_start, :server_port, :rackup_path, :hostname
|
7
|
+
attr_accessor :server, :server_start, :server_port, :rackup_path, :hostname, :server_timeout
|
8
8
|
attr_accessor :screen_widths, :url_paths
|
9
9
|
attr_accessor :path
|
10
|
-
attr_accessor :failfast
|
10
|
+
attr_accessor :debug, :failfast
|
11
11
|
|
12
12
|
def configure
|
13
13
|
yield self
|
14
14
|
end
|
15
15
|
|
16
16
|
def setup
|
17
|
-
|
18
|
-
|
17
|
+
include_support_env
|
18
|
+
include_support_pre_launch
|
19
|
+
@server = AutoBrewster::Server.new(server, server_port, server_timeout, rackup_path, hostname)
|
19
20
|
@screenshot = AutoBrewster::Screenshot.new(@server, path, url_paths, screen_widths)
|
20
21
|
end
|
21
22
|
|
@@ -53,16 +54,17 @@ module AutoBrewster
|
|
53
54
|
|
54
55
|
def run_default_server(app, port)
|
55
56
|
require 'rack/handler/thin'
|
56
|
-
Thin::Logging.silent = true
|
57
|
+
Thin::Logging.silent = true unless debug
|
57
58
|
Rack::Handler::Thin.run(app, :Port => port, :AccessLog => [])
|
58
59
|
end
|
59
60
|
|
61
|
+
def include_support_post_launch
|
62
|
+
Dir.glob("#{path}/support/post_launch/*.rb").map { |file| require file }
|
63
|
+
end
|
64
|
+
|
60
65
|
private
|
61
|
-
def
|
62
|
-
|
63
|
-
Dir.glob("#{path}/support/*.rb").map do |file|
|
64
|
-
require file unless file.end_with?('/env.rb')
|
65
|
-
end
|
66
|
+
def include_support_pre_launch
|
67
|
+
Dir.glob("#{path}/support/pre_launch/*.rb").map { |file| require file }
|
66
68
|
end
|
67
69
|
|
68
70
|
def include_support_env
|
@@ -75,10 +77,12 @@ end
|
|
75
77
|
AutoBrewster.configure do |config|
|
76
78
|
config.server_start = true
|
77
79
|
config.server_port = 5001
|
78
|
-
config.path = "#{Dir.pwd}/test/
|
80
|
+
config.path = "#{Dir.pwd}/test/autobrewster"
|
79
81
|
config.rackup_path = 'config.ru'
|
80
82
|
config.server {|app, port| AutoBrewster.run_default_server(app, port)}
|
83
|
+
config.server_timeout = 10
|
81
84
|
config.hostname = false
|
85
|
+
config.debug = true
|
82
86
|
config.failfast = false
|
83
87
|
config.screen_widths = [320, 1024]
|
84
88
|
config.url_paths = {
|
data/lib/auto_brewster/server.rb
CHANGED
@@ -10,30 +10,31 @@ module AutoBrewster
|
|
10
10
|
:hostname,
|
11
11
|
:app
|
12
12
|
|
13
|
-
def initialize(server, port, rackup_path = 'config.ru', hostname = false)
|
13
|
+
def initialize(server, port, timeout = 10, rackup_path = 'config.ru', hostname = false)
|
14
14
|
ENV['RACK_ENV'] ||= 'test'
|
15
15
|
|
16
16
|
@port = port
|
17
17
|
@server = server
|
18
|
+
@timeout = timeout
|
18
19
|
@rackup_path = rackup_path
|
19
20
|
@hostname = hostname
|
20
21
|
@app = build_rack_app
|
21
|
-
|
22
22
|
@middleware = AutoBrewster::Middleware.new(@app)
|
23
23
|
end
|
24
24
|
|
25
25
|
def start
|
26
26
|
@server_thread = Thread.new do
|
27
|
+
AutoBrewster.include_support_post_launch
|
27
28
|
@server.call(@middleware, @port)
|
28
29
|
end
|
29
30
|
|
30
|
-
Timeout.timeout(
|
31
|
+
Timeout.timeout(@timeout) { @server_thread.join(0.1) until responsive? }
|
31
32
|
end
|
32
33
|
|
33
34
|
def stop
|
34
35
|
return if @server_thread.nil?
|
35
36
|
@server_thread.kill
|
36
|
-
Timeout.timeout(
|
37
|
+
Timeout.timeout(@timeout) { @server_thread.join(0.1) until !responsive? }
|
37
38
|
end
|
38
39
|
|
39
40
|
def get_host_with_protocol_and_port
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chris Blackburn
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-08-
|
17
|
+
date: 2013-08-28 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|