Class: DiffRunner::Registary

Inherits:
Object
  • Object
show all
Defined in:
lib/diff-runner/registary.rb

Constant Summary collapse

@@instance =
Registary.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistary

Returns a new instance of Registary.



6
7
8
# File 'lib/diff-runner/registary.rb', line 6

def initialize
	@listeners = {}
end

Class Method Details

.instanceObject



12
13
14
# File 'lib/diff-runner/registary.rb', line 12

def self.instance
	@@instance
end

Instance Method Details

#clearObject



26
27
28
29
30
31
32
# File 'lib/diff-runner/registary.rb', line 26

def clear 
	@listeners.each do |path, listener|
		listener.stop
	end

	@listeners = {}
end

#is_listening?(path) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/diff-runner/registary.rb', line 40

def is_listening?(path)
	@listeners.key? path
end

#register(path, action) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/diff-runner/registary.rb', line 16

def register(path, action)
	listener = Listen.to(path) do |m, a, d|
		action.run
	end

	listener.start

	@listeners[path] = listener
end

#unregister(path) ⇒ Object



34
35
36
37
38
# File 'lib/diff-runner/registary.rb', line 34

def unregister(path)
	if @listeners.has_key? path
		@listeners.delete(path).stop
	end
end