Module: DataMapper::Adapters::Sphinx::ConfigParser
- Extended by:
- Extlib::Assertions
- Defined in:
- lib/dm-sphinx-adapter/config_parser.rb
Class Method Summary collapse
-
.parse(path) ⇒ Object
Parse a sphinx config file and return searchd options as a hash.
Class Method Details
.parse(path) ⇒ Object
Parse a sphinx config file and return searchd options as a hash.
Raises
- RuntimeError
-
On parsing errors.
Parameters
- path<String>
-
Sphinx configuration file.
Returns
- Hash
-
Searchd options.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dm-sphinx-adapter/config_parser.rb', line 25 def self.parse(path) assert_kind_of 'path', path, Pathname, String config = Pathname(path).read config.gsub!(/\r\n|\r|\n/, "\n") # Everything in \n config.gsub!(/\s*\\\n\s*/, ' ') # Remove unixy line wraps. blocks(StringScanner.new(config), out = []) out.find{|c| c['type'] =~ /searchd/i} || {} end |