Sha256: ac8842344863e27aad8e519a997c818bbd1f23e55d091c05040c362a4ae612a8

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

class ThinkingSphinx::Interfaces::SQL < ThinkingSphinx::Interfaces::Base
  def initialize(configuration, options, stream = STDOUT)
    super

    configuration.preload_indices

    command :prepare
  end

  def clear
    command :clear_sql, :indices => (filtered? ? filtered_indices : indices)
  end

  def index(reconfigure = true, verbose = nil)
    stream.puts <<-TXT unless verbose.nil?
The verbose argument to the index method is now deprecated, and can instead be
managed by the :verbose option passed in when initialising RakeInterface. That
option is set automatically when invoked by rake, via rake's --silent and/or
--quiet arguments.
    TXT
    return if indices.empty?

    command :configure if reconfigure
    command :index_sql,
      :indices => (filtered? ? filtered_indices.collect(&:name) : nil)
  end

  def merge
    command :merge_and_update
  end

  private

  def filtered?
    index_names.any?
  end

  def filtered_indices
    indices.select { |index| index_names.include? index.name }
  end

  def index_names
    @index_names ||= options[:index_names] || []
  end

  def indices
    @indices ||= configuration.indices.select do |index|
      index.type == 'plain' || index.type.blank?
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/interfaces/sql.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/interfaces/sql.rb