class ThinkingSphinx::Commands::Base

Public Class Methods

call(configuration, options, stream = STDOUT) click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 6
def self.call(configuration, options, stream = STDOUT)
  new(configuration, options, stream).call_with_handling
end

Public Instance Methods

call_with_handling() click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 10
def call_with_handling
  call
rescue Riddle::CommandFailedError => error
  handle_failure error.command_result
end

Private Instance Methods

command(command, extra_options = {}) click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 20
def command(command, extra_options = {})
  ThinkingSphinx::Commander.call(
    command, configuration, options.merge(extra_options), stream
  )
end
command_output(output) click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 26
def command_output(output)
  return "See above\n" if output.nil?

  "\n\t" + output.gsub("\n", "\n\t")
end
handle_failure(result) click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 32
  def handle_failure(result)
    stream.puts <<-TXT

The Sphinx #{type} command failed:
  Command: #{result.command}
  Status:  #{result.status}
  Output:  #{command_output result.output}
There may be more information about the failure in #{configuration.searchd.log}.
    TXT
    exit(result.status || 1)
  end
log(message) click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 44
def log(message)
  return if options[:silent]

  stream.puts message
end
skip_directories?() click to toggle source
# File lib/thinking_sphinx/commands/base.rb, line 50
def skip_directories?
  configuration.settings['skip_directory_creation']
end