Class: VagrantPlugins::Fsevents::ChangeEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-fsevents/changeEvents.rb

Overview

A single changed path string of a specified change type

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, type, watch) ⇒ ChangeEvents

Returns a new instance of ChangeEvents.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-fsevents/changeEvents.rb', line 29

def initialize(path, type, watch)
  @path = path
  @type = type
  @sync_path = watch[:sync_path]
  @watch_path = watch[:watch_path]
  @watch = watch

  @relative_path = path.sub(sync_path, '')
  @full_path_on_guest = File.join(
    (watch[:opts][:override_guestpath] || watch[:opts][:guestpath]),
    @relative_path
  )
end

Instance Attribute Details

#full_path_on_guestObject (readonly)

Returns the value of attribute full_path_on_guest.



13
14
15
# File 'lib/vagrant-fsevents/changeEvents.rb', line 13

def full_path_on_guest
  @full_path_on_guest
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/vagrant-fsevents/changeEvents.rb', line 7

def path
  @path
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



12
13
14
# File 'lib/vagrant-fsevents/changeEvents.rb', line 12

def relative_path
  @relative_path
end

#sync_pathObject (readonly)

Returns the value of attribute sync_path.



10
11
12
# File 'lib/vagrant-fsevents/changeEvents.rb', line 10

def sync_path
  @sync_path
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/vagrant-fsevents/changeEvents.rb', line 8

def type
  @type
end

#watchObject (readonly)

Returns the value of attribute watch.



9
10
11
# File 'lib/vagrant-fsevents/changeEvents.rb', line 9

def watch
  @watch
end

#watch_pathObject (readonly)

Returns the value of attribute watch_path.



11
12
13
# File 'lib/vagrant-fsevents/changeEvents.rb', line 11

def watch_path
  @watch_path
end

Class Method Details

.make(mods, adds, removes, watch) ⇒ Object

Takes the output of a listen callback (as arrays of strings of files split by type of change) and converts them into single events for a specific watch definition



18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-fsevents/changeEvents.rb', line 18

def self.make(mods, adds, removes, watch)
  change_events = []
  structure = { modified: mods, added: adds, removed: removes }
  structure.each do |type, files|
    files.each do |path|
      change_events.push new(path, type, watch)
    end
  end
  change_events
end