lib/ffi/hunspell/hunspell.rb in ffi-hunspell-0.3.0 vs lib/ffi/hunspell/hunspell.rb in ffi-hunspell-0.3.1

- old
+ new

@@ -2,13 +2,16 @@ module FFI module Hunspell extend FFI::Library - ffi_lib ['hunspell-1.2', 'libhunspell-1.2.so.0', - 'hunspell-1.3', 'libhunspell-1.3.so.0'] + ffi_lib [ + 'hunspell-1.3', 'libhunspell-1.3.so.0', + 'hunspell-1.2', 'libhunspell-1.2.so.0' + ] + attach_function :Hunspell_create, [:string, :string], :pointer attach_function :Hunspell_create_key, [:string, :string, :string], :pointer attach_function :Hunspell_destroy, [:pointer], :void attach_function :Hunspell_spell, [:pointer, :string], :int attach_function :Hunspell_get_dic_encoding, [:pointer], :string @@ -37,11 +40,11 @@ # @return [String] # The name of the default language. # # @since 0.2.0 # - def Hunspell.lang + def self.lang @lang ||= DEFAULT_LANG end # # Sets the default language. @@ -52,21 +55,24 @@ # @return [String] # The name of the new default language. # # @since 0.2.0 # - def Hunspell.lang=(new_lang) + def self.lang=(new_lang) @lang = new_lang.to_s end # The directory name used to store user installed dictionaries. USER_DIR = '.hunspell_default' # Known directories to search within for dictionaries. KNOWN_DIRECTORIES = [ # User File.join(Gem.user_home,USER_DIR), + # OS X brew-instlled hunspell + File.join(Gem.user_home,'Library/Spelling'), + '/Library/Spelling', # Debian '/usr/local/share/myspell/dicts', '/usr/share/myspell/dicts', # Ubuntu '/usr/share/hunspell', @@ -84,16 +90,20 @@ # @return [Array<String, Pathname>] # The directory paths. # # @since 0.2.0 # - def Hunspell.directories + def self.directories @directories ||= KNOWN_DIRECTORIES.select do |path| File.directory?(path) end end + def self.directories=(dirs) + @directories = dirs + end + # # Opens a Hunspell dictionary. # # @param [Symbol, String] name # The name of the dictionary to open. @@ -104,10 +114,10 @@ # @yieldparam [Dictionary] dict # The opened dictionary. # # @return [nil] # - def Hunspell.dict(name=Hunspell.lang,&block) + def self.dict(name=Hunspell.lang,&block) Dictionary.open(name,&block) end end end