Yardoc for the interactor.
This commit is contained in:
parent
98ee450037
commit
ad6fe6f69b
@ -1,14 +1,29 @@
|
|||||||
module Guard
|
module Guard
|
||||||
|
|
||||||
|
# The interactor reads user input and triggers
|
||||||
|
# specific action upon them unless its locked.
|
||||||
|
#
|
||||||
|
# Currently the following actions are implemented:
|
||||||
|
# - stop, quit, exit, s, q, e => Exit Guard
|
||||||
|
# - reload, r, z => Reload Guard
|
||||||
|
# - pause, p => Pause Guard
|
||||||
|
# - Everything else => Run all
|
||||||
|
#
|
||||||
class Interactor
|
class Interactor
|
||||||
|
|
||||||
attr_reader :locked
|
attr_reader :locked
|
||||||
|
|
||||||
|
# Initialize the interactor in unlocked state.
|
||||||
|
#
|
||||||
def initialize
|
def initialize
|
||||||
@locked = false
|
@locked = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Start the interactor in a own thread.
|
||||||
|
#
|
||||||
def start
|
def start
|
||||||
return if ENV["GUARD_ENV"] == 'test'
|
return if ENV["GUARD_ENV"] == 'test'
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
loop do
|
loop do
|
||||||
if (entry = $stdin.gets) && !@locked
|
if (entry = $stdin.gets) && !@locked
|
||||||
@ -28,10 +43,14 @@ module Guard
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Lock the interactor.
|
||||||
|
#
|
||||||
def lock
|
def lock
|
||||||
@locked = true
|
@locked = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Unlock the interactor.
|
||||||
|
#
|
||||||
def unlock
|
def unlock
|
||||||
@locked = false
|
@locked = false
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user