Skip to content
Browse files

Renaming servers to behaviors

  • Loading branch information...
1 parent 5076f34 commit 2c07b06006fb4079596464e658a00426bb1f759b @danielwellman committed
View
2 lib/bane.rb
@@ -1,5 +1,5 @@
require 'bane/service_registry'
require 'bane/utils'
-require 'bane/servers'
+require 'bane/behaviors'
require 'bane/launcher'
require 'bane/delegating_gserver'
View
16 lib/bane/servers.rb → lib/bane/behaviors.rb
@@ -1,31 +1,31 @@
module Bane
- class BasicServer
+ class BasicBehavior
def self.inherited(clazz)
ServiceRegistry.register(clazz)
end
end
- class CloseImmediately < BasicServer
+ class CloseImmediately < BasicBehavior
def serve(io)
# do nothing
end
end
- class CloseAfterPause < BasicServer
+ class CloseAfterPause < BasicBehavior
def serve(io)
sleep(30)
end
end
- class RandomResponseThenClose < BasicServer
+ class RandomResponseThenClose < BasicBehavior
def serve(io)
io.write Utils.random_string()
end
end
- class RandomResponse < BasicServer
+ class RandomResponse < BasicBehavior
def serve(io)
while (io.gets)
io.write Utils.random_string()
@@ -33,7 +33,7 @@ def serve(io)
end
end
- class SlowResponse < BasicServer
+ class SlowResponse < BasicBehavior
MESSAGE = "Now is the time for all good foxes to go seeking other foxes and do good stuff for their government."
def serve(io)
@@ -46,13 +46,13 @@ def serve(io)
end
end
- class NeverRespond < BasicServer
+ class NeverRespond < BasicBehavior
def serve(io)
loop { sleep 1 }
end
end
- class DelugeResponse < BasicServer
+ class DelugeResponse < BasicBehavior
def serve(io)
1_000_000.times { io.write('x') }
end
View
6 lib/bane/launcher.rb
@@ -23,11 +23,11 @@ def stop
private
- def lookup_behavior_classes(server_classes)
- if server_classes.empty?
+ def lookup_behavior_classes(classes)
+ if classes.empty?
ServiceRegistry.all_servers
else
- server_classes.map { |name| Bane.const_get(name) }
+ classes.map { |name| Bane.const_get(name) }
end
end
View
2 test/bane/servers_test.rb → test/bane/behaviors_test.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'timeout'
-class ServersTest < Test::Unit::TestCase
+class BehaviorsTest < Test::Unit::TestCase
def setup
@fake_connection = StringIO.new
View
2 test/bane/launcher_test.rb
@@ -2,7 +2,7 @@
require 'mocha'
module Bane
- class FakeTestServer < BasicServer
+ class FakeTestServer < BasicBehavior
end
end

0 comments on commit 2c07b06

Please sign in to comment.
Something went wrong with that request. Please try again.