bin_path()
click to toggle source
def bin_path
settings['bin_path']
end
controller()
click to toggle source
def controller
@controller ||= begin
rc = Riddle::Controller.new self, configuration_file
rc.bin_path = bin_path.gsub(/([^\/])$/, '\1/') if bin_path.present?
rc
end
end
engine_index_paths()
click to toggle source
def engine_index_paths
return [] unless defined?(Rails)
engine_indice_paths.flatten.compact
end
engine_indice_paths()
click to toggle source
def engine_indice_paths
Rails::Engine::Railties.engines.collect do |engine|
engine.paths['app/indices'].existent if engine.paths['app/indices']
end
end
framework()
click to toggle source
def framework
@framework ||= ThinkingSphinx::Frameworks.current
end
framework=(framework)
click to toggle source
def framework=(framework)
@framework = framework
setup
framework
end
indices_for_references(*references)
click to toggle source
def indices_for_references(*references)
preload_indices
indices.select { |index| references.include?(index.reference) }
end
next_offset(reference)
click to toggle source
def next_offset(reference)
@offsets[reference] ||= @offsets.keys.count
end
preload_indices()
click to toggle source
def preload_indices
return if @preloaded_indices
index_paths.each do |path|
Dir["#{path}/**/*.rb"].sort.each do |file|
ActiveSupport::Dependencies.require_or_load file
end
end
@preloaded_indices = true
end
render()
click to toggle source
Calls superclass method
def render
preload_indices
ThinkingSphinx::Configuration::ConsistentIds.new(indices).reconcile
ThinkingSphinx::Configuration::MinimumFields.new(indices).reconcile
super
end
render_to_file()
click to toggle source
def render_to_file
FileUtils.mkdir_p searchd.binlog_path
open(configuration_file, 'w') { |file| file.write render }
end
settings()
click to toggle source
def settings
@settings ||= File.exists?(settings_file) ? settings_to_hash : {}
end
apply_sphinx_settings!()
click to toggle source
def apply_sphinx_settings!
[indexer, searchd].each do |object|
settings.each do |key, value|
next unless object.class.settings.include?(key.to_sym)
object.send("#{key}=", value)
end
end
end
framework_root()
click to toggle source
def framework_root
Pathname.new(framework.root)
end
log_root()
click to toggle source
def log_root
framework_root.join('log').realpath
end
settings_file()
click to toggle source
def settings_file
framework_root.join 'config', 'thinking_sphinx.yml'
end
settings_to_hash()
click to toggle source
def settings_to_hash
contents = YAML.load(ERB.new(File.read(settings_file)).result)
contents && contents[environment] || {}
end
setup()
click to toggle source
def setup
@settings = nil
@configuration_file = settings['configuration_file'] || framework_root.join(
'config', "#{environment}.sphinx.conf"
).to_s
@index_paths = engine_index_paths + [framework_root.join('app', 'indices').to_s]
@indices_location = settings['indices_location'] || framework_root.join(
'db', 'sphinx', environment
).to_s
@version = settings['version'] || '2.0.6'
configure_searchd
apply_sphinx_settings!
@offsets = {}
end
tmp_path()
click to toggle source
def tmp_path
path = framework_root.join('tmp')
File.exists?(path) ? path.realpath : path
end