sanford 0.7.0 → 0.8.0
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/bench/runner.rb +7 -7
- data/bench/services.rb +1 -3
- data/lib/sanford/host.rb +13 -32
- data/lib/sanford/host_data.rb +4 -11
- data/lib/sanford/runner.rb +1 -1
- data/lib/sanford/test_runner.rb +1 -1
- data/lib/sanford/version.rb +1 -1
- data/lib/sanford/worker.rb +1 -3
- data/sanford.gemspec +3 -2
- data/test/support/fake_connection.rb +2 -2
- data/test/support/services.rb +10 -13
- data/test/support/simple_client.rb +2 -2
- data/test/system/request_handling_tests.rb +10 -33
- data/test/unit/host_data_tests.rb +7 -7
- data/test/unit/host_tests.rb +13 -5
- data/test/unit/runner_tests.rb +1 -1
- data/test/unit/worker_tests.rb +1 -1
- metadata +22 -24
- data/test/unit/host_version_group_tests.rb +0 -39
data/bench/runner.rb
CHANGED
@@ -10,7 +10,7 @@ module Bench
|
|
10
10
|
HOST_AND_PORT = [ '127.0.0.1', 59284 ]
|
11
11
|
|
12
12
|
REQUESTS = [
|
13
|
-
[ '
|
13
|
+
[ 'simple', {}, 10000 ]
|
14
14
|
]
|
15
15
|
|
16
16
|
TIME_MODIFIER = 10 ** 4 # 4 decimal places
|
@@ -24,19 +24,19 @@ module Bench
|
|
24
24
|
def build_report
|
25
25
|
output "Running benchmark report..."
|
26
26
|
|
27
|
-
REQUESTS.each do |
|
28
|
-
self.benchmark_service(
|
27
|
+
REQUESTS.each do |name, params, times|
|
28
|
+
self.benchmark_service(name, params, times, false)
|
29
29
|
end
|
30
30
|
|
31
31
|
output "Done running benchmark report"
|
32
32
|
end
|
33
33
|
|
34
|
-
def benchmark_service(
|
34
|
+
def benchmark_service(name, params, times, show_result = false)
|
35
35
|
benchmarks = []
|
36
36
|
|
37
37
|
output "\nHitting #{name.inspect} service with #{params.inspect}, #{times} times"
|
38
38
|
[*(1..times.to_i)].each do |index|
|
39
|
-
benchmark = self.hit_service(
|
39
|
+
benchmark = self.hit_service(name, params.merge({ :request_number => index }), show_result)
|
40
40
|
benchmarks << self.round_time(benchmark.real * 1000.to_f)
|
41
41
|
output('.', false) if ((index - 1) % 100 == 0) && !show_result
|
42
42
|
end
|
@@ -73,11 +73,11 @@ module Bench
|
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
-
def hit_service(
|
76
|
+
def hit_service(name, params, show_result)
|
77
77
|
Benchmark.measure do
|
78
78
|
begin
|
79
79
|
client = Bench::Client.new(*HOST_AND_PORT)
|
80
|
-
response = client.call(
|
80
|
+
response = client.call(name, params)
|
81
81
|
if show_result
|
82
82
|
output "Got a response:"
|
83
83
|
output " #{response.status}"
|
data/bench/services.rb
CHANGED
data/lib/sanford/host.rb
CHANGED
@@ -43,11 +43,12 @@ module Sanford
|
|
43
43
|
Sanford.register(host_class)
|
44
44
|
end
|
45
45
|
|
46
|
-
attr_reader :configuration, :
|
46
|
+
attr_reader :configuration, :services
|
47
47
|
|
48
48
|
def initialize
|
49
49
|
@configuration = Configuration.new(self)
|
50
|
-
@
|
50
|
+
@service_handler_ns = nil
|
51
|
+
@services = {}
|
51
52
|
end
|
52
53
|
|
53
54
|
def name(*args)
|
@@ -90,9 +91,16 @@ module Sanford
|
|
90
91
|
self.configuration.init_proc = block
|
91
92
|
end
|
92
93
|
|
93
|
-
def
|
94
|
-
|
95
|
-
@
|
94
|
+
def service_handler_ns(value = nil)
|
95
|
+
@service_handler_ns = value if value
|
96
|
+
@service_handler_ns
|
97
|
+
end
|
98
|
+
|
99
|
+
def service(service_name, handler_class_name)
|
100
|
+
if @service_handler_ns && !(handler_class_name =~ /^::/)
|
101
|
+
handler_class_name = "#{@service_handler_ns}::#{handler_class_name}"
|
102
|
+
end
|
103
|
+
@services[service_name] = handler_class_name
|
96
104
|
end
|
97
105
|
|
98
106
|
def inspect
|
@@ -103,33 +111,6 @@ module Sanford
|
|
103
111
|
|
104
112
|
protected
|
105
113
|
|
106
|
-
class VersionGroup
|
107
|
-
attr_reader :name, :services
|
108
|
-
|
109
|
-
def initialize(name, &definition_block)
|
110
|
-
@name = name
|
111
|
-
@services = {}
|
112
|
-
self.instance_eval(&definition_block)
|
113
|
-
end
|
114
|
-
|
115
|
-
def service_handler_ns(value = nil)
|
116
|
-
@service_handler_ns = value if value
|
117
|
-
@service_handler_ns
|
118
|
-
end
|
119
|
-
|
120
|
-
def service(service_name, handler_class_name)
|
121
|
-
if self.service_handler_ns && !(handler_class_name =~ /^::/)
|
122
|
-
handler_class_name = "#{self.service_handler_ns}::#{handler_class_name}"
|
123
|
-
end
|
124
|
-
@services[service_name] = handler_class_name
|
125
|
-
end
|
126
|
-
|
127
|
-
def to_hash
|
128
|
-
{ self.name => self.services }
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
114
|
module ClassMethods
|
134
115
|
|
135
116
|
# the class level of a `Host` should just proxy it's methods down to it's
|
data/lib/sanford/host_data.rb
CHANGED
@@ -27,8 +27,8 @@ module Sanford
|
|
27
27
|
@runner = configuration[:runner]
|
28
28
|
@error_procs = configuration[:error_procs]
|
29
29
|
|
30
|
-
@handlers = service_host.
|
31
|
-
|
30
|
+
@handlers = service_host.services.inject({}) do |h, (name, handler_class_name)|
|
31
|
+
h.merge({ name => self.constantize(handler_class_name) })
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -36,19 +36,12 @@ module Sanford
|
|
36
36
|
self.runner.new(handler_class, request, self.logger).run
|
37
37
|
end
|
38
38
|
|
39
|
-
def handler_class_for(
|
40
|
-
|
41
|
-
version_group[service] || raise(Sanford::NotFoundError)
|
39
|
+
def handler_class_for(service)
|
40
|
+
@handlers[service] || raise(Sanford::NotFoundError)
|
42
41
|
end
|
43
42
|
|
44
43
|
protected
|
45
44
|
|
46
|
-
def constantize_services(services)
|
47
|
-
services.inject({}) do |hash, (name, handler_class_name)|
|
48
|
-
hash.merge({ name => self.constantize(handler_class_name) })
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
45
|
def constantize(handler_class_name)
|
53
46
|
Sanford::ServiceHandler.constantize(handler_class_name) ||
|
54
47
|
raise(Sanford::NoHandlerClassError.new(handler_class_name))
|
data/lib/sanford/runner.rb
CHANGED
@@ -54,7 +54,7 @@ module Sanford
|
|
54
54
|
module ClassMethods
|
55
55
|
|
56
56
|
def run(handler_class, params = nil, logger = nil)
|
57
|
-
request = Sanford::Protocol::Request.new('
|
57
|
+
request = Sanford::Protocol::Request.new('name', params || {})
|
58
58
|
self.new(handler_class, request, logger).run
|
59
59
|
end
|
60
60
|
|
data/lib/sanford/test_runner.rb
CHANGED
data/lib/sanford/version.rb
CHANGED
data/lib/sanford/worker.rb
CHANGED
@@ -42,7 +42,7 @@ module Sanford
|
|
42
42
|
self.log_request(request)
|
43
43
|
service.request = request
|
44
44
|
|
45
|
-
handler_class = @host_data.handler_class_for(request.
|
45
|
+
handler_class = @host_data.handler_class_for(request.name)
|
46
46
|
self.log_handler_class(handler_class)
|
47
47
|
service.handler_class = handler_class
|
48
48
|
|
@@ -84,7 +84,6 @@ module Sanford
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def log_request(request)
|
87
|
-
log_verbose " Version: #{request.version.inspect}"
|
88
87
|
log_verbose " Service: #{request.name.inspect}"
|
89
88
|
log_verbose " Params: #{request.params.inspect}"
|
90
89
|
end
|
@@ -104,7 +103,6 @@ module Sanford
|
|
104
103
|
summary_line_args['status'] = processed_service.response.code
|
105
104
|
end
|
106
105
|
if (request = processed_service.request)
|
107
|
-
summary_line_args['version'] = request.version
|
108
106
|
summary_line_args['service'] = request.name
|
109
107
|
summary_line_args['params'] = request.params
|
110
108
|
end
|
data/sanford.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.description = "Sanford TCP protocol server for hosting services"
|
12
12
|
gem.summary = "Sanford TCP protocol server for hosting services"
|
13
13
|
gem.homepage = "https://github.com/redding/sanford"
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -19,8 +20,8 @@ Gem::Specification.new do |gem|
|
|
19
20
|
|
20
21
|
gem.add_dependency("dat-tcp", ["~>0.4"])
|
21
22
|
gem.add_dependency("ns-options", ["~>1.0"])
|
22
|
-
gem.add_dependency("sanford-protocol", ["~>0.
|
23
|
+
gem.add_dependency("sanford-protocol", ["~>0.6"])
|
23
24
|
|
24
|
-
gem.add_development_dependency("assert", ["~>2.
|
25
|
+
gem.add_development_dependency("assert", ["~>2.3"])
|
25
26
|
gem.add_development_dependency("assert-mocha", ["~>1.0"])
|
26
27
|
end
|
@@ -2,8 +2,8 @@ class FakeConnection
|
|
2
2
|
|
3
3
|
attr_reader :read_data, :response, :write_stream_closed
|
4
4
|
|
5
|
-
def self.with_request(
|
6
|
-
request = Sanford::Protocol::Request.new(
|
5
|
+
def self.with_request(name, params = {}, raise_on_write = false)
|
6
|
+
request = Sanford::Protocol::Request.new(name, params)
|
7
7
|
self.new(request.to_hash, raise_on_write)
|
8
8
|
end
|
9
9
|
|
data/test/support/services.rb
CHANGED
@@ -24,16 +24,14 @@ class TestHost
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
service 'custom_error', 'CustomError'
|
36
|
-
end
|
27
|
+
service_handler_ns 'TestHost'
|
28
|
+
|
29
|
+
service 'echo', 'Echo'
|
30
|
+
service 'bad', 'Bad'
|
31
|
+
service 'multiply', 'Multiply'
|
32
|
+
service 'halt_it', '::TestHost::HaltIt'
|
33
|
+
service 'authorized', 'Authorized'
|
34
|
+
service 'custom_error', 'CustomError'
|
37
35
|
|
38
36
|
class Echo
|
39
37
|
include Sanford::ServiceHandler
|
@@ -116,9 +114,8 @@ class UndefinedHandlersHost
|
|
116
114
|
|
117
115
|
port 12345
|
118
116
|
|
119
|
-
|
120
|
-
|
121
|
-
end
|
117
|
+
service 'undefined', 'ThisIsNotDefined'
|
118
|
+
|
122
119
|
end
|
123
120
|
|
124
121
|
class EmptyHost
|
@@ -2,8 +2,8 @@ require 'sanford-protocol/test/fake_socket'
|
|
2
2
|
|
3
3
|
class SimpleClient
|
4
4
|
|
5
|
-
def self.call_with_request(service_host,
|
6
|
-
self.new(service_host).call_with_request(
|
5
|
+
def self.call_with_request(service_host, name, params)
|
6
|
+
self.new(service_host).call_with_request(name, params)
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.call_with_msg_body(service_host, *args)
|
@@ -26,7 +26,7 @@ class RequestHandlingTests < Assert::Context
|
|
26
26
|
class EchoTests < FakeConnectionTests
|
27
27
|
desc "running a request for the echo server"
|
28
28
|
setup do
|
29
|
-
@connection = FakeConnection.with_request('
|
29
|
+
@connection = FakeConnection.with_request('echo', { :message => 'test' })
|
30
30
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
31
31
|
end
|
32
32
|
|
@@ -47,33 +47,10 @@ class RequestHandlingTests < Assert::Context
|
|
47
47
|
|
48
48
|
end
|
49
49
|
|
50
|
-
class MissingServiceVersionTests < FakeConnectionTests
|
51
|
-
desc "running a request with no service version"
|
52
|
-
setup do
|
53
|
-
request_hash = Sanford::Protocol::Request.new('v1', 'what', {}).to_hash
|
54
|
-
request_hash.delete('version')
|
55
|
-
@connection = FakeConnection.new(request_hash)
|
56
|
-
@worker = Sanford::Worker.new(@host_data, @connection)
|
57
|
-
end
|
58
|
-
|
59
|
-
should "return a bad request response" do
|
60
|
-
assert_raises(Sanford::Protocol::BadRequestError) do
|
61
|
-
@worker.run
|
62
|
-
end
|
63
|
-
response = @connection.response
|
64
|
-
|
65
|
-
assert_equal 400, response.code
|
66
|
-
assert_match "request", response.status.message
|
67
|
-
assert_match "version", response.status.message
|
68
|
-
assert_equal nil, response.data
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
50
|
class MissingServiceNameTests < FakeConnectionTests
|
74
51
|
desc "running a request with no service name"
|
75
52
|
setup do
|
76
|
-
request_hash = Sanford::Protocol::Request.new('
|
53
|
+
request_hash = Sanford::Protocol::Request.new('what', {}).to_hash
|
77
54
|
request_hash.delete('name')
|
78
55
|
@connection = FakeConnection.new(request_hash)
|
79
56
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
@@ -96,7 +73,7 @@ class RequestHandlingTests < Assert::Context
|
|
96
73
|
class NotFoundServiceTests < FakeConnectionTests
|
97
74
|
desc "running a request with no matching service name"
|
98
75
|
setup do
|
99
|
-
@connection = FakeConnection.with_request('
|
76
|
+
@connection = FakeConnection.with_request('what', {})
|
100
77
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
101
78
|
end
|
102
79
|
|
@@ -116,7 +93,7 @@ class RequestHandlingTests < Assert::Context
|
|
116
93
|
class ErrorServiceTests < FakeConnectionTests
|
117
94
|
desc "running a request that errors on the server"
|
118
95
|
setup do
|
119
|
-
@connection = FakeConnection.with_request('
|
96
|
+
@connection = FakeConnection.with_request('bad', {})
|
120
97
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
121
98
|
end
|
122
99
|
|
@@ -136,7 +113,7 @@ class RequestHandlingTests < Assert::Context
|
|
136
113
|
class HaltTests < FakeConnectionTests
|
137
114
|
desc "running a request that halts"
|
138
115
|
setup do
|
139
|
-
@connection = FakeConnection.with_request('
|
116
|
+
@connection = FakeConnection.with_request('halt_it', {})
|
140
117
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
141
118
|
end
|
142
119
|
|
@@ -154,7 +131,7 @@ class RequestHandlingTests < Assert::Context
|
|
154
131
|
class AuthorizeRequestTests < FakeConnectionTests
|
155
132
|
desc "running a request that halts in a callback"
|
156
133
|
setup do
|
157
|
-
@connection = FakeConnection.with_request('
|
134
|
+
@connection = FakeConnection.with_request('authorized', {})
|
158
135
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
159
136
|
end
|
160
137
|
|
@@ -172,7 +149,7 @@ class RequestHandlingTests < Assert::Context
|
|
172
149
|
class WithCustomErrorHandlerTests < FakeConnectionTests
|
173
150
|
desc "running a request that triggers our custom error handler"
|
174
151
|
setup do
|
175
|
-
@connection = FakeConnection.with_request('
|
152
|
+
@connection = FakeConnection.with_request('custom_error', {})
|
176
153
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
177
154
|
end
|
178
155
|
|
@@ -190,7 +167,7 @@ class RequestHandlingTests < Assert::Context
|
|
190
167
|
class WithBadResponseHashTests < FakeConnectionTests
|
191
168
|
desc "running a request that builds an object that can't be encoded"
|
192
169
|
setup do
|
193
|
-
@connection = FakeConnection.with_request('
|
170
|
+
@connection = FakeConnection.with_request('echo', { :message => 'cant encode' }, true)
|
194
171
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
195
172
|
end
|
196
173
|
|
@@ -247,7 +224,7 @@ class RequestHandlingTests < Assert::Context
|
|
247
224
|
|
248
225
|
should "return a successful response and echo the params sent to it" do
|
249
226
|
self.start_server(TestHost) do
|
250
|
-
response = SimpleClient.call_with_request(TestHost, '
|
227
|
+
response = SimpleClient.call_with_request(TestHost, 'echo', {
|
251
228
|
:message => 'test'
|
252
229
|
})
|
253
230
|
|
@@ -317,7 +294,7 @@ class RequestHandlingTests < Assert::Context
|
|
317
294
|
should "timeout" do
|
318
295
|
self.start_server(TestHost) do
|
319
296
|
client = SimpleClient.new(TestHost, :with_delay => 1)
|
320
|
-
response = client.call_with_request('
|
297
|
+
response = client.call_with_request('echo', { :message => 'test' })
|
321
298
|
|
322
299
|
assert_equal 408, response.code
|
323
300
|
assert_equal nil, response.status.message
|
@@ -34,20 +34,20 @@ class Sanford::HostData
|
|
34
34
|
|
35
35
|
should "constantize a host's handlers" do
|
36
36
|
handlers = subject.instance_variable_get("@handlers")
|
37
|
-
assert_equal TestHost::Authorized, handlers['
|
38
|
-
assert_equal TestHost::Bad, handlers['
|
39
|
-
assert_equal TestHost::Echo, handlers['
|
40
|
-
assert_equal TestHost::HaltIt, handlers['
|
41
|
-
assert_equal TestHost::Multiply, handlers['
|
37
|
+
assert_equal TestHost::Authorized, handlers['authorized']
|
38
|
+
assert_equal TestHost::Bad, handlers['bad']
|
39
|
+
assert_equal TestHost::Echo, handlers['echo']
|
40
|
+
assert_equal TestHost::HaltIt, handlers['halt_it']
|
41
|
+
assert_equal TestHost::Multiply, handlers['multiply']
|
42
42
|
end
|
43
43
|
|
44
44
|
should "look up handler classes with #handler_class_for" do
|
45
|
-
assert_equal TestHost::Echo, subject.handler_class_for('
|
45
|
+
assert_equal TestHost::Echo, subject.handler_class_for('echo')
|
46
46
|
end
|
47
47
|
|
48
48
|
should "raise a custom error when handler_class_for is called with an unknown service" do
|
49
49
|
assert_raises(Sanford::NotFoundError) do
|
50
|
-
subject.handler_class_for('
|
50
|
+
subject.handler_class_for('not_defined')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
data/test/unit/host_tests.rb
CHANGED
@@ -13,8 +13,8 @@ module Sanford::Host
|
|
13
13
|
subject{ MyHost.instance }
|
14
14
|
|
15
15
|
should have_instance_methods :configuration, :name, :ip, :port, :pid_file,
|
16
|
-
:logger, :verbose_logging, :runner, :error, :init, :
|
17
|
-
:
|
16
|
+
:logger, :verbose_logging, :runner, :error, :init, :service_handler_ns,
|
17
|
+
:service, :services
|
18
18
|
|
19
19
|
should "get and set it's configuration options with their matching methods" do
|
20
20
|
subject.name 'my_awesome_host'
|
@@ -23,10 +23,18 @@ module Sanford::Host
|
|
23
23
|
assert_equal subject.configuration.port, subject.port
|
24
24
|
end
|
25
25
|
|
26
|
-
should "
|
27
|
-
subject.
|
26
|
+
should "allow adding a service with #service" do
|
27
|
+
subject.service_handler_ns 'MyNamespace'
|
28
|
+
subject.service('test', 'MyServiceHandler')
|
28
29
|
|
29
|
-
assert_equal
|
30
|
+
assert_equal 'MyNamespace::MyServiceHandler', subject.services['test']
|
31
|
+
end
|
32
|
+
|
33
|
+
should "ignore a namespace when a service class has leading colons" do
|
34
|
+
subject.service_handler_ns 'MyNamespace'
|
35
|
+
subject.service('test', '::MyServiceHandler')
|
36
|
+
|
37
|
+
assert_equal '::MyServiceHandler', subject.services['test']
|
30
38
|
end
|
31
39
|
|
32
40
|
end
|
data/test/unit/runner_tests.rb
CHANGED
@@ -5,7 +5,7 @@ module Sanford::Runner
|
|
5
5
|
class BaseTests < Assert::Context
|
6
6
|
desc "Sanford::Runner"
|
7
7
|
setup do
|
8
|
-
request = Sanford::Protocol::Request.new('
|
8
|
+
request = Sanford::Protocol::Request.new('test', {})
|
9
9
|
@runner = Sanford::DefaultRunner.new(BasicServiceHandler, request)
|
10
10
|
end
|
11
11
|
subject{ @runner }
|
data/test/unit/worker_tests.rb
CHANGED
@@ -9,7 +9,7 @@ class Sanford::Worker
|
|
9
9
|
desc "Sanford::Worker"
|
10
10
|
setup do
|
11
11
|
@host_data = Sanford::HostData.new(TestHost)
|
12
|
-
@connection = FakeConnection.with_request('
|
12
|
+
@connection = FakeConnection.with_request('service', {})
|
13
13
|
@worker = Sanford::Worker.new(@host_data, @connection)
|
14
14
|
end
|
15
15
|
subject{ @worker }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanford
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Collin Redding
|
@@ -16,10 +16,9 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2013-
|
19
|
+
date: 2013-10-14 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
prerelease: false
|
23
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
23
|
none: false
|
25
24
|
requirements:
|
@@ -30,11 +29,11 @@ dependencies:
|
|
30
29
|
- 0
|
31
30
|
- 4
|
32
31
|
version: "0.4"
|
32
|
+
type: :runtime
|
33
33
|
requirement: *id001
|
34
|
+
prerelease: false
|
34
35
|
name: dat-tcp
|
35
|
-
type: :runtime
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
prerelease: false
|
38
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
@@ -45,41 +44,41 @@ dependencies:
|
|
45
44
|
- 1
|
46
45
|
- 0
|
47
46
|
version: "1.0"
|
47
|
+
type: :runtime
|
48
48
|
requirement: *id002
|
49
|
+
prerelease: false
|
49
50
|
name: ns-options
|
50
|
-
type: :runtime
|
51
51
|
- !ruby/object:Gem::Dependency
|
52
|
-
prerelease: false
|
53
52
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
53
|
none: false
|
55
54
|
requirements:
|
56
55
|
- - ~>
|
57
56
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
57
|
+
hash: 7
|
59
58
|
segments:
|
60
59
|
- 0
|
61
|
-
-
|
62
|
-
version: "0.
|
60
|
+
- 6
|
61
|
+
version: "0.6"
|
62
|
+
type: :runtime
|
63
63
|
requirement: *id003
|
64
|
+
prerelease: false
|
64
65
|
name: sanford-protocol
|
65
|
-
type: :runtime
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
-
prerelease: false
|
68
67
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
68
|
none: false
|
70
69
|
requirements:
|
71
70
|
- - ~>
|
72
71
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
72
|
+
hash: 5
|
74
73
|
segments:
|
75
74
|
- 2
|
76
|
-
-
|
77
|
-
version: "2.
|
75
|
+
- 3
|
76
|
+
version: "2.3"
|
77
|
+
type: :development
|
78
78
|
requirement: *id004
|
79
|
+
prerelease: false
|
79
80
|
name: assert
|
80
|
-
type: :development
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
-
prerelease: false
|
83
82
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
84
|
requirements:
|
@@ -90,9 +89,10 @@ dependencies:
|
|
90
89
|
- 1
|
91
90
|
- 0
|
92
91
|
version: "1.0"
|
92
|
+
type: :development
|
93
93
|
requirement: *id005
|
94
|
+
prerelease: false
|
94
95
|
name: assert-mocha
|
95
|
-
type: :development
|
96
96
|
description: Sanford TCP protocol server for hosting services
|
97
97
|
email:
|
98
98
|
- collin.redding@me.com
|
@@ -141,7 +141,6 @@ files:
|
|
141
141
|
- test/unit/host_configuration_tests.rb
|
142
142
|
- test/unit/host_data_tests.rb
|
143
143
|
- test/unit/host_tests.rb
|
144
|
-
- test/unit/host_version_group_tests.rb
|
145
144
|
- test/unit/hosts_tests.rb
|
146
145
|
- test/unit/manager_pid_file_tests.rb
|
147
146
|
- test/unit/manager_tests.rb
|
@@ -151,8 +150,8 @@ files:
|
|
151
150
|
- test/unit/worker_tests.rb
|
152
151
|
- tmp/.gitkeep
|
153
152
|
homepage: https://github.com/redding/sanford
|
154
|
-
licenses:
|
155
|
-
|
153
|
+
licenses:
|
154
|
+
- MIT
|
156
155
|
post_install_message:
|
157
156
|
rdoc_options: []
|
158
157
|
|
@@ -196,7 +195,6 @@ test_files:
|
|
196
195
|
- test/unit/host_configuration_tests.rb
|
197
196
|
- test/unit/host_data_tests.rb
|
198
197
|
- test/unit/host_tests.rb
|
199
|
-
- test/unit/host_version_group_tests.rb
|
200
198
|
- test/unit/hosts_tests.rb
|
201
199
|
- test/unit/manager_pid_file_tests.rb
|
202
200
|
- test/unit/manager_tests.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'assert'
|
2
|
-
|
3
|
-
class Sanford::Host::VersionGroup
|
4
|
-
|
5
|
-
class BaseTests < Assert::Context
|
6
|
-
desc "Sanford::Host::VersionGroup"
|
7
|
-
setup do
|
8
|
-
@version_group = Sanford::Host::VersionGroup.new('v1'){ }
|
9
|
-
end
|
10
|
-
subject{ @version_group }
|
11
|
-
|
12
|
-
should have_instance_methods :name, :services, :service, :to_hash
|
13
|
-
|
14
|
-
should "add a key-value to it's services hash with #service" do
|
15
|
-
subject.service('test', 'MyServiceHandler')
|
16
|
-
|
17
|
-
assert_equal 'MyServiceHandler', subject.services['test']
|
18
|
-
end
|
19
|
-
should "allow setting a namespace and use it when a service is added" do
|
20
|
-
subject.service_handler_ns 'MyNamespace'
|
21
|
-
subject.service('test', 'MyServiceHandler')
|
22
|
-
|
23
|
-
assert_equal 'MyNamespace::MyServiceHandler', subject.services['test']
|
24
|
-
end
|
25
|
-
should "ignore a namespace and when a service class has leading colons" do
|
26
|
-
subject.service_handler_ns 'MyNamespace'
|
27
|
-
subject.service('test', '::MyServiceHandler')
|
28
|
-
|
29
|
-
assert_equal '::MyServiceHandler', subject.services['test']
|
30
|
-
end
|
31
|
-
should "return a hash with it's name as a key and its services as the value with #to_hash" do
|
32
|
-
subject.service('test', 'MyServiceHandler')
|
33
|
-
expected = { subject.name => subject.services }
|
34
|
-
|
35
|
-
assert_equal expected, subject.to_hash
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|