Class: Spring::ApplicationWatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/spring/application_watcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationWatcher

Returns a new instance of ApplicationWatcher.



5
6
7
8
9
# File 'lib/spring/application_watcher.rb', line 5

def initialize
  @files = []
  @globs = []
  @mtime = nil
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/spring/application_watcher.rb', line 3

def files
  @files
end

#globsObject (readonly)

Returns the value of attribute globs.



3
4
5
# File 'lib/spring/application_watcher.rb', line 3

def globs
  @globs
end

#mtimeObject (readonly)

Returns the value of attribute mtime.



3
4
5
# File 'lib/spring/application_watcher.rb', line 3

def mtime
  @mtime
end

Instance Method Details

#add_files(new_files) ⇒ Object



11
12
13
14
15
# File 'lib/spring/application_watcher.rb', line 11

def add_files(new_files)
  files.concat new_files.select { |f| File.exist?(f) }
  files.uniq!
  reset
end

#add_globs(new_globs) ⇒ Object



17
18
19
20
# File 'lib/spring/application_watcher.rb', line 17

def add_globs(new_globs)
  globs.concat new_globs
  reset
end

#resetObject



22
23
24
# File 'lib/spring/application_watcher.rb', line 22

def reset
  @mtime = compute_mtime
end

#stale?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/spring/application_watcher.rb', line 26

def stale?
  mtime < compute_mtime
end