Sha256: 9f6ad0dde02302d0a900c2be4a876e387c067d6abbee73a462ccf17f60fea817

Contents?: true

Size: 1.04 KB

Versions: 48

Compression:

Stored size: 1.04 KB

Contents

class ThinkingSphinx::Test
  def self.init(suppress_delta_output = true)
    set_flags suppress_delta_output
    create_indexes_folder
  end
  
  def self.start
    config.build
    config.controller.index
    config.controller.start
  end
  
  def self.start_with_autostop
    autostop
    start
  end
  
  def self.stop
    config.controller.stop
    sleep(0.5) # Ensure Sphinx has shut down completely
  end
  
  def self.autostop
    Kernel.at_exit do
      ThinkingSphinx::Test.stop
    end
  end
  
  def self.run(&block)
    begin
      start
      yield
    ensure
      stop
    end
  end
  
  def self.config
    @config ||= ::ThinkingSphinx::Configuration.instance
  end
  
  def self.index(*indexes)
    config.controller.index *indexes
  end
  
  def self.set_flags(suppress_delta_output)
    ::ThinkingSphinx.deltas_enabled        = true
    ::ThinkingSphinx.updates_enabled       = true
    ::ThinkingSphinx.suppress_delta_output = suppress_delta_output
  end
  
  def self.create_indexes_folder
    FileUtils.mkdir_p config.searchd_file_path
  end
end

Version data entries

48 entries across 48 versions & 5 rubygems

Version Path
friendlyfashion-thinking-sphinx-2.0.14.4 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/thinking_sphinx/test.rb
thinking-sphinx-2.1.0 lib/thinking_sphinx/test.rb
thinking-sphinx-1.5.0 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/thinking_sphinx/test.rb
thinking-sphinx-2.0.14 lib/thinking_sphinx/test.rb
thinking-sphinx-1.4.14 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/thinking_sphinx/test.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/thinking_sphinx/test.rb
thinking-sphinx-2.0.13 lib/thinking_sphinx/test.rb
thinking-sphinx-1.4.13 lib/thinking_sphinx/test.rb
thinking-sphinx-2.0.12 lib/thinking_sphinx/test.rb
thinking-sphinx-1.4.12 lib/thinking_sphinx/test.rb
thinking-sphinx-2.0.11 lib/thinking_sphinx/test.rb
thinking-sphinx-1.4.11 lib/thinking_sphinx/test.rb
thinking-sphinx-2.0.10 lib/thinking_sphinx/test.rb
thinking-sphinx-1.4.10 lib/thinking_sphinx/test.rb