ffi-aspell 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/changelog.md +7 -1
- data/lib/ffi/aspell/aspell.rb +65 -0
- data/lib/ffi/aspell/speller.rb +46 -0
- data/lib/ffi/aspell/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de124725c6b91091475f71adab06a9fd3ab3895
|
4
|
+
data.tar.gz: afa6929f7f48223e2ae5f9f2baac4fc70217776e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96f4d2869585cbe7ed271ec0e746f86a0b610cb2c5376e584b1fc0d599bbf674495cad396d7474c898d8f0a452b600191fc6ee7d71d60703768a1c6c4eeca6ef
|
7
|
+
data.tar.gz: 907f703554fe23a837c966e0e879379e4b9c964fe656e11a4d21f10d2ce337110791b9ec6933ba7ae858c9ba8f4d1b0eaaa56d1170f659502ea0373136b5602d
|
data/doc/changelog.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 1.0.
|
3
|
+
## 1.0.2 - 2014-11-13
|
4
|
+
|
5
|
+
The Speller class now checks if a dictionary is installed upon initialization or
|
6
|
+
when updating a speller (instead of just crashing). See
|
7
|
+
<https://github.com/YorickPeterse/ffi-aspell/pull/20> for more information.
|
8
|
+
|
9
|
+
## 1.0.1 - 2014-11-05
|
4
10
|
|
5
11
|
An alternative library name for Aspell was added so that this Gem now works on
|
6
12
|
Ubuntu systems.
|
data/lib/ffi/aspell/aspell.rb
CHANGED
@@ -16,6 +16,13 @@ module FFI
|
|
16
16
|
extend FFI::Library
|
17
17
|
ffi_lib ['aspell', 'libaspell.so.15']
|
18
18
|
|
19
|
+
##
|
20
|
+
# Structure for storing dictionary information.
|
21
|
+
#
|
22
|
+
class DictInfo < FFI::Struct
|
23
|
+
layout :code, :string
|
24
|
+
end
|
25
|
+
|
19
26
|
##
|
20
27
|
# Creates a pointer for a configuration struct.
|
21
28
|
#
|
@@ -247,5 +254,63 @@ module FFI
|
|
247
254
|
'aspell_string_enumeration_next',
|
248
255
|
[:pointer],
|
249
256
|
:string
|
257
|
+
|
258
|
+
##
|
259
|
+
# Gets a list of all installed aspell dictionaries.
|
260
|
+
#
|
261
|
+
# @method dict_info_list(config)
|
262
|
+
# @scope class
|
263
|
+
# @param [FFI::Pointer] config
|
264
|
+
# @return [FFI::Pointer] list A list of dictionaries which can be used
|
265
|
+
# by {FFI::Aspell.dict_info_list_elements}.
|
266
|
+
#
|
267
|
+
attach_function 'dict_info_list',
|
268
|
+
'get_aspell_dict_info_list',
|
269
|
+
[:pointer],
|
270
|
+
:pointer
|
271
|
+
|
272
|
+
##
|
273
|
+
# Gets all elements from the dictionary list.
|
274
|
+
#
|
275
|
+
# @method dict_info_list_elements(list)
|
276
|
+
# @scope class
|
277
|
+
# @param [FFI::Pointer] list A list of dictionaries as returned
|
278
|
+
# by {FFI::Aspell.dict_info_list}.
|
279
|
+
# @return [FFI::Pointer] dictionary Returns an enumeration of
|
280
|
+
# {FFI::Aspell::DictInfo} structs.
|
281
|
+
#
|
282
|
+
attach_function 'dict_info_list_elements',
|
283
|
+
'aspell_dict_info_list_elements',
|
284
|
+
[:pointer],
|
285
|
+
:pointer
|
286
|
+
|
287
|
+
##
|
288
|
+
# Deletes an enumeration of dictionaries.
|
289
|
+
#
|
290
|
+
# @method delete_dict_info_enumeration(enumeration)
|
291
|
+
# @scope class
|
292
|
+
# @param [FFI::Pointer] enumeration An enumeration of dictionaries returned
|
293
|
+
# by {FFI::Aspell.dict_info_list_elements}.
|
294
|
+
#
|
295
|
+
attach_function 'delete_dict_info_enumeration',
|
296
|
+
'delete_aspell_dict_info_enumeration',
|
297
|
+
[:pointer],
|
298
|
+
:void
|
299
|
+
|
300
|
+
##
|
301
|
+
# Retrieves the next element in the list of dictionaries.
|
302
|
+
#
|
303
|
+
# @method dict_info_enumeration_next(elements)
|
304
|
+
# @scope class
|
305
|
+
# @param [FFI::Pointer] elements Pointer to a dictionary enumeration as returned
|
306
|
+
# by {FFI::Aspell.dict_info_list_elements}.
|
307
|
+
# @return [DictInfo|NilClass] dictInfo Returns an object of {FFI::Aspell::DictInfo}
|
308
|
+
# information, which contains dictionary information.
|
309
|
+
#
|
310
|
+
attach_function 'dict_info_enumeration_next',
|
311
|
+
'aspell_dict_info_enumeration_next',
|
312
|
+
[:pointer],
|
313
|
+
DictInfo
|
314
|
+
|
250
315
|
end # Aspell
|
251
316
|
end # FFI
|
data/lib/ffi/aspell/speller.rb
CHANGED
@@ -193,6 +193,15 @@ module FFI
|
|
193
193
|
return @config.nil?
|
194
194
|
end
|
195
195
|
|
196
|
+
##
|
197
|
+
# Checks if a dictionary is available or not
|
198
|
+
#
|
199
|
+
# @return [TrueClass|FalseClass]
|
200
|
+
#
|
201
|
+
def dictionary_available?(dictionary)
|
202
|
+
return available_dictionaries.include?(dictionary)
|
203
|
+
end
|
204
|
+
|
196
205
|
##
|
197
206
|
# Checks if the given word is correct or not.
|
198
207
|
#
|
@@ -399,6 +408,19 @@ module FFI
|
|
399
408
|
end
|
400
409
|
end
|
401
410
|
|
411
|
+
##
|
412
|
+
# Raises error if used dictionary is not installed.
|
413
|
+
#
|
414
|
+
# @raise [ArgumentError] Raised if dictionary does not exist.
|
415
|
+
# @return [nil]
|
416
|
+
#
|
417
|
+
def check_dictionary
|
418
|
+
dictionary = get('lang')
|
419
|
+
if !dictionary_available?(dictionary)
|
420
|
+
raise(ArgumentError, "The used dictionary #{dictionary.inspect} is not available")
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
402
424
|
##
|
403
425
|
# Updates the internal speller object to use the current config.
|
404
426
|
#
|
@@ -413,7 +435,31 @@ module FFI
|
|
413
435
|
self,
|
414
436
|
self.class.finalizer(@config, @speller)
|
415
437
|
)
|
438
|
+
|
439
|
+
check_dictionary
|
440
|
+
end
|
441
|
+
|
442
|
+
##
|
443
|
+
# Get all availbale aspell dictionary codes
|
444
|
+
#
|
445
|
+
# @return [Array]
|
446
|
+
#
|
447
|
+
def available_dictionaries
|
448
|
+
list = Aspell.dict_info_list(@config)
|
449
|
+
elements = Aspell.dict_info_list_elements(list)
|
450
|
+
dicts = []
|
451
|
+
|
452
|
+
while element = Aspell.dict_info_enumeration_next(elements)
|
453
|
+
break if element == FFI::Pointer::NULL
|
454
|
+
dict_info = Aspell::DictInfo.new(element)
|
455
|
+
dicts << handle_output(dict_info[:code])
|
456
|
+
end
|
457
|
+
|
458
|
+
Aspell.delete_dict_info_enumeration(elements)
|
459
|
+
|
460
|
+
return dicts
|
416
461
|
end
|
462
|
+
|
417
463
|
end # Speller
|
418
464
|
end # Aspell
|
419
465
|
end # FFI
|
data/lib/ffi/aspell/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffi-aspell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|