Class: Test::Redis
- Inherits:
-
Object
- Object
- Test::Redis
- Defined in:
- lib/test-redis.rb,
lib/test-redis/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Class Method Summary collapse
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(options = {}) ⇒ Redis
constructor
A new instance of Redis.
- #restart ⇒ Object
- #start ⇒ Object
- #stop(signal = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Redis
Returns a new instance of Redis.
17 18 19 20 |
# File 'lib/test-redis.rb', line 17 def initialize(={}) setup start if !![:auto_start] || self.class.auto_start end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
54 55 56 |
# File 'lib/test-redis.rb', line 54 def base_dir @base_dir end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
54 55 56 |
# File 'lib/test-redis.rb', line 54 def conf @conf end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
54 55 56 |
# File 'lib/test-redis.rb', line 54 def pid @pid end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
54 55 56 |
# File 'lib/test-redis.rb', line 54 def redis @redis end |
Class Method Details
.auto_start ⇒ Object
9 10 11 |
# File 'lib/test-redis.rb', line 9 def self.auto_start @@auto_start ||= false end |
.auto_start=(value) ⇒ Object
13 14 15 |
# File 'lib/test-redis.rb', line 13 def self.auto_start=(value) @@auto_start = !!value end |
Instance Method Details
#info ⇒ Object
50 51 52 |
# File 'lib/test-redis.rb', line 50 def info read_info end |
#restart ⇒ Object
45 46 47 48 |
# File 'lib/test-redis.rb', line 45 def restart stop start end |
#start ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/test-redis.rb', line 22 def start return if @pid write_conf conf fork_redis at_exit { stop } wait_redis nil end |
#stop(signal = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/test-redis.rb', line 31 def stop(signal=nil) return unless @pid if File.exist? conf["pidfile"] realpid = File.read(conf["pidfile"]).strip.to_i kill realpid, signal FileUtils.rm_f conf["pidfile"] end kill @pid, signal @pid = nil end |