Class: DataMapper::Adapters::Sphinx::Config
- Inherits:
-
Object
- Object
- DataMapper::Adapters::Sphinx::Config
- Includes:
- Extlib::Assertions
- Defined in:
- lib/dm-sphinx-adapter/config.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Configuration option.
-
#config ⇒ Object
readonly
Configuration option.
-
#log ⇒ Object
readonly
Configuration option.
-
#port ⇒ Object
readonly
Configuration option.
Instance Method Summary collapse
-
#indexer_bin(use_config = true) ⇒ Object
Indexer binary full path name and config argument.
-
#initialize(uri_or_options = {}) ⇒ Config
constructor
Sphinx configuration options.
-
#pid_file ⇒ Object
Full path to pid_file.
-
#searchd_bin(use_config = true) ⇒ Object
Searchd binary full path name and config argument.
Constructor Details
#initialize(uri_or_options = {}) ⇒ Config
Sphinx configuration options.
This class just gives you access to handy searchd {} configuration options. If a sphinx configuration file is passed and can be parsed searchd
options will be set straight from the file.
Notes
Option precedence is:
-
The options hash.
-
The configuration file.
-
Sphinx defaults.
See
www.sphinxsearch.com/doc.html#confgroup-searchd
Parameters
- uri_or_options<URI, DataObject::URI, Addressable::URI, String, Hash, Pathname>
-
DataMapper uri or options hash.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dm-sphinx-adapter/config.rb', line 32 def initialize( = {}) assert_kind_of 'uri_or_options', , Addressable::URI, DataObjects::URI, Hash, String, Pathname = () config = parse_config("#{[:path]}") # Pathname#to_s is broken? @address = [:host] || config['address'] || '0.0.0.0' @port = [:port] || config['port'] || 3312 @log = [:log] || config['log'] || 'searchd.log' @pid_file = [:pid_file] || config['pid_file'] end |
Instance Attribute Details
#address ⇒ Object (readonly)
Configuration option.
13 14 15 |
# File 'lib/dm-sphinx-adapter/config.rb', line 13 def address @address end |
#config ⇒ Object (readonly)
Configuration option.
13 14 15 |
# File 'lib/dm-sphinx-adapter/config.rb', line 13 def config @config end |
#log ⇒ Object (readonly)
Configuration option.
13 14 15 |
# File 'lib/dm-sphinx-adapter/config.rb', line 13 def log @log end |
#port ⇒ Object (readonly)
Configuration option.
13 14 15 |
# File 'lib/dm-sphinx-adapter/config.rb', line 13 def port @port end |
Instance Method Details
#indexer_bin(use_config = true) ⇒ Object
Indexer binary full path name and config argument.
Parameters
- use_config<Boolean>
-
Return
--config path/to/config.conf
as part of string. Defaulttrue
.
Returns
String
50 51 52 53 54 |
# File 'lib/dm-sphinx-adapter/config.rb', line 50 def indexer_bin(use_config = true) path = 'indexer' # TODO: Real. path << " --config #{config}" if config path end |
#pid_file ⇒ Object
Full path to pid_file.
Raises
- RuntimeError
-
If a pid file was not read or set. pid_file is a mandatory searchd option in a sphinx
configuration file.
74 75 76 |
# File 'lib/dm-sphinx-adapter/config.rb', line 74 def pid_file @pid_file or raise "Mandatory pid_file option missing from searchd configuration." end |
#searchd_bin(use_config = true) ⇒ Object
Searchd binary full path name and config argument.
Parameters
- use_config<Boolean>
-
Return
--config path/to/config.conf
as part of string. Defaulttrue
.
Returns
String
63 64 65 66 67 |
# File 'lib/dm-sphinx-adapter/config.rb', line 63 def searchd_bin(use_config = true) path = 'searchd' # TODO: Real. path << " --config #{config}" if config path end |