Class: Woodchuck::Watcher
- Inherits:
-
Object
- Object
- Woodchuck::Watcher
- Extended by:
- Forwardable
- Defined in:
- lib/woodchuck/watcher.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#events ⇒ Object
Returns the value of attribute events.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#tailer ⇒ Object
Returns the value of attribute tailer.
Instance Method Summary collapse
-
#initialize(agent, *paths) ⇒ Watcher
constructor
A new instance of Watcher.
- #inspect ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(agent, *paths) ⇒ Watcher
Returns a new instance of Watcher.
15 16 17 18 19 20 |
# File 'lib/woodchuck/watcher.rb', line 15 def initialize(agent, *paths) @agent = agent @logger = Woodchuck::Logger.new(::STDOUT) @tailer = FileWatch::Tail.new @paths = paths.flatten end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
12 13 14 |
# File 'lib/woodchuck/watcher.rb', line 12 def agent @agent end |
#events ⇒ Object
Returns the value of attribute events.
12 13 14 |
# File 'lib/woodchuck/watcher.rb', line 12 def events @events end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/woodchuck/watcher.rb', line 12 def logger @logger end |
#paths ⇒ Object
Returns the value of attribute paths.
12 13 14 |
# File 'lib/woodchuck/watcher.rb', line 12 def paths @paths end |
#tailer ⇒ Object
Returns the value of attribute tailer.
12 13 14 |
# File 'lib/woodchuck/watcher.rb', line 12 def tailer @tailer end |
Instance Method Details
#inspect ⇒ Object
32 33 34 |
# File 'lib/woodchuck/watcher.rb', line 32 def inspect to_s end |
#start ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/woodchuck/watcher.rb', line 22 def start paths.each do |path| tailer.tail(path) end tailer.subscribe do |path, line| event = Woodchuck::Event.new(path, line) output.handle(event) end end |