Class: Listenandcopy

Inherits:
Object
  • Object
show all
Defined in:
lib/listenandcopy.rb

Class Method Summary collapse

Class Method Details

.listenandcopy(filePath, destination) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/listenandcopy.rb', line 6

def self.listenandcopy(filePath, destination)
  Listen.to(filePath, :force_polling => true) do |modified, added, removed|
    # This block will be called when there are changes.
    for f in modified
      puts "change detected in file: " + f
      # puts "copy from: " + f + " to: " + destination
      FileUtils.copy(f, destination)
    end
  end 
end