Class: Synchrotron::Scanner
- Inherits:
-
Object
- Object
- Synchrotron::Scanner
- Defined in:
- lib/synchrotron/scanner.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root) ⇒ Scanner
constructor
A new instance of Scanner.
- #scan(path = @root) ⇒ Object
Constructor Details
#initialize(root) ⇒ Scanner
Returns a new instance of Scanner.
6 7 8 9 |
# File 'lib/synchrotron/scanner.rb', line 6 def initialize(root) @paths = {} @root = File.(root) end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
4 5 6 |
# File 'lib/synchrotron/scanner.rb', line 4 def paths @paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
4 5 6 |
# File 'lib/synchrotron/scanner.rb', line 4 def root @root end |
Instance Method Details
#scan(path = @root) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/synchrotron/scanner.rb', line 11 def scan(path = @root) changed = {} ignored = [] Find.find(path) do |p| if Synchrotron.ignore.match(p) ignored << p Find.prune end old = @paths[p] stat = File.lstat(p) changed[p] = stat if old.nil? || stat.ino != old.ino || stat.mtime != old.mtime || stat.size != old.size end @paths.merge!(changed) unless changed.empty? {:changed => changed.values.sort, :ignored => ignored} end |