Class: Readis
- Inherits:
-
Object
show all
- Defined in:
- lib/readis.rb,
lib/readis/inspect.rb,
lib/readis/monitor.rb
Defined Under Namespace
Classes: Inspect, Monitor, Retry
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Readis
Returns a new instance of Readis.
53
54
55
56
57
|
# File 'lib/readis.rb', line 53
def initialize
self.parser.parse!
@_redis = Redis.new(:host => self.options[:host], :port => self.options[:port])
@redis = Retry.new(@_redis)
end
|
Class Method Details
.command_runner(name) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/readis.rb', line 39
def self.command_runner(name)
case name
when "inspect"
Readis::Inspect.new
when "monitor"
Readis::Monitor.new
else
puts "Usage: readis <command> [options]"
puts "Usage: readis help <command>"
puts "Available commands: inspect, monitor"
exit
end
end
|
Instance Method Details
#help ⇒ Object
79
80
81
|
# File 'lib/readis.rb', line 79
def help
parser.help
end
|
#options ⇒ Object
59
60
61
62
63
64
|
# File 'lib/readis.rb', line 59
def options
@options ||= {
:host => "127.0.0.1",
:port => "6379",
}
end
|
#parser ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/readis.rb', line 66
def parser
OptionParser.new do |parser|
parser.on("-h", "--host=HOST",
"redis host. Defaults to '127.0.0.1'") do |name|
self.options[:host] = name
end
parser.on("-p", "--port=PORT",
"redis port. Defaults to '6379'") do |name|
self.options[:port] = name
end
end
end
|