Class: Kodiak::Watcher
- Inherits:
-
Object
- Object
- Kodiak::Watcher
- Defined in:
- lib/kodiak/watcher.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#files ⇒ Object
Returns the value of attribute files.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(config, options) ⇒ Watcher
constructor
A new instance of Watcher.
- #watch ⇒ Object
Constructor Details
#initialize(config, options) ⇒ Watcher
Returns a new instance of Watcher.
8 9 10 11 12 13 |
# File 'lib/kodiak/watcher.rb', line 8 def initialize(config, ) @config = config @files = config.files @options = watch end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/kodiak/watcher.rb', line 6 def config @config end |
#files ⇒ Object
Returns the value of attribute files.
6 7 8 |
# File 'lib/kodiak/watcher.rb', line 6 def files @files end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/kodiak/watcher.rb', line 6 def @options end |
Instance Method Details
#watch ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kodiak/watcher.rb', line 15 def watch transporter = Kodiak::Transporter.new(config, ) dw = [] @files.each do |file| dw = DirectoryWatcher.new '.', :glob => file[:source], :pre_load => true dw.add_observer do |*args| args.each do |event| if event.type == :stable then transporter.transport [file] end end end dw.interval = 0.25 # polling interval dw.stable = 2 # mutiple of interval for 'stable' events dw.start end puts "Kodiak server started" STDIN.gets dw.stop end |