Method: Spring::Watcher::Abstract#add

Defined in:
lib/spring/watcher/abstract.rb

#add(*items) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/spring/watcher/abstract.rb', line 28

def add(*items)
  items = items.flatten.map do |item|
    item = Pathname.new(item)

    if item.relative?
      Pathname.new("#{root}/#{item}")
    else
      item
    end
  end

  items = items.select(&:exist?)

  synchronize {
    items.each do |item|
      if item.directory?
        directories << item.realpath.to_s
      else
        files << item.realpath.to_s
      end
    end

    subjects_changed
  }
end