ffi-aspell 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +7 -3
- data/LICENSE +1 -1
- data/doc/DCO.md +25 -0
- data/doc/changelog.md +22 -0
- data/doc/css/common.css +76 -0
- data/lib/ffi/aspell.rb +4 -256
- data/lib/ffi/aspell/aspell.rb +251 -0
- data/lib/ffi/aspell/error.rb +0 -2
- data/lib/ffi/aspell/speller.rb +160 -55
- data/lib/ffi/aspell/version.rb +1 -1
- metadata +36 -59
- data/.gitignore +0 -3
- data/.ruby-version +0 -1
- data/Gemfile +0 -3
- data/README.md +0 -65
- data/Rakefile +0 -3
- data/ffi-aspell.gemspec +0 -21
- data/pkg/.gitkeep +0 -0
- data/spec/ffi/aspell/speller.rb +0 -107
- data/spec/ffi/aspell/suggestions.rb +0 -57
- data/spec/fixtures/personal.en.pws +0 -3
- data/spec/fixtures/personal.nl.pws +0 -3
- data/spec/helper.rb +0 -24
- data/task/build.rake +0 -15
- data/task/memory.rake +0 -50
- data/task/test.rake +0 -4
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5d5f68f43c75d63cc6396df932cc489fdd686e6b
|
4
|
+
data.tar.gz: 9dff43b8df8ecf21e50a6dec8ef569e1714f51be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5055b910a021d5ca54b2aa779528c5c77cc8eda99e2db966e33b58c1f981b42d6e4ae4c3e9e3c59c395db818bc97a2f01f80e58b848979e7b2321a2b7cd7fbe
|
7
|
+
data.tar.gz: 3cabedaa1799f4ecdb46f4c7454df765c98953718389d79a83687f4fd9bae9e252a0d2b53473b0314e743018f11086aac7a6ac9ea94adc3184c028e069c286db
|
data/.yardopts
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
./lib/ffi/**/*.rb
|
1
|
+
./lib/ffi/aspell/**/*.rb ./lib/ffi/aspell.rb
|
2
2
|
-m markdown
|
3
|
-
-M
|
4
|
-
-o
|
3
|
+
-M kramdown
|
4
|
+
-o yardoc
|
5
5
|
-r ./README.md
|
6
6
|
--private
|
7
7
|
--protected
|
8
|
+
--asset ./doc/css/common.css:css/common.css
|
9
|
+
--verbose
|
8
10
|
-
|
11
|
+
./doc/*.md
|
9
12
|
LICENSE
|
13
|
+
CONTRIBUTING.md
|
data/LICENSE
CHANGED
data/doc/DCO.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Developer's Certificate of Origin 1.0
|
2
|
+
|
3
|
+
By making a contribution to this project, I certify that:
|
4
|
+
|
5
|
+
1. The contribution was created in whole or in part by me and I
|
6
|
+
have the right to submit it under the open source license
|
7
|
+
indicated in the file LICENSE; or
|
8
|
+
|
9
|
+
2. The contribution is based upon previous work that, to the best
|
10
|
+
of my knowledge, is covered under an appropriate open source
|
11
|
+
license and I have the right under that license to submit that
|
12
|
+
work with modifications, whether created in whole or in part
|
13
|
+
by me, under the same open source license (unless I am
|
14
|
+
permitted to submit under a different license), as indicated
|
15
|
+
in the file LICENSE; or
|
16
|
+
|
17
|
+
3. The contribution was provided directly to me by some other
|
18
|
+
person who certified (1), (2) or (3) and I have not modified
|
19
|
+
it.
|
20
|
+
|
21
|
+
4. I understand and agree that this project and the contribution
|
22
|
+
are public and that a record of the contribution (including all
|
23
|
+
personal information I submit with it, including my sign-off) is
|
24
|
+
maintained indefinitely and may be redistributed consistent with
|
25
|
+
this project or the open source license(s) involved.
|
data/doc/changelog.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.0.0 - 2014-09-10
|
4
|
+
|
5
|
+
The first stable release of the Gem (at least according to semver). This release
|
6
|
+
contains a bunch of under the hood changes, a new project structure and a new
|
7
|
+
test suite.
|
8
|
+
|
9
|
+
The biggest change is that thanks to Chris Schmich
|
10
|
+
(<https://github.com/schmich>) ffi-aspell no longer leaks certain native
|
11
|
+
resources. A finalizer is used to clean up these resources but you can
|
12
|
+
explicitly free them by calling `close` on a speller object. See the following
|
13
|
+
issues/pull-requests for more information:
|
14
|
+
|
15
|
+
* <https://github.com/YorickPeterse/ffi-aspell/pull/15>
|
16
|
+
* <https://github.com/YorickPeterse/ffi-aspell/pull/16>
|
17
|
+
* <https://github.com/YorickPeterse/ffi-aspell/pull/17>
|
18
|
+
|
19
|
+
Another big change, and one of the reasons for the major version increase, is
|
20
|
+
the removal of support for Ruby 1.8.7. To be exact, ffi-aspell now requires Ruby
|
21
|
+
1.9.3 or newer. This simplifies some of the internal encoding handling and just
|
22
|
+
generally makes my life easier.
|
data/doc/css/common.css
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
body
|
2
|
+
{
|
3
|
+
font-size: 14px;
|
4
|
+
line-height: 1.6;
|
5
|
+
margin: 0 auto;
|
6
|
+
max-width: 960px;
|
7
|
+
}
|
8
|
+
|
9
|
+
p code
|
10
|
+
{
|
11
|
+
background: #f2f2f2;
|
12
|
+
padding-left: 3px;
|
13
|
+
padding-right: 3px;
|
14
|
+
}
|
15
|
+
|
16
|
+
pre.code
|
17
|
+
{
|
18
|
+
font-size: 13px;
|
19
|
+
line-height: 1.4;
|
20
|
+
overflow: auto;
|
21
|
+
}
|
22
|
+
|
23
|
+
blockquote
|
24
|
+
{
|
25
|
+
border-left: 5px solid #eee;
|
26
|
+
margin: 0px;
|
27
|
+
padding-left: 15px;
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* YARD uses generic table styles, using a special class means those tables
|
32
|
+
* don't get messed up.
|
33
|
+
*/
|
34
|
+
.table
|
35
|
+
{
|
36
|
+
border: 1px solid #ccc;
|
37
|
+
border-right: none;
|
38
|
+
border-collapse: separate;
|
39
|
+
border-spacing: 0;
|
40
|
+
text-align: left;
|
41
|
+
}
|
42
|
+
|
43
|
+
.table.full
|
44
|
+
{
|
45
|
+
width: 100%;
|
46
|
+
}
|
47
|
+
|
48
|
+
.table .field_name
|
49
|
+
{
|
50
|
+
min-width: 160px;
|
51
|
+
}
|
52
|
+
|
53
|
+
.table thead tr th.no_sort:first-child
|
54
|
+
{
|
55
|
+
width: 25px;
|
56
|
+
}
|
57
|
+
|
58
|
+
.table thead tr th, .table tbody tr td
|
59
|
+
{
|
60
|
+
border-bottom: 1px solid #ccc;
|
61
|
+
border-right: 1px solid #ccc;
|
62
|
+
min-width: 20px;
|
63
|
+
padding: 8px 5px;
|
64
|
+
text-align: left;
|
65
|
+
vertical-align: top;
|
66
|
+
}
|
67
|
+
|
68
|
+
.table tbody tr:last-child td
|
69
|
+
{
|
70
|
+
border-bottom: none;
|
71
|
+
}
|
72
|
+
|
73
|
+
.table tr:nth-child(odd) td
|
74
|
+
{
|
75
|
+
background: #f9f9f9;
|
76
|
+
}
|
data/lib/ffi/aspell.rb
CHANGED
@@ -1,258 +1,6 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
module FFI
|
8
|
-
##
|
9
|
-
# FFI::Aspell is an FFI binding for the Aspell spell checking library. Basic
|
10
|
-
# usage is as following:
|
11
|
-
#
|
12
|
-
# require 'ffi/aspell'
|
13
|
-
#
|
14
|
-
# speller = FFI::Aspell::Speller.new
|
15
|
-
#
|
16
|
-
# speller.correct?('cookie') # => true
|
17
|
-
# speller.correct?('cookei') # => false
|
18
|
-
#
|
19
|
-
# For more information see {FFI::Aspell::Speller}.
|
20
|
-
#
|
21
|
-
# @since 13-04-2012
|
22
|
-
#
|
23
|
-
module Aspell
|
24
|
-
extend FFI::Library
|
25
|
-
ffi_lib 'aspell'
|
26
|
-
|
27
|
-
##
|
28
|
-
# Creates a pointer for a configuration struct.
|
29
|
-
#
|
30
|
-
# @since 24-04-2012
|
31
|
-
# @method config_new
|
32
|
-
# @scope class
|
33
|
-
# @return [FFI::Pointer]
|
34
|
-
#
|
35
|
-
attach_function 'config_new',
|
36
|
-
'new_aspell_config',
|
37
|
-
[],
|
38
|
-
:pointer
|
39
|
-
|
40
|
-
##
|
41
|
-
# Retrieves the value of a given configuration item. The value is returned
|
42
|
-
# as a string or nil upon failure.
|
43
|
-
#
|
44
|
-
# @example
|
45
|
-
# config = FFI::Aspell.config_new
|
46
|
-
# value = FFI::Aspell.config_retrieve(config, 'lang')
|
47
|
-
#
|
48
|
-
# puts value # => "en_US"
|
49
|
-
#
|
50
|
-
# @since 24-04-2012
|
51
|
-
# @method config_retrieve(config, key)
|
52
|
-
# @scope class
|
53
|
-
# @param [FFI::Pointer] config A pointer to a configuration struct.
|
54
|
-
# @param [String] key The name of the configuration item to retrieve.
|
55
|
-
# @return [String]
|
56
|
-
#
|
57
|
-
attach_function 'config_retrieve',
|
58
|
-
'aspell_config_retrieve',
|
59
|
-
[:pointer, :string],
|
60
|
-
:string
|
61
|
-
|
62
|
-
##
|
63
|
-
# Retrieves the default value of a configuration item.
|
64
|
-
#
|
65
|
-
# @since 24-04-2012
|
66
|
-
# @method config_retrieve_default(config, key)
|
67
|
-
# @scope class
|
68
|
-
# @see FFI::Aspell.config_retrieve
|
69
|
-
#
|
70
|
-
attach_function 'config_retrieve_default',
|
71
|
-
'aspell_config_get_default',
|
72
|
-
[:pointer, :string],
|
73
|
-
:string
|
74
|
-
|
75
|
-
##
|
76
|
-
# Sets the new value of the specified configuration item.
|
77
|
-
#
|
78
|
-
# @example
|
79
|
-
# config = FFI::Aspell.config_new
|
80
|
-
#
|
81
|
-
# FFI::Aspell.config_replace(config, 'lang', 'nl')
|
82
|
-
#
|
83
|
-
# @since 24-04-2012
|
84
|
-
# @method config_replace(config, key, value)
|
85
|
-
# @scope class
|
86
|
-
# @param [FFI::Pointer] config Pointer to the configuration struct.
|
87
|
-
# @param [String] key The name of the configuration item to set.
|
88
|
-
# @param [String] value The new value of the configuration item.
|
89
|
-
# @return [TrueClass|FalseClass]
|
90
|
-
#
|
91
|
-
attach_function 'config_replace',
|
92
|
-
'aspell_config_replace',
|
93
|
-
[:pointer, :string, :string],
|
94
|
-
:bool
|
95
|
-
|
96
|
-
##
|
97
|
-
# Sets the value of the specified configuration item back to its default
|
98
|
-
# value.
|
99
|
-
#
|
100
|
-
# @example
|
101
|
-
# config = FFI::Aspell.config_new
|
102
|
-
#
|
103
|
-
# FFI::Aspell.config_replace(config, 'lang', 'nl')
|
104
|
-
# FFI::Aspell.config_remove(config, 'lang')
|
105
|
-
#
|
106
|
-
# @since 24-04-2012
|
107
|
-
# @method config_remove(config, key)
|
108
|
-
# @scope class
|
109
|
-
# @param [FFI::Pointer] config Pointer to the configuration struct.
|
110
|
-
# @param [String] key The name of the configuration item to reset.
|
111
|
-
# @return [TrueClass|FalseClass]
|
112
|
-
#
|
113
|
-
attach_function 'config_remove',
|
114
|
-
'aspell_config_remove',
|
115
|
-
[:pointer, :string],
|
116
|
-
:bool
|
117
|
-
|
118
|
-
# Spell checking related functions.
|
119
|
-
|
120
|
-
##
|
121
|
-
# Creates a pointer to a speller struct.
|
122
|
-
#
|
123
|
-
# @example
|
124
|
-
# config = FFI::Aspell.config_new
|
125
|
-
# speller = FFI::Aspell.speller_new(config)
|
126
|
-
#
|
127
|
-
# @since 24-04-2012
|
128
|
-
# @method speller_new(config)
|
129
|
-
# @scope class
|
130
|
-
# @param [FFI::Pointer] config The configuration struct to use for the
|
131
|
-
# speller.
|
132
|
-
# @return [FFI::Pointer]
|
133
|
-
#
|
134
|
-
attach_function 'speller_new',
|
135
|
-
'new_aspell_speller',
|
136
|
-
[:pointer],
|
137
|
-
:pointer
|
138
|
-
|
139
|
-
##
|
140
|
-
# Removes a speller pointer and frees the memory associated with said
|
141
|
-
# pointer.
|
142
|
-
#
|
143
|
-
# @since 24-04-2012
|
144
|
-
# @method speller_delete(speller)
|
145
|
-
# @scope class
|
146
|
-
# @param [FFI::Pointer] speller The pointer to remove.
|
147
|
-
#
|
148
|
-
attach_function 'speller_delete',
|
149
|
-
'delete_aspell_speller',
|
150
|
-
[:pointer],
|
151
|
-
:void
|
152
|
-
|
153
|
-
##
|
154
|
-
# Checks if a given word is spelled correctly or not. If the word is valid
|
155
|
-
# `true` will be returned, `false` otherwise.
|
156
|
-
#
|
157
|
-
# @example
|
158
|
-
# config = FFI::Aspell.config_new
|
159
|
-
# speller = FFI::Aspell.speller_new(config)
|
160
|
-
# word = 'cookie'
|
161
|
-
# valid = FFI::Aspell.speller_check(speller, word, word.length)
|
162
|
-
#
|
163
|
-
# if valid
|
164
|
-
# puts 'The word "cookie" is valid'
|
165
|
-
# else
|
166
|
-
# puts 'The word "cookie" is invalid'
|
167
|
-
# end
|
168
|
-
#
|
169
|
-
# @since 24-04-2012
|
170
|
-
# @method speller_check(speller, word, length)
|
171
|
-
# @scope class
|
172
|
-
# @param [FFI::Pointer] speller Pointer to a speller struct to use.
|
173
|
-
# @param [String] word The word to check.
|
174
|
-
# @param [Fixnum] length The length of the word.
|
175
|
-
# @return [TrueClass|FalseClass]
|
176
|
-
#
|
177
|
-
attach_function 'speller_check',
|
178
|
-
'aspell_speller_check',
|
179
|
-
[:pointer, :string, :int],
|
180
|
-
:bool
|
181
|
-
|
182
|
-
# Functions for dealing with suggestions.
|
183
|
-
|
184
|
-
##
|
185
|
-
# Returns a pointer that can be used to retrieve a list of suggestions for a
|
186
|
-
# given word.
|
187
|
-
#
|
188
|
-
# @since 24-04-2012
|
189
|
-
# @method speller_suggest(speller, word, length)
|
190
|
-
# @see FFI::Aspell.speller_check
|
191
|
-
# @return [FFI::Pointer]
|
192
|
-
#
|
193
|
-
attach_function 'speller_suggest',
|
194
|
-
'aspell_speller_suggest',
|
195
|
-
[:pointer, :string, :int],
|
196
|
-
:pointer
|
197
|
-
|
198
|
-
##
|
199
|
-
# Returns a pointer to a list which can be used by
|
200
|
-
# {FFI::Aspell.string_enumeration_next} to retrieve all the suggested words.
|
201
|
-
#
|
202
|
-
# @since 24-04-2012
|
203
|
-
# @method word_list_elements(suggestions)
|
204
|
-
# @scope class
|
205
|
-
# @param [FFI::Pointer] suggestions A pointer with suggestions as returned
|
206
|
-
# by {FFI::Aspell.speller_suggest}
|
207
|
-
# @return [FFI::Pointer]
|
208
|
-
#
|
209
|
-
attach_function 'word_list_elements',
|
210
|
-
'aspell_word_list_elements',
|
211
|
-
[:pointer],
|
212
|
-
:pointer
|
213
|
-
|
214
|
-
##
|
215
|
-
# Removes the pointer returned by {FFI::Aspell.word_list_elements} and frees
|
216
|
-
# the associated memory.
|
217
|
-
#
|
218
|
-
# @since 24-04-2012
|
219
|
-
# @method string_enumeration_delete(elements)
|
220
|
-
# @scope class
|
221
|
-
# @param [FFI::Pointer] elements A pointer for a list of elements as
|
222
|
-
# returned by {FFI::Aspell.word_list_elements}.
|
223
|
-
#
|
224
|
-
attach_function 'string_enumeration_delete',
|
225
|
-
'delete_aspell_string_enumeration',
|
226
|
-
[:pointer],
|
227
|
-
:void
|
228
|
-
|
229
|
-
##
|
230
|
-
# Retrieves the next item in the list of suggestions.
|
231
|
-
#
|
232
|
-
# @example
|
233
|
-
# speller = FFI::Aspell.speller_new(FFI::Aspell.config_new)
|
234
|
-
# word = 'cookie'
|
235
|
-
# list = FFI::Aspell.speller_suggest(speller, word, word.length)
|
236
|
-
# elements = FFI::Aspell.word_list_elements(list)
|
237
|
-
# words = []
|
238
|
-
#
|
239
|
-
# while word = FFI::Aspell.string_enumeration_next(elements)
|
240
|
-
# words << word
|
241
|
-
# end
|
242
|
-
#
|
243
|
-
# FFI::Aspell.string_enumeration_delete(elements)
|
244
|
-
# FFI::Aspell.speller_delete(speller)
|
245
|
-
#
|
246
|
-
# @since 24-04-2012
|
247
|
-
# @method string_enumeration_next(elements)
|
248
|
-
# @scope class
|
249
|
-
# @param [FFI::Pointer] elements Pointer to a list of elements as returned
|
250
|
-
# by {FFI::Aspell.word_list_elements}.
|
251
|
-
# @return [String|NilClass]
|
252
|
-
#
|
253
|
-
attach_function 'string_enumeration_next',
|
254
|
-
'aspell_string_enumeration_next',
|
255
|
-
[:pointer],
|
256
|
-
:string
|
257
|
-
end # Aspell
|
258
|
-
end # FFI
|
3
|
+
require_relative 'aspell/aspell'
|
4
|
+
require_relative 'aspell/error'
|
5
|
+
require_relative 'aspell/speller'
|
6
|
+
require_relative 'aspell/version'
|
@@ -0,0 +1,251 @@
|
|
1
|
+
module FFI
|
2
|
+
##
|
3
|
+
# FFI::Aspell is an FFI binding for the Aspell spell checking library. Basic
|
4
|
+
# usage is as following:
|
5
|
+
#
|
6
|
+
# require 'ffi/aspell'
|
7
|
+
#
|
8
|
+
# speller = FFI::Aspell::Speller.new
|
9
|
+
#
|
10
|
+
# speller.correct?('cookie') # => true
|
11
|
+
# speller.correct?('cookei') # => false
|
12
|
+
#
|
13
|
+
# For more information see {FFI::Aspell::Speller}.
|
14
|
+
#
|
15
|
+
module Aspell
|
16
|
+
extend FFI::Library
|
17
|
+
ffi_lib 'aspell'
|
18
|
+
|
19
|
+
##
|
20
|
+
# Creates a pointer for a configuration struct.
|
21
|
+
#
|
22
|
+
# @method config_new
|
23
|
+
# @scope class
|
24
|
+
# @return [FFI::Pointer]
|
25
|
+
#
|
26
|
+
attach_function 'config_new',
|
27
|
+
'new_aspell_config',
|
28
|
+
[],
|
29
|
+
:pointer
|
30
|
+
|
31
|
+
##
|
32
|
+
# Removes a config pointer and frees the memory associated with said
|
33
|
+
# pointer.
|
34
|
+
#
|
35
|
+
# @method config_delete(config)
|
36
|
+
# @scope class
|
37
|
+
# @param [FFI::Pointer] config The pointer to remove.
|
38
|
+
#
|
39
|
+
attach_function 'config_delete',
|
40
|
+
'delete_aspell_config',
|
41
|
+
[:pointer],
|
42
|
+
:void
|
43
|
+
|
44
|
+
##
|
45
|
+
# Retrieves the value of a given configuration item. The value is returned
|
46
|
+
# as a string or nil upon failure.
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# config = FFI::Aspell.config_new
|
50
|
+
# value = FFI::Aspell.config_retrieve(config, 'lang')
|
51
|
+
#
|
52
|
+
# puts value # => "en_US"
|
53
|
+
#
|
54
|
+
# @method config_retrieve(config, key)
|
55
|
+
# @scope class
|
56
|
+
# @param [FFI::Pointer] config A pointer to a configuration struct.
|
57
|
+
# @param [String] key The name of the configuration item to retrieve.
|
58
|
+
# @return [String]
|
59
|
+
#
|
60
|
+
attach_function 'config_retrieve',
|
61
|
+
'aspell_config_retrieve',
|
62
|
+
[:pointer, :string],
|
63
|
+
:string
|
64
|
+
|
65
|
+
##
|
66
|
+
# Retrieves the default value of a configuration item.
|
67
|
+
#
|
68
|
+
# @method config_retrieve_default(config, key)
|
69
|
+
# @scope class
|
70
|
+
# @see FFI::Aspell.config_retrieve
|
71
|
+
#
|
72
|
+
attach_function 'config_retrieve_default',
|
73
|
+
'aspell_config_get_default',
|
74
|
+
[:pointer, :string],
|
75
|
+
:string
|
76
|
+
|
77
|
+
##
|
78
|
+
# Sets the new value of the specified configuration item.
|
79
|
+
#
|
80
|
+
# @example
|
81
|
+
# config = FFI::Aspell.config_new
|
82
|
+
#
|
83
|
+
# FFI::Aspell.config_replace(config, 'lang', 'nl')
|
84
|
+
#
|
85
|
+
# @method config_replace(config, key, value)
|
86
|
+
# @scope class
|
87
|
+
# @param [FFI::Pointer] config Pointer to the configuration struct.
|
88
|
+
# @param [String] key The name of the configuration item to set.
|
89
|
+
# @param [String] value The new value of the configuration item.
|
90
|
+
# @return [TrueClass|FalseClass]
|
91
|
+
#
|
92
|
+
attach_function 'config_replace',
|
93
|
+
'aspell_config_replace',
|
94
|
+
[:pointer, :string, :string],
|
95
|
+
:bool
|
96
|
+
|
97
|
+
##
|
98
|
+
# Sets the value of the specified configuration item back to its default
|
99
|
+
# value.
|
100
|
+
#
|
101
|
+
# @example
|
102
|
+
# config = FFI::Aspell.config_new
|
103
|
+
#
|
104
|
+
# FFI::Aspell.config_replace(config, 'lang', 'nl')
|
105
|
+
# FFI::Aspell.config_remove(config, 'lang')
|
106
|
+
#
|
107
|
+
# @method config_remove(config, key)
|
108
|
+
# @scope class
|
109
|
+
# @param [FFI::Pointer] config Pointer to the configuration struct.
|
110
|
+
# @param [String] key The name of the configuration item to reset.
|
111
|
+
# @return [TrueClass|FalseClass]
|
112
|
+
#
|
113
|
+
attach_function 'config_remove',
|
114
|
+
'aspell_config_remove',
|
115
|
+
[:pointer, :string],
|
116
|
+
:bool
|
117
|
+
|
118
|
+
# Spell checking related functions.
|
119
|
+
|
120
|
+
##
|
121
|
+
# Creates a pointer to a speller struct.
|
122
|
+
#
|
123
|
+
# @example
|
124
|
+
# config = FFI::Aspell.config_new
|
125
|
+
# speller = FFI::Aspell.speller_new(config)
|
126
|
+
#
|
127
|
+
# @method speller_new(config)
|
128
|
+
# @scope class
|
129
|
+
# @param [FFI::Pointer] config The configuration struct to use for the
|
130
|
+
# speller.
|
131
|
+
# @return [FFI::Pointer]
|
132
|
+
#
|
133
|
+
attach_function 'speller_new',
|
134
|
+
'new_aspell_speller',
|
135
|
+
[:pointer],
|
136
|
+
:pointer
|
137
|
+
|
138
|
+
##
|
139
|
+
# Removes a speller pointer and frees the memory associated with said
|
140
|
+
# pointer.
|
141
|
+
#
|
142
|
+
# @method speller_delete(speller)
|
143
|
+
# @scope class
|
144
|
+
# @param [FFI::Pointer] speller The pointer to remove.
|
145
|
+
#
|
146
|
+
attach_function 'speller_delete',
|
147
|
+
'delete_aspell_speller',
|
148
|
+
[:pointer],
|
149
|
+
:void
|
150
|
+
|
151
|
+
##
|
152
|
+
# Checks if a given word is spelled correctly or not. If the word is valid
|
153
|
+
# `true` will be returned, `false` otherwise.
|
154
|
+
#
|
155
|
+
# @example
|
156
|
+
# config = FFI::Aspell.config_new
|
157
|
+
# speller = FFI::Aspell.speller_new(config)
|
158
|
+
# word = 'cookie'
|
159
|
+
# valid = FFI::Aspell.speller_check(speller, word, word.length)
|
160
|
+
#
|
161
|
+
# if valid
|
162
|
+
# puts 'The word "cookie" is valid'
|
163
|
+
# else
|
164
|
+
# puts 'The word "cookie" is invalid'
|
165
|
+
# end
|
166
|
+
#
|
167
|
+
# @method speller_check(speller, word, length)
|
168
|
+
# @scope class
|
169
|
+
# @param [FFI::Pointer] speller Pointer to a speller struct to use.
|
170
|
+
# @param [String] word The word to check.
|
171
|
+
# @param [Fixnum] length The length of the word.
|
172
|
+
# @return [TrueClass|FalseClass]
|
173
|
+
#
|
174
|
+
attach_function 'speller_check',
|
175
|
+
'aspell_speller_check',
|
176
|
+
[:pointer, :string, :int],
|
177
|
+
:bool
|
178
|
+
|
179
|
+
# Functions for dealing with suggestions.
|
180
|
+
|
181
|
+
##
|
182
|
+
# Returns a pointer that can be used to retrieve a list of suggestions for a
|
183
|
+
# given word.
|
184
|
+
#
|
185
|
+
# @method speller_suggest(speller, word, length)
|
186
|
+
# @see FFI::Aspell.speller_check
|
187
|
+
# @return [FFI::Pointer]
|
188
|
+
#
|
189
|
+
attach_function 'speller_suggest',
|
190
|
+
'aspell_speller_suggest',
|
191
|
+
[:pointer, :string, :int],
|
192
|
+
:pointer
|
193
|
+
|
194
|
+
##
|
195
|
+
# Returns a pointer to a list which can be used by
|
196
|
+
# {FFI::Aspell.string_enumeration_next} to retrieve all the suggested words.
|
197
|
+
#
|
198
|
+
# @method word_list_elements(suggestions)
|
199
|
+
# @scope class
|
200
|
+
# @param [FFI::Pointer] suggestions A pointer with suggestions as returned
|
201
|
+
# by {FFI::Aspell.speller_suggest}
|
202
|
+
# @return [FFI::Pointer]
|
203
|
+
#
|
204
|
+
attach_function 'word_list_elements',
|
205
|
+
'aspell_word_list_elements',
|
206
|
+
[:pointer],
|
207
|
+
:pointer
|
208
|
+
|
209
|
+
##
|
210
|
+
# Removes the pointer returned by {FFI::Aspell.word_list_elements} and frees
|
211
|
+
# the associated memory.
|
212
|
+
#
|
213
|
+
# @method string_enumeration_delete(elements)
|
214
|
+
# @scope class
|
215
|
+
# @param [FFI::Pointer] elements A pointer for a list of elements as
|
216
|
+
# returned by {FFI::Aspell.word_list_elements}.
|
217
|
+
#
|
218
|
+
attach_function 'string_enumeration_delete',
|
219
|
+
'delete_aspell_string_enumeration',
|
220
|
+
[:pointer],
|
221
|
+
:void
|
222
|
+
|
223
|
+
##
|
224
|
+
# Retrieves the next item in the list of suggestions.
|
225
|
+
#
|
226
|
+
# @example
|
227
|
+
# speller = FFI::Aspell.speller_new(FFI::Aspell.config_new)
|
228
|
+
# word = 'cookie'
|
229
|
+
# list = FFI::Aspell.speller_suggest(speller, word, word.length)
|
230
|
+
# elements = FFI::Aspell.word_list_elements(list)
|
231
|
+
# words = []
|
232
|
+
#
|
233
|
+
# while word = FFI::Aspell.string_enumeration_next(elements)
|
234
|
+
# words << word
|
235
|
+
# end
|
236
|
+
#
|
237
|
+
# FFI::Aspell.string_enumeration_delete(elements)
|
238
|
+
# FFI::Aspell.speller_delete(speller)
|
239
|
+
#
|
240
|
+
# @method string_enumeration_next(elements)
|
241
|
+
# @scope class
|
242
|
+
# @param [FFI::Pointer] elements Pointer to a list of elements as returned
|
243
|
+
# by {FFI::Aspell.word_list_elements}.
|
244
|
+
# @return [String|NilClass]
|
245
|
+
#
|
246
|
+
attach_function 'string_enumeration_next',
|
247
|
+
'aspell_string_enumeration_next',
|
248
|
+
[:pointer],
|
249
|
+
:string
|
250
|
+
end # Aspell
|
251
|
+
end # FFI
|