Class: Captured
- Inherits:
-
Object
- Object
- Captured
- Defined in:
- lib/captured.rb
Class Method Summary collapse
- .config_file ⇒ Object
- .guess_watch_path ⇒ Object
-
.run_and_watch!(options) ⇒ Object
Depricated this is now handeled by launchd.
- .run_once!(options) ⇒ Object
Class Method Details
.config_file ⇒ Object
6 7 8 |
# File 'lib/captured.rb', line 6 def self.config_file "#{ENV['HOME']}/.captured.yml" end |
.guess_watch_path ⇒ Object
10 11 12 13 |
# File 'lib/captured.rb', line 10 def self.guess_watch_path # This should work for 10.5, and 10.6 "{Picture,Screen}*.png" end |
.run_and_watch!(options) ⇒ Object
Depricated this is now handeled by launchd
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/captured.rb', line 26 def self.run_and_watch!() require 'captured/fs_events' watch_path = [:watch_path] || "#{ENV['HOME']}/Desktop/" tracker = FileTracker.new() tracker.scan([desktop_dir], :existing) e = FSEvents.new(watch_path) e.run do |paths| tracker.scan paths, :pending tracker.each_pending do |file| FileUploader.upload(file, ) tracker.mark_processed(file) end end end |
.run_once!(options) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/captured.rb', line 15 def self.run_once!() watch_path = [:watch_path] || "#{ENV['HOME']}/Desktop/" Dir["#{watch_path}#{[:watch_pattern]}"].each do |file| if (File.mtime(file).to_i > (Time.now.to_i-10)) puts "#{file} is new" FileUploader.upload(file, ) end end end |