Class: MongoidSphinx::Configuration
- Inherits:
-
Object
- Object
- MongoidSphinx::Configuration
- Includes:
- Singleton
- Defined in:
- lib/mongoid_sphinx/configuration.rb
Constant Summary collapse
- SourceOptions =
%w( mysql_connect_flags mysql_ssl_cert mysql_ssl_key mysql_ssl_ca sql_range_step sql_query_pre sql_query_post sql_query_killlist sql_ranged_throttle sql_query_post_index unpack_zlib unpack_mysqlcompress unpack_mysqlcompress_maxsize )- IndexOptions =
%w( blend_chars charset_table charset_type charset_dictpath docinfo enable_star exceptions expand_keywords hitless_words html_index_attrs html_remove_elements html_strip index_exact_words ignore_chars inplace_docinfo_gap inplace_enable inplace_hit_gap inplace_reloc_factor inplace_write_factor min_infix_len min_prefix_len min_stemming_len min_word_len mlock morphology ngram_chars ngram_len ondisk_dict overshort_step phrase_boundary phrase_boundary_step preopen stopwords stopwords_step wordforms )
Instance Attribute Summary collapse
-
#allow_star ⇒ Object
Returns the value of attribute allow_star.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#index_options ⇒ Object
Returns the value of attribute index_options.
-
#indexed_models ⇒ Object
Returns the value of attribute indexed_models.
-
#model_directories ⇒ Object
Returns the value of attribute model_directories.
-
#searchd_file_path ⇒ Object
Returns the value of attribute searchd_file_path.
-
#source_options ⇒ Object
Returns the value of attribute source_options.
Instance Method Summary collapse
- #address ⇒ Object
- #address=(address) ⇒ Object
- #bin_path ⇒ Object
- #bin_path=(path) ⇒ Object
- #build(file_path = nil) ⇒ Object
- #client ⇒ Object
- #config_file ⇒ Object
- #config_file=(file) ⇒ Object
- #indexer_binary_name ⇒ Object
- #indexer_binary_name=(name) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #mem_limit ⇒ Object
- #mem_limit=(mem_limit) ⇒ Object
- #pid_file ⇒ Object
- #pid_file=(pid_file) ⇒ Object
- #port ⇒ Object
- #port=(port) ⇒ Object
- #query_log_file ⇒ Object
- #query_log_file=(file) ⇒ Object
- #searchd_binary_name ⇒ Object
- #searchd_binary_name=(name) ⇒ Object
- #searchd_log_file ⇒ Object
- #searchd_log_file=(file) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mongoid_sphinx/configuration.rb', line 27 def initialize init_root_env @configuration = Riddle::Configuration.new @configuration.searchd.pid_file = "#{@root}/log/searchd.#{@env}.pid" @configuration.searchd.log = "#{@root}/log/searchd.log" @configuration.searchd.query_log = "#{@root}/log/searchd.query.log" @controller = Riddle::Controller.new @configuration, "#{@root}/config/#{@env}.sphinx.conf" self.address = "127.0.0.1" self.port = 9312 self.searchd_file_path = "#{@root}/db/sphinx/#{@env}" self.allow_star = false self.model_directories = ["#{@root}/app/models/"] + Dir.glob("#{@root}/vendor/plugins/*/app/models/") self.indexed_models = [] self. = { :type => "xmlpipe2" } self. = { :charset_type => "utf-8", :morphology => "stem_en" } parse_config self end |
Instance Attribute Details
#allow_star ⇒ Object
Returns the value of attribute allow_star.
22 23 24 |
# File 'lib/mongoid_sphinx/configuration.rb', line 22 def allow_star @allow_star end |
#configuration ⇒ Object
Returns the value of attribute configuration.
25 26 27 |
# File 'lib/mongoid_sphinx/configuration.rb', line 25 def configuration @configuration end |
#controller ⇒ Object
Returns the value of attribute controller.
25 26 27 |
# File 'lib/mongoid_sphinx/configuration.rb', line 25 def controller @controller end |
#index_options ⇒ Object
Returns the value of attribute index_options.
24 25 26 |
# File 'lib/mongoid_sphinx/configuration.rb', line 24 def end |
#indexed_models ⇒ Object
Returns the value of attribute indexed_models.
23 24 25 |
# File 'lib/mongoid_sphinx/configuration.rb', line 23 def indexed_models @indexed_models end |
#model_directories ⇒ Object
Returns the value of attribute model_directories.
23 24 25 |
# File 'lib/mongoid_sphinx/configuration.rb', line 23 def model_directories @model_directories end |
#searchd_file_path ⇒ Object
Returns the value of attribute searchd_file_path.
23 24 25 |
# File 'lib/mongoid_sphinx/configuration.rb', line 23 def searchd_file_path @searchd_file_path end |
#source_options ⇒ Object
Returns the value of attribute source_options.
24 25 26 |
# File 'lib/mongoid_sphinx/configuration.rb', line 24 def end |
Instance Method Details
#address ⇒ Object
76 77 78 |
# File 'lib/mongoid_sphinx/configuration.rb', line 76 def address @address end |
#address=(address) ⇒ Object
80 81 82 83 |
# File 'lib/mongoid_sphinx/configuration.rb', line 80 def address=(address) @address = address @configuration.searchd.address = address end |
#bin_path ⇒ Object
135 136 137 |
# File 'lib/mongoid_sphinx/configuration.rb', line 135 def bin_path @controller.bin_path end |
#bin_path=(path) ⇒ Object
139 140 141 |
# File 'lib/mongoid_sphinx/configuration.rb', line 139 def bin_path=(path) @controller.bin_path = path end |
#build(file_path = nil) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mongoid_sphinx/configuration.rb', line 61 def build(file_path=nil) file_path ||= "#{self.config_file}" @configuration.indexes.clear MongoidSphinx.context.indexed_models.each do |model| model = model.constantize @configuration.indexes.concat model.to_riddle end open(file_path, "w") do |file| file.write @configuration.render end end |
#client ⇒ Object
56 57 58 59 |
# File 'lib/mongoid_sphinx/configuration.rb', line 56 def client @configuration ||= parse_config Riddle::Client.new address, port end |
#config_file ⇒ Object
127 128 129 |
# File 'lib/mongoid_sphinx/configuration.rb', line 127 def config_file @controller.path end |
#config_file=(file) ⇒ Object
131 132 133 |
# File 'lib/mongoid_sphinx/configuration.rb', line 131 def config_file=(file) @controller.path = file end |
#indexer_binary_name ⇒ Object
151 152 153 |
# File 'lib/mongoid_sphinx/configuration.rb', line 151 def indexer_binary_name @controller.indexer_binary_name end |
#indexer_binary_name=(name) ⇒ Object
155 156 157 |
# File 'lib/mongoid_sphinx/configuration.rb', line 155 def indexer_binary_name=(name) @controller.indexer_binary_name = name end |
#mem_limit ⇒ Object
94 95 96 |
# File 'lib/mongoid_sphinx/configuration.rb', line 94 def mem_limit @mem_limit end |
#mem_limit=(mem_limit) ⇒ Object
98 99 100 101 |
# File 'lib/mongoid_sphinx/configuration.rb', line 98 def mem_limit=(mem_limit) @mem_limit = mem_limit @configuration.indexer.mem_limit = mem_limit end |
#pid_file ⇒ Object
103 104 105 |
# File 'lib/mongoid_sphinx/configuration.rb', line 103 def pid_file @configuration.searchd.pid_file end |
#pid_file=(pid_file) ⇒ Object
107 108 109 |
# File 'lib/mongoid_sphinx/configuration.rb', line 107 def pid_file=(pid_file) @configuration.searchd.pid_file = pid_file end |
#port ⇒ Object
85 86 87 |
# File 'lib/mongoid_sphinx/configuration.rb', line 85 def port @port end |
#port=(port) ⇒ Object
89 90 91 92 |
# File 'lib/mongoid_sphinx/configuration.rb', line 89 def port=(port) @port = port @configuration.searchd.port = port end |
#query_log_file ⇒ Object
119 120 121 |
# File 'lib/mongoid_sphinx/configuration.rb', line 119 def query_log_file @configuration.searchd.query_log end |
#query_log_file=(file) ⇒ Object
123 124 125 |
# File 'lib/mongoid_sphinx/configuration.rb', line 123 def query_log_file=(file) @configuration.searchd.query_log = file end |
#searchd_binary_name ⇒ Object
143 144 145 |
# File 'lib/mongoid_sphinx/configuration.rb', line 143 def searchd_binary_name @controller.searchd_binary_name end |
#searchd_binary_name=(name) ⇒ Object
147 148 149 |
# File 'lib/mongoid_sphinx/configuration.rb', line 147 def searchd_binary_name=(name) @controller.searchd_binary_name = name end |
#searchd_log_file ⇒ Object
111 112 113 |
# File 'lib/mongoid_sphinx/configuration.rb', line 111 def searchd_log_file @configuration.searchd.log end |
#searchd_log_file=(file) ⇒ Object
115 116 117 |
# File 'lib/mongoid_sphinx/configuration.rb', line 115 def searchd_log_file=(file) @configuration.searchd.log = file end |