Skip to content

Commit

Permalink
Changed hacky class << self to def self.settings in all classes from …
Browse files Browse the repository at this point in the history
…Riddle::Configuration module
  • Loading branch information
useruby committed Jun 10, 2011
1 parent dcf591b commit d697bb1
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 83 deletions.
12 changes: 5 additions & 7 deletions lib/riddle/configuration/distributed_index.rb
@@ -1,13 +1,11 @@
module Riddle
class Configuration
class DistributedIndex < Riddle::Configuration::Section
class << self
def settings
[
:type, :local, :agent, :agent_blackhole,
:agent_connect_timeout, :agent_query_timeout
]
end
def self.settings
[
:type, :local, :agent, :agent_blackhole,
:agent_connect_timeout, :agent_query_timeout
]
end

attr_accessor :name, :local_indexes, :remote_indexes, :agent_blackhole,
Expand Down
30 changes: 14 additions & 16 deletions lib/riddle/configuration/index.rb
@@ -1,22 +1,20 @@
module Riddle
class Configuration
class Index < Riddle::Configuration::Section
class << self
def settings
[
:type, :source, :path, :docinfo, :mlock, :morphology,
:dict, :index_sp, :index_zones, :min_stemming_len, :stopwords,
:wordforms, :exceptions, :min_word_len, :charset_dictpath,
:charset_type, :charset_table, :ignore_chars, :min_prefix_len,
:min_infix_len, :prefix_fields, :infix_fields, :enable_star,
:expand_keywords, :ngram_len, :ngram_chars, :phrase_boundary,
:phrase_boundary_step, :blend_chars, :blend_mode, :html_strip,
:html_index_attrs, :html_remove_elements, :preopen, :ondisk_dict,
:inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
:inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
:overshort_step, :stopwords_step, :hitless_words
]
end
def self.settings
[
:type, :source, :path, :docinfo, :mlock, :morphology,
:dict, :index_sp, :index_zones, :min_stemming_len, :stopwords,
:wordforms, :exceptions, :min_word_len, :charset_dictpath,
:charset_type, :charset_table, :ignore_chars, :min_prefix_len,
:min_infix_len, :prefix_fields, :infix_fields, :enable_star,
:expand_keywords, :ngram_len, :ngram_chars, :phrase_boundary,
:phrase_boundary_step, :blend_chars, :blend_mode, :html_strip,
:html_index_attrs, :html_remove_elements, :preopen, :ondisk_dict,
:inplace_enable, :inplace_hit_gap, :inplace_docinfo_gap,
:inplace_reloc_factor, :inplace_write_factor, :index_exact_words,
:overshort_step, :stopwords_step, :hitless_words
]
end

attr_accessor :name, :parent, :type, :sources, :path, :docinfo, :mlock,
Expand Down
12 changes: 5 additions & 7 deletions lib/riddle/configuration/indexer.rb
@@ -1,13 +1,11 @@
module Riddle
class Configuration
class Indexer < Riddle::Configuration::Section
class << self
def settings
[
:mem_limit, :max_iops, :max_iosize, :max_xmlpipe2_field,
:write_buffer, :max_file_field_buffer
]
end
def self.settings
[
:mem_limit, :max_iops, :max_iosize, :max_xmlpipe2_field,
:write_buffer, :max_file_field_buffer
]
end

attr_accessor *self.settings
Expand Down
12 changes: 5 additions & 7 deletions lib/riddle/configuration/realtime_index.rb
@@ -1,13 +1,11 @@
module Riddle
class Configuration
class RealtimeIndex < Riddle::Configuration::Section
class << self
def settings
[
:type, :path, :rt_mem_limit, :rt_field, :rt_attr_uint,
:rt_attr_bigint, :rt_attr_float, :rt_attr_timestamp, :rt_attr_string
]
end
def self.settings
[
:type, :path, :rt_mem_limit, :rt_field, :rt_attr_uint,
:rt_attr_bigint, :rt_attr_float, :rt_attr_timestamp, :rt_attr_string
]
end

attr_accessor :name
Expand Down
30 changes: 14 additions & 16 deletions lib/riddle/configuration/searchd.rb
@@ -1,22 +1,20 @@
module Riddle
class Configuration
class Searchd < Riddle::Configuration::Section
class << self
def settings
[
:listen, :address, :port, :log, :query_log,
:query_log_format, :read_timeout, :client_timeout, :max_children,
:pid_file, :max_matches, :seamless_rotate, :preopen_indexes,
:unlink_old, :attr_flush_period, :ondisk_dict_default, :max_packet_size,
:mva_updates_pool, :crash_log_path, :max_filters, :max_filter_values,
:listen_backlog, :read_buffer, :read_unhinted, :max_batch_queries,
:subtree_docs_cache, :subtree_hits_cache, :workers, :dist_threads,
:binlog_path, :binlog_flush, :binlog_max_log_size, :collation_server,
:collation_libc_locale, :plugin_dir, :mysql_version_string,
:rt_flush_period, :thread_stack, :expansion_limit,
:compat_sphinxql_magics, :watchdog, :client_key
]
end
def self.settings
[
:listen, :address, :port, :log, :query_log,
:query_log_format, :read_timeout, :client_timeout, :max_children,
:pid_file, :max_matches, :seamless_rotate, :preopen_indexes,
:unlink_old, :attr_flush_period, :ondisk_dict_default, :max_packet_size,
:mva_updates_pool, :crash_log_path, :max_filters, :max_filter_values,
:listen_backlog, :read_buffer, :read_unhinted, :max_batch_queries,
:subtree_docs_cache, :subtree_hits_cache, :workers, :dist_threads,
:binlog_path, :binlog_flush, :binlog_max_log_size, :collation_server,
:collation_libc_locale, :plugin_dir, :mysql_version_string,
:rt_flush_period, :thread_stack, :expansion_limit,
:compat_sphinxql_magics, :watchdog, :client_key
]
end

