saorin 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/saorin/server.rb +6 -3
- data/lib/saorin/server/base.rb +2 -0
- data/lib/saorin/server/rack.rb +15 -4
- data/lib/saorin/test.rb +4 -3
- data/lib/saorin/version.rb +1 -1
- metadata +3 -3
data/lib/saorin/server.rb
CHANGED
@@ -6,12 +6,15 @@ module Saorin
|
|
6
6
|
self.load_path = 'saorin/server'
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def new(handler, options = {}
|
9
|
+
def new(handler, options = {})
|
10
10
|
adapter = options.delete(:adapter) || :rack
|
11
11
|
adapter_class = guess adapter
|
12
|
-
adapter_class.new handler, options
|
12
|
+
adapter_class.new handler, options
|
13
|
+
end
|
14
|
+
|
15
|
+
def start(handler, options = {}, &block)
|
16
|
+
new(handler, options).start(&block)
|
13
17
|
end
|
14
|
-
alias_method :start, :new
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/saorin/server/base.rb
CHANGED
@@ -7,11 +7,13 @@ module Saorin
|
|
7
7
|
module Server
|
8
8
|
module Base
|
9
9
|
attr_reader :handler, :allowed_methods
|
10
|
+
attr_reader :options
|
10
11
|
|
11
12
|
def initialize(handler, options = {})
|
12
13
|
@handler = handler
|
13
14
|
@allowed_methods = options[:allowed_methods] || handler.public_methods(false)
|
14
15
|
@allowed_methods.map! { |m| m.to_s }
|
16
|
+
@options = options
|
15
17
|
end
|
16
18
|
|
17
19
|
def process_request(content)
|
data/lib/saorin/server/rack.rb
CHANGED
@@ -10,14 +10,25 @@ module Saorin
|
|
10
10
|
'Content-Type' => 'application/json'
|
11
11
|
}.freeze
|
12
12
|
|
13
|
-
|
14
|
-
super handler, options
|
13
|
+
attr_reader :server
|
15
14
|
|
16
|
-
|
15
|
+
def initialize(handler, options = {})
|
16
|
+
super
|
17
|
+
@server = ::Rack::Server.new({
|
17
18
|
:app => self,
|
18
19
|
:Host => options[:host],
|
19
20
|
:Port => options[:port],
|
20
|
-
}.merge(options))
|
21
|
+
}.merge(@options))
|
22
|
+
end
|
23
|
+
|
24
|
+
def start(&block)
|
25
|
+
@server.start &block
|
26
|
+
end
|
27
|
+
|
28
|
+
def shutdown
|
29
|
+
if @server.server.respond_to?(:shutdown)
|
30
|
+
@server.server.shutdonw
|
31
|
+
end
|
21
32
|
end
|
22
33
|
|
23
34
|
def call(env)
|
data/lib/saorin/test.rb
CHANGED
@@ -49,19 +49,20 @@ module Saorin
|
|
49
49
|
|
50
50
|
def create_test_server(options = {})
|
51
51
|
@pid = Process.fork do
|
52
|
-
@server = Saorin::Server.
|
52
|
+
@server = Saorin::Server.new(Handler.new, {
|
53
53
|
:host => HOST,
|
54
54
|
:port => PORT,
|
55
55
|
:Logger => Logger.new('/dev/null'),
|
56
56
|
:AccessLog => [],
|
57
57
|
}.merge(options))
|
58
|
+
@server.start
|
58
59
|
end
|
59
|
-
sleep
|
60
|
+
sleep 2
|
60
61
|
end
|
61
62
|
|
62
63
|
def shutdown_test_server
|
63
64
|
Process.kill :INT, @pid
|
64
|
-
sleep
|
65
|
+
sleep 2
|
65
66
|
end
|
66
67
|
|
67
68
|
def create_test_client(options = {})
|
data/lib/saorin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saorin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
segments:
|
142
142
|
- 0
|
143
|
-
hash:
|
143
|
+
hash: 1175865570057102178
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
segments:
|
151
151
|
- 0
|
152
|
-
hash:
|
152
|
+
hash: 1175865570057102178
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
155
|
rubygems_version: 1.8.24
|