Class: Rediscover::App

Inherits:
Wx::App
  • Object
show all
Defined in:
lib/rediscover/app.rb

Constant Summary collapse

DEFAULTS =
{
  :host => 'localhost',
  :port => 6379
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



31
32
33
# File 'lib/rediscover/app.rb', line 31

def host
  @host
end

#loggerObject (readonly)

Returns the value of attribute logger.



31
32
33
# File 'lib/rediscover/app.rb', line 31

def logger
  @logger
end

#portObject (readonly)

Returns the value of attribute port.



31
32
33
# File 'lib/rediscover/app.rb', line 31

def port
  @port
end

#redisObject (readonly)

Returns the value of attribute redis.



31
32
33
# File 'lib/rediscover/app.rb', line 31

def redis
  @redis
end

Instance Method Details

#connect(host, port) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rediscover/app.rb', line 56

def connect(host, port)
  begin
    @redis = Redis.new(:host => host, :port => port)
    @redis.connect_to_server # connection errors will be rescued by Frame::Connect
    @host, @port = host, port
    @connect_frame.close
  rescue => e
    logger.error(e)
    @conn_refused_dlg = Dialog::Error.new(@connect_frame,
                                            "Can't connect to server.",
                                            'Unable to Connect')
    @conn_refused_dlg.show_modal
    return
  end

  display_main
end

#display_connectObject



48
49
50
# File 'lib/rediscover/app.rb', line 48

def display_connect
  @connect_frame = Frame::Connect.new
end

#display_mainObject



52
53
54
# File 'lib/rediscover/app.rb', line 52

def display_main
  @main_frame = Frame::Main.new
end

#on_initObject



33
34
35
36
37
38
39
40
# File 'lib/rediscover/app.rb', line 33

def on_init
  @logger = Logger.new('rediscover.log')
  ExceptionHandler.set_logger(@logger)
  @host = DEFAULTS[:host]
  @port = DEFAULTS[:port]

  display_connect
end

#on_runObject



42
43
44
45
46
# File 'lib/rediscover/app.rb', line 42

def on_run
  super
rescue Exception => e
  @logger.fatal(e)
end