Class: ThinkingSphinx::Configuration
- Inherits:
-
Riddle::Configuration
- Object
- Riddle::Configuration
- ThinkingSphinx::Configuration
show all
- Defined in:
- lib/thinking_sphinx/configuration.rb
Defined Under Namespace
Modules: Defaults
Classes: ConsistentIds, MinimumFields
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
10
11
12
13
14
|
# File 'lib/thinking_sphinx/configuration.rb', line 10
def initialize
super
setup
end
|
Instance Attribute Details
#configuration_file ⇒ Object
Returns the value of attribute configuration_file.
4
5
6
|
# File 'lib/thinking_sphinx/configuration.rb', line 4
def configuration_file
@configuration_file
end
|
#controller ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/thinking_sphinx/configuration.rb', line 28
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
|
#index_paths ⇒ Object
Returns the value of attribute index_paths.
5
6
7
|
# File 'lib/thinking_sphinx/configuration.rb', line 5
def index_paths
@index_paths
end
|
#indices_location ⇒ Object
Returns the value of attribute indices_location.
4
5
6
|
# File 'lib/thinking_sphinx/configuration.rb', line 4
def indices_location
@indices_location
end
|
#version ⇒ Object
Returns the value of attribute version.
4
5
6
|
# File 'lib/thinking_sphinx/configuration.rb', line 4
def version
@version
end
|
Class Method Details
.instance ⇒ Object
16
17
18
|
# File 'lib/thinking_sphinx/configuration.rb', line 16
def self.instance
@instance ||= new
end
|
.reset ⇒ Object
20
21
22
|
# File 'lib/thinking_sphinx/configuration.rb', line 20
def self.reset
@instance = nil
end
|
Instance Method Details
#bin_path ⇒ Object
24
25
26
|
# File 'lib/thinking_sphinx/configuration.rb', line 24
def bin_path
settings['bin_path']
end
|
#engine_index_paths ⇒ Object
46
47
48
49
50
|
# File 'lib/thinking_sphinx/configuration.rb', line 46
def engine_index_paths
return [] unless defined?(Rails)
engine_indice_paths.flatten.compact
end
|
#engine_indice_paths ⇒ Object
52
53
54
55
56
|
# File 'lib/thinking_sphinx/configuration.rb', line 52
def engine_indice_paths
Rails::Engine::Railties.engines.collect do |engine|
engine.paths['app/indices'].existent if engine.paths['app/indices']
end
end
|
#framework ⇒ Object
36
37
38
|
# File 'lib/thinking_sphinx/configuration.rb', line 36
def framework
@framework ||= ThinkingSphinx::Frameworks.current
end
|
#framework=(framework) ⇒ Object
40
41
42
43
44
|
# File 'lib/thinking_sphinx/configuration.rb', line 40
def framework=(framework)
@framework = framework
setup
framework
end
|
#indices_for_references(*references) ⇒ Object
58
59
60
61
|
# File 'lib/thinking_sphinx/configuration.rb', line 58
def indices_for_references(*references)
preload_indices
indices.select { |index| references.include?(index.reference) }
end
|
#next_offset(reference) ⇒ Object
63
64
65
|
# File 'lib/thinking_sphinx/configuration.rb', line 63
def next_offset(reference)
@offsets[reference] ||= @offsets.keys.count
end
|
#preload_indices ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/thinking_sphinx/configuration.rb', line 67
def preload_indices
return if @preloaded_indices
index_paths.each do |path|
Dir["#{path}/**/*.rb"].each do |file|
ActiveSupport::Dependencies.require_or_load file
end
end
@preloaded_indices = true
end
|
#render ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/thinking_sphinx/configuration.rb', line 79
def render
preload_indices
ThinkingSphinx::Configuration::ConsistentIds.new(indices).reconcile
ThinkingSphinx::Configuration::MinimumFields.new(indices).reconcile
super
end
|
#render_to_file ⇒ Object
88
89
90
91
92
|
# File 'lib/thinking_sphinx/configuration.rb', line 88
def render_to_file
FileUtils.mkdir_p searchd.binlog_path
open(configuration_file, 'w') { |file| file.write render }
end
|
#settings ⇒ Object
94
95
96
|
# File 'lib/thinking_sphinx/configuration.rb', line 94
def settings
@settings ||= File.exists?(settings_file) ? settings_to_hash : {}
end
|