attr_accessor *self.settings
Expand Down
6 changes: 2 additions & 4 deletions lib/riddle/configuration/section.rb
@@ -1,12 +1,10 @@
module Riddle
class Configuration
class Section
class << self
attr_accessor :settings
def self.settings
[]
end

settings = []

def valid?
true
end
Expand Down
30 changes: 14 additions & 16 deletions lib/riddle/configuration/sql_source.rb
@@ -1,22 +1,20 @@
module Riddle
class Configuration
class SQLSource < Riddle::Configuration::Source
class << self
def settings
[
:type, :sql_host, :sql_user, :sql_pass, :sql_db,
:sql_port, :sql_sock, :mysql_connect_flags, :mysql_ssl_cert,
:mysql_ssl_key, :mysql_ssl_ca, :odbc_dsn, :sql_query_pre, :sql_query,
:sql_joined_field, :sql_file_field, :sql_query_range, :sql_range_step,
:sql_query_killlist, :sql_attr_uint, :sql_attr_bool, :sql_attr_bigint,
:sql_attr_timestamp, :sql_attr_str2ordinal, :sql_attr_float,
:sql_attr_multi, :sql_attr_string, :sql_attr_str2wordcount,
:sql_column_buffers, :sql_field_string, :sql_field_str2wordcount,
:sql_query_post, :sql_query_post_index, :sql_ranged_throttle,
:sql_query_info, :mssql_winauth, :mssql_unicode, :unpack_zlib,
:unpack_mysqlcompress, :unpack_mysqlcompress_maxsize
]
end
def self.settings
[
:type, :sql_host, :sql_user, :sql_pass, :sql_db,
:sql_port, :sql_sock, :mysql_connect_flags, :mysql_ssl_cert,
:mysql_ssl_key, :mysql_ssl_ca, :odbc_dsn, :sql_query_pre, :sql_query,
:sql_joined_field, :sql_file_field, :sql_query_range, :sql_range_step,
:sql_query_killlist, :sql_attr_uint, :sql_attr_bool, :sql_attr_bigint,
:sql_attr_timestamp, :sql_attr_str2ordinal, :sql_attr_float,
:sql_attr_multi, :sql_attr_string, :sql_attr_str2wordcount,
:sql_column_buffers, :sql_field_string, :sql_field_str2wordcount,
:sql_query_post, :sql_query_post_index, :sql_ranged_throttle,
:sql_query_info, :mssql_winauth, :mssql_unicode, :unpack_zlib,
:unpack_mysqlcompress, :unpack_mysqlcompress_maxsize
]
end

attr_accessor *self.settings
Expand Down
16 changes: 7 additions & 9 deletions lib/riddle/configuration/xml_source.rb
@@ -1,15 +1,13 @@
module Riddle
class Configuration
class XMLSource < Riddle::Configuration::Source
class << self
def settings
[
:type, :xmlpipe_command, :xmlpipe_field,
:xmlpipe_attr_uint, :xmlpipe_attr_bool, :xmlpipe_attr_timestamp,
:xmlpipe_attr_str2ordinal, :xmlpipe_attr_float, :xmlpipe_attr_multi,
:xmlpipe_fixup_utf8
]
end
def self.settings
[
:type, :xmlpipe_command, :xmlpipe_field,
:xmlpipe_attr_uint, :xmlpipe_attr_bool, :xmlpipe_attr_timestamp,
:xmlpipe_attr_str2ordinal, :xmlpipe_attr_float, :xmlpipe_attr_multi,
:xmlpipe_fixup_utf8
]
end

attr_accessor *self.settings
Expand Down
25 changes: 24 additions & 1 deletion spec/riddle/configuration_spec.rb
@@ -1,5 +1,28 @@
require 'spec_helper'

describe Riddle::Configuration do
#
describe Riddle::Configuration::Index do
describe '#settings' do
it 'should return array with all settings of index' do
Riddle::Configuration::Index.settings.should_not be_empty
end

it 'should return array which contains a docinfo' do
Riddle::Configuration::Index.settings.should be_include :docinfo
end
end
end

describe 'class inherited from Riddle::Configuration::Index' do
before :all do
class TestIndex < Riddle::Configuration::Index; end
end

describe '#settings' do
it 'should has same settings as Riddle::Configuration::Index' do
TestIndex.settings.should == Riddle::Configuration::Index.settings
end
end

end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -23,6 +23,10 @@
config.after :all do
sphinx.stop
end

# enable filtering for examples
config.filter_run :wip => true
config.run_all_when_everything_filtered = true
end

def query_contents(key)
Expand Down

0 comments on commit d697bb1

Please sign in to comment.