Class: Listen::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/again/patches/listen.rb

Class Method Summary collapse

Class Method Details

.usable_and_works?(directories, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/again/patches/listen.rb', line 5

def self.usable_and_works?(directories, options = {})
  usable? #&& Array(directories).all? { |d| !writable?(d) || works?(d, options) }
end

.writable?(directory) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# File 'lib/again/patches/listen.rb', line 9

def self.writable?(directory)
  test_file = "#{directory}/.listen_test"
  FileUtils.touch(test_file)
  return true
rescue SystemCallError
  return false
ensure
  FileUtils.rm(test_file) if File.exists?(test_file)
end