Class: FileTracker
- Inherits:
-
Object
- Object
- FileTracker
- Defined in:
- lib/captured/file_tracker.rb
Instance Attribute Summary collapse
-
#tracked_files ⇒ Object
Returns the value of attribute tracked_files.
Instance Method Summary collapse
- #add(file, state) ⇒ Object
- #each_pending ⇒ Object
-
#initialize(options) ⇒ FileTracker
constructor
A new instance of FileTracker.
- #mark_processed(file) ⇒ Object
- #scan(paths, state) ⇒ Object
Constructor Details
#initialize(options) ⇒ FileTracker
Returns a new instance of FileTracker.
4 5 6 7 |
# File 'lib/captured/file_tracker.rb', line 4 def initialize() @options = @tracked_files = {} end |
Instance Attribute Details
#tracked_files ⇒ Object
Returns the value of attribute tracked_files.
2 3 4 |
# File 'lib/captured/file_tracker.rb', line 2 def tracked_files @tracked_files end |
Instance Method Details
#add(file, state) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/captured/file_tracker.rb', line 18 def add(file, state) unless @tracked_files[file] puts "Adding #{file} to tracked files as #{state}" @tracked_files[file] = state end end |
#each_pending ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/captured/file_tracker.rb', line 30 def each_pending @tracked_files.each_pair do |key, value| if(value == :pending) yield(key) end end end |
#mark_processed(file) ⇒ Object
25 26 27 28 |
# File 'lib/captured/file_tracker.rb', line 25 def mark_processed(file) puts "Marking #{file} processed" @tracked_files[file] = :processed end |
#scan(paths, state) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/captured/file_tracker.rb', line 9 def scan(paths, state) puts "Scanning #{paths}" paths.each do |path| Dir["#{path}#{@options[:watch_pattern]}"].each do |file| self.add file, state end end end |