Module: Otaku
- Defined in:
- lib/otaku.rb,
lib/otaku/client.rb,
lib/otaku/server.rb,
lib/otaku/encoder.rb,
lib/otaku/handler.rb
Defined Under Namespace
Modules: Client, Encoder, Server
Classes: DataProcessError, Handler, HandlerNotDefinedError
Constant Summary
collapse
- DEFAULTS =
{
:ruby => 'ruby',
:address => '127.0.0.1',
:port => 10999,
:log_file => '/tmp/otaku.log',
:init_wait_time => 2 * (RUBY_PLATFORM =~ /java/i ? 3 : 1)
}
Class Method Summary
collapse
Class Method Details
.cleanup ⇒ Object
61
62
63
|
# File 'lib/otaku.rb', line 61
def cleanup
@logger.close if @logger
end
|
.config ⇒ Object
36
37
38
39
40
|
# File 'lib/otaku.rb', line 36
def config
DEFAULTS.keys.inject({}) do |memo, name|
memo.merge(name => send(name))
end
end
|
31
32
33
34
|
# File 'lib/otaku.rb', line 31
def configure(config = {}, &block)
block_given? ? yield(self) :
config.each{|name, val| send(:"#{name}=", val) }
end
|
.log(*msgs) ⇒ Object
56
57
58
59
|
# File 'lib/otaku.rb', line 56
def log(*msgs)
@logger ||= Logger.new(Otaku.log_file)
[msgs].flatten.each{|msg| @logger << "[Otaku] %s\n" % msg }
end
|
.process(data) ⇒ Object
52
53
54
|
# File 'lib/otaku.rb', line 52
def process(data)
Client.get(data)
end
|
.start(context = {}, &handler) ⇒ Object
.stop ⇒ Object
48
49
50
|
# File 'lib/otaku.rb', line 48
def stop
Server.stop
end
|