Class: ThinkingSphinx::Guard::File

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/guard/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ File

Returns a new instance of File.



6
7
8
# File 'lib/thinking_sphinx/guard/file.rb', line 6

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/thinking_sphinx/guard/file.rb', line 4

def name
  @name
end

Instance Method Details

#lockObject



10
11
12
# File 'lib/thinking_sphinx/guard/file.rb', line 10

def lock
  FileUtils.touch path
end

#locked?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/thinking_sphinx/guard/file.rb', line 14

def locked?
  File.exist? path
end

#pathObject



18
19
20
21
22
23
# File 'lib/thinking_sphinx/guard/file.rb', line 18

def path
  @path ||= File.join(
    ThinkingSphinx::Configuration.instance.indices_location,
    "ts-#{name}.tmp"
  )
end

#unlockObject



25
26
27
# File 'lib/thinking_sphinx/guard/file.rb', line 25

def unlock
  FileUtils.rm(path) if locked?
end