Class: ThinkingSphinx::Test

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

Class Method Summary collapse

Class Method Details

.autostopObject



23
24
25
26
27
# File 'lib/thinking_sphinx/test.rb', line 23

def self.autostop
  Kernel.at_exit do
    ThinkingSphinx::Test.stop
  end
end

.configObject



35
36
37
# File 'lib/thinking_sphinx/test.rb', line 35

def self.config
  @config ||= ::ThinkingSphinx::Configuration.instance
end

.create_indexes_folderObject



49
50
51
# File 'lib/thinking_sphinx/test.rb', line 49

def self.create_indexes_folder
  FileUtils.mkdir_p config.searchd_file_path
end

.index(*indexes) ⇒ Object



39
40
41
# File 'lib/thinking_sphinx/test.rb', line 39

def self.index(*indexes)
  config.controller.index *indexes
end

.init(suppress_delta_output = true) ⇒ Object



2
3
4
5
# File 'lib/thinking_sphinx/test.rb', line 2

def self.init(suppress_delta_output = true)
  set_flags suppress_delta_output
  create_indexes_folder
end

.run(&block) ⇒ Object



29
30
31
32
33
# File 'lib/thinking_sphinx/test.rb', line 29

def self.run(&block)
  start
  yield
  stop
end

.set_flags(suppress_delta_output) ⇒ Object



43
44
45
46
47
# File 'lib/thinking_sphinx/test.rb', line 43

def self.set_flags(suppress_delta_output)
  ::ThinkingSphinx.deltas_enabled        = true
  ::ThinkingSphinx.updates_enabled       = true
  ::ThinkingSphinx.suppress_delta_output = suppress_delta_output
end

.startObject



7
8
9
10
11
# File 'lib/thinking_sphinx/test.rb', line 7

def self.start
  config.build
  config.controller.index
  config.controller.start
end

.start_with_autostopObject



13
14
15
16
# File 'lib/thinking_sphinx/test.rb', line 13

def self.start_with_autostop
  autostop
  start
end

.stopObject



18
19
20
21
# File 'lib/thinking_sphinx/test.rb', line 18

def self.stop
  config.controller.stop
  sleep(0.5) # Ensure Sphinx has shut down completely
end