lib/xapian_db/config.rb in xapian_db-0.3.2 vs lib/xapian_db/config.rb in xapian_db-0.3.3

- old
+ new

@@ -28,11 +28,11 @@ @config ||= Config.new yield @config if block_given? end # Install delegates for the config instance variables - [:database, :adapter, :writer, :stemmer].each do |attr| + [:database, :adapter, :writer, :stemmer, :stopper].each do |attr| define_method attr do @config.nil? ? nil : @config.instance_variable_get("@_#{attr}") end end end @@ -40,11 +40,11 @@ # --------------------------------------------------------------------------------- # DSL methods # --------------------------------------------------------------------------------- # - attr_reader :_database, :_adapter, :_writer, :_stemmer + attr_reader :_database, :_adapter, :_writer, :_stemmer, :_stopper # Set the global database to use # @param [String] path The path to the database. Either apply a file sytem path or :memory # for an in memory database def database(path) @@ -85,23 +85,20 @@ def writer(type) # We try to guess the writer name @_writer = XapianDb::IndexWriters.const_get("#{camelize(type.to_s)}Writer") end - # Set the language - # @param [Symbol] lang The language; either apply the english name of the language - # or the two letter IS639 code - # @example Use the english name of the language + # Set the language. + # @param [Symbol] lang The language; apply the two letter ISO639 code for the language + # @example # XapianDb::Config.setup do |config| - # config.language :german - # end - # @example Use the iso code of the language - # XapianDb::Config.setup do |config| # config.language :de # end - # see http://xapian.org/docs/apidoc/html/classXapian_1_1Stem.html for supported languages + # see {LANGUAGE_MAP} for supported languages def language(lang) - @_stemmer = Xapian::Stem.new(lang.to_s) + key = lang.to_sym + @_stemmer = XapianDb::Repositories::Stemmer.stemmer_for key + key == :none ? @_stopper = nil : @_stopper = XapianDb::Repositories::Stopper.stopper_for(key) end private # TODO: move this to a helper module \ No newline at end of file