Class: Listen::Change
- Inherits:
-
Object
- Object
- Listen::Change
- Defined in:
- lib/listen/change.rb
Overview
TODO: rename to Snapshot
Defined Under Namespace
Classes: Config
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(config, record) ⇒ Change
constructor
A new instance of Change.
-
#invalidate(type, rel_path, options) ⇒ Object
Invalidate some part of the snapshot/record (dir, file, subtree, etc.) rubocop:disable Metrics/MethodLength rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity.
Constructor Details
#initialize(config, record) ⇒ Change
Returns a new instance of Change.
27 28 29 30 |
# File 'lib/listen/change.rb', line 27 def initialize(config, record) @config = config @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
25 26 27 |
# File 'lib/listen/change.rb', line 25 def record @record end |
Instance Method Details
#invalidate(type, rel_path, options) ⇒ Object
Invalidate some part of the snapshot/record (dir, file, subtree, etc.) rubocop:disable Metrics/MethodLength rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/listen/change.rb', line 36 def invalidate(type, rel_path, ) watched_dir = Pathname.new(record.root) change = [:change] = [:cookie] if ! && @config.silenced?(rel_path, type) Listen.logger.debug { "(silenced): #{rel_path.inspect}" } return end path = watched_dir + rel_path Listen.logger.debug do log_details = [:silence] && 'recording' || change || 'unknown' "#{log_details}: #{type}:#{path} (#{.inspect})" end if change = ? { cookie: } : {} @config.queue(type, change, watched_dir, rel_path, ) elsif type == :dir # NOTE: POSSIBLE RECURSION # TODO: fix - use a queue instead Directory.scan(self, rel_path, ) elsif (change = File.change(record, rel_path)) && ![:silence] @config.queue(:file, change, watched_dir, rel_path) end end |