Class: Messed::Interface
- Inherits:
-
Object
show all
- Includes:
- Logger::LoggingModule
- Defined in:
- lib/messed/interface.rb,
lib/messed/interface/runner.rb,
lib/messed/interface/adapter.rb,
lib/messed/interface/adapter/twitter_search.rb,
lib/messed/interface/adapter/twitter_sender.rb,
lib/messed/interface/adapter/twitter_consumer.rb,
lib/messed/interface/adapter/twitter_streaming.rb
Defined Under Namespace
Classes: Adapter, Runner
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #logger, #logger=
Constructor Details
Returns a new instance of Interface.
32
33
34
|
# File 'lib/messed/interface.rb', line 32
def initialize
@started_at = Time.new
end
|
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
30
31
32
|
# File 'lib/messed/interface.rb', line 30
def adapter
@adapter
end
|
#booter ⇒ Object
Returns the value of attribute booter.
30
31
32
|
# File 'lib/messed/interface.rb', line 30
def booter
@booter
end
|
#configuration ⇒ Object
Returns the value of attribute configuration.
30
31
32
|
# File 'lib/messed/interface.rb', line 30
def configuration
@configuration
end
|
#name ⇒ Object
Returns the value of attribute name.
30
31
32
|
# File 'lib/messed/interface.rb', line 30
def name
@name
end
|
#started_at ⇒ Object
Returns the value of attribute started_at.
30
31
32
|
# File 'lib/messed/interface.rb', line 30
def started_at
@started_at
end
|
Class Method Details
.interface_from_configuration(booter, name, configuration) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/messed/interface.rb', line 9
def self.interface_from_configuration(booter, name, configuration)
interface = Interface.new
interface.send(:name=, name)
interface.send(:configuration=, configuration)
interface.send(:adapter=, Adapter.for_name(configuration.adapter).new(interface))
interface.send(:booter=, booter)
interface
end
|
Instance Method Details
#application ⇒ Object
36
37
38
|
# File 'lib/messed/interface.rb', line 36
def application
booter.application
end
|
#start ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/messed/interface.rb', line 53
def start
begin
EM.start_server(status_host, status_port, EMRunner::StatusHandler) do |c|
c.interface = self
end
logger.info "Status handler for #{self.class} started on #{status_host}:#{status_port}"
rescue RuntimeError => e
if e.message =~ /no acceptor/
logger.error "Unable to start status handler"
else
raise e
end
end
booter.write_pid_file(configuration.pid_file)
adapter.start
end
|
#status ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/messed/interface.rb', line 22
def status
{
'adapter' => adapter.status,
'configuration' => configuration,
'name' => name
}
end
|
#status_host ⇒ Object
40
41
42
|
# File 'lib/messed/interface.rb', line 40
def status_host
configuration.status_address || '0.0.0.0'
end
|
#status_port ⇒ Object
44
45
46
|
# File 'lib/messed/interface.rb', line 44
def status_port
configuration.status_port || 11190
end
|
#stop ⇒ Object
48
49
50
51
|
# File 'lib/messed/interface.rb', line 48
def stop
Process.kill("INT", booter.read_pid_file(configuration.pid_file))
exit(0)
end
|
#to_s ⇒ Object
18
19
20
|
# File 'lib/messed/interface.rb', line 18
def to_s
"#{Array(configuration['mode']) * ', '} ->> #{name}"
end
|