Class: FlyingSphinx::Configuration
- Inherits:
-
Object
- Object
- FlyingSphinx::Configuration
- Defined in:
- lib/flying_sphinx/configuration.rb
Constant Summary collapse
- FileIndexSettings =
[:stopwords, :wordforms, :exceptions]
- FileSourceSettings =
[:mysql_ssl_cert, :mysql_ssl_key, :mysql_ssl_ca]
- FileSettings =
FileIndexSettings + FileSourceSettings
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#database_port ⇒ Object
readonly
Returns the value of attribute database_port.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#mem_limit ⇒ Object
readonly
Returns the value of attribute mem_limit.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #api ⇒ Object
- #client_key ⇒ Object
- #file_setting_pairs(setting) ⇒ Object
-
#initialize(identifier = nil, api_key = nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #output_recent_actions ⇒ Object
- #sphinx_configuration ⇒ Object
- #start_sphinx ⇒ Object
- #stop_sphinx ⇒ Object
Constructor Details
#initialize(identifier = nil, api_key = nil) ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 |
# File 'lib/flying_sphinx/configuration.rb', line 8 def initialize(identifier = nil, api_key = nil) @identifier = identifier || identifier_from_env @api_key = api_key || api_key_from_env set_from_server setup_environment_settings end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def api_key @api_key end |
#database_port ⇒ Object (readonly)
Returns the value of attribute database_port.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def database_port @database_port end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def host @host end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def identifier @identifier end |
#mem_limit ⇒ Object (readonly)
Returns the value of attribute mem_limit.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def mem_limit @mem_limit end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
2 3 4 |
# File 'lib/flying_sphinx/configuration.rb', line 2 def port @port end |
Instance Method Details
#api ⇒ Object
16 17 18 |
# File 'lib/flying_sphinx/configuration.rb', line 16 def api @api ||= FlyingSphinx::API.new(identifier, api_key) end |
#client_key ⇒ Object
47 48 49 |
# File 'lib/flying_sphinx/configuration.rb', line 47 def client_key "#{identifier}:#{api_key}" end |
#file_setting_pairs(setting) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/flying_sphinx/configuration.rb', line 28 def file_setting_pairs(setting) @file_setting_pairs ||= {} @file_setting_pairs[setting] ||= begin pairs = {} file_setting_sources(setting).each_with_index do |source, index| pairs[source] = "#{base_path}/#{setting}/#{index}.txt" end pairs end end |
#output_recent_actions ⇒ Object
51 52 53 54 55 |
# File 'lib/flying_sphinx/configuration.rb', line 51 def output_recent_actions api.get('actions').body.each do |action| puts "#{action.created_at} #{action.name}" end end |
#sphinx_configuration ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/flying_sphinx/configuration.rb', line 20 def sphinx_configuration thinking_sphinx.generate set_database_settings set_file_settings riddle.render end |
#start_sphinx ⇒ Object
39 40 41 |
# File 'lib/flying_sphinx/configuration.rb', line 39 def start_sphinx api.post('start') end |
#stop_sphinx ⇒ Object
43 44 45 |
# File 'lib/flying_sphinx/configuration.rb', line 43 def stop_sphinx api.post('stop') end |