Module: FFI::Hunspell

Extended by:
Library
Defined in:
lib/ffi/hunspell/version.rb,
lib/ffi/hunspell/hunspell.rb,
lib/ffi/hunspell/dictionary.rb

Defined Under Namespace

Classes: Dictionary

Constant Summary collapse

VERSION =

ffi-hunspell versiont

Since:

  • 0.5.0

'0.6.1'
DEFAULT_LANG =

The language to default to, if no 'LANG' env variable was set.

ENV.fetch('LANG','en_US.UTF-8').split('.',2).first
USER_DIR =

The directory name used to store user installed dictionaries.

'.hunspell_default'
KNOWN_DIRECTORIES =

Known directories to search within for dictionaries.

[
  # 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',
  # Fedora
  '/usr/local/share/myspell',
  '/usr/share/myspell',
  # Mac Ports
  '/opt/local/share/hunspell',
  '/opt/share/hunspell'
]

Class Method Summary collapse

Class Method Details

.dict(name = Hunspell.lang) {|dict| ... } ⇒ nil

Opens a Hunspell dictionary.

Parameters:

  • name (Symbol, String) (defaults to: Hunspell.lang)

    The name of the dictionary to open.

Yields:

  • (dict)

    The given block will be passed the Hunspell dictionary.

Yield Parameters:

Returns:

  • (nil)


136
137
138
# File 'lib/ffi/hunspell/hunspell.rb', line 136

def self.dict(name=Hunspell.lang,&block)
  Dictionary.open(name,&block)
end

.directoriesArray<String, Pathname>

The dictionary directories to search for dictionary files.

Returns:

  • (Array<String, Pathname>)

    The directory paths.

Since:

  • 0.2.0



112
113
114
115
116
# File 'lib/ffi/hunspell/hunspell.rb', line 112

def self.directories
  @directories ||= KNOWN_DIRECTORIES.select do |path|
    File.directory?(path)
  end
end

.directories=(dirs) ⇒ Object



118
119
120
# File 'lib/ffi/hunspell/hunspell.rb', line 118

def self.directories=(dirs)
  @directories = dirs
end

.langString

The default language.

Returns:

  • (String)

    The name of the default language.

Since:

  • 0.2.0



62
63
64
# File 'lib/ffi/hunspell/hunspell.rb', line 62

def self.lang
  @lang ||= DEFAULT_LANG
end

.lang=(new_lang) ⇒ String

Sets the default language.

Parameters:

  • new_lang (String)

    The new language name.

Returns:

  • (String)

    The name of the new default language.

Since:

  • 0.2.0



77
78
79
# File 'lib/ffi/hunspell/hunspell.rb', line 77

def self.lang=(new_lang)
  @lang = new_lang.to_s
end