Class: ChangeListener
- Inherits:
-
Object
- Object
- ChangeListener
- Defined in:
- lib/change_listener.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
Instance Method Summary collapse
- #execute ⇒ Object
- #ignore(*regexps) ⇒ Object
- #ignore_path(*paths) ⇒ Object
-
#initialize(command, *arguments) ⇒ ChangeListener
constructor
A new instance of ChangeListener.
- #start ⇒ Object
Constructor Details
#initialize(command, *arguments) ⇒ ChangeListener
Returns a new instance of ChangeListener.
9 10 11 12 13 14 15 |
# File 'lib/change_listener.rb', line 9 def initialize(command, *arguments) @command = command @arguments = arguments @listener = Listen.to('./').ignore(/^\.\w+/) @listener.change{ execute } end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
7 8 9 |
# File 'lib/change_listener.rb', line 7 def arguments @arguments end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
6 7 8 |
# File 'lib/change_listener.rb', line 6 def command @command end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
5 6 7 |
# File 'lib/change_listener.rb', line 5 def listener @listener end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 25 |
# File 'lib/change_listener.rb', line 21 def execute listener.pause Kernel.system(ENV, command, *arguments) listener.unpause end |
#ignore(*regexps) ⇒ Object
27 28 29 |
# File 'lib/change_listener.rb', line 27 def ignore(*regexps) @listener.ignore(*regexps) end |
#ignore_path(*paths) ⇒ Object
31 32 33 34 35 |
# File 'lib/change_listener.rb', line 31 def ignore_path(*paths) globs = paths.map{|p| FileGlob.new(p)} @listener.ignore(*globs) end |
#start ⇒ Object
17 18 19 |
# File 'lib/change_listener.rb', line 17 def start listener.start(false) end |