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.
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- pkg/*.gem
2
- doc
3
- Gemfile.lock
@@ -1 +0,0 @@
1
- 1.9.3-p194
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
data/README.md DELETED
@@ -1,65 +0,0 @@
1
- # FFI::Aspell
2
-
3
- FFI::Aspell is an FFI binding for the Aspell library. It was mainly written as
4
- [Raspell][raspell], a C binding for Aspell, is buggy and no longer maintained by
5
- the main author as of April 2012.
6
-
7
- ## Requirements
8
-
9
- * FFI: `gem install ffi`
10
- * Aspell (`sudo pacman -S aspell` if you're on Arch Linux)
11
- * Dutch and Greek language packs for Aspell.
12
-
13
- ## Usage
14
-
15
- Install the gem:
16
-
17
- $ gem install ffi-aspell
18
-
19
- Load it:
20
-
21
- require 'ffi/aspell'
22
-
23
- The primary class is `FFI::Aspell::Speller`, this class can be used to check for
24
- spelling errors and the like:
25
-
26
- speller = FFI::Aspell::Speller.new('en_US')
27
-
28
- if speller.correct?('cookie')
29
- puts 'The word "cookie" is correct'
30
- else
31
- puts 'The word "cookie" is incorrect'
32
- end
33
-
34
- For more information see the YARD documentation.
35
-
36
- ## Hacking & Contributing
37
-
38
- 1. Make sure that Aspell and the English and Dutch dictionaries for it are
39
- installed as well. On Arch Linux this can be done by running `sudo pacman -S
40
- aspell aspell-en aspell-nl`.
41
- 2. Install the gems: `bundle install`
42
- 3. Run the tests to see if everything is working: `rake test`
43
- 4. Hack away!
44
-
45
- ## Coding Standards
46
-
47
- * FFI functions go in FFI::Aspell
48
- * Attached function names should resemble the C function names as much as
49
- possible.
50
- * No more than 80 characters per line of code.
51
- * Document your code, pull requests with big changes but without documentation
52
- will be rejected.
53
- * Git commits should be signed off, this can be done by running `git commit
54
- --sign`. Commits that are not signed off will be rejected.
55
- * Follow the Git commit standards are described here:
56
- <http://ramaze.net/documentation/file.contributing.html#Commit_Messages>.
57
- * Test your code! Pull requests without tests will not be accepted.
58
-
59
- ## License
60
-
61
- The code in this repository is licensed under the MIT license. A copy of this
62
- license can be found in the file "LICENSE" in the root directory of this
63
- repository.
64
-
65
- [raspell]: https://github.com/evan/raspell
data/Rakefile DELETED
@@ -1,3 +0,0 @@
1
- Dir['./task/*.rake'].each { |task| import(task) }
2
-
3
- task :default => :test
@@ -1,21 +0,0 @@
1
- require File.expand_path('../lib/ffi/aspell/version', __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = 'ffi-aspell'
5
- s.version = FFI::Aspell::VERSION
6
- s.date = '2012-07-07'
7
- s.authors = ['Yorick Peterse']
8
- s.email = 'yorickpeterse@gmail.com'
9
- s.summary = 'FFI bindings for Aspell'
10
- s.homepage = 'https://github.com/YorickPeterse/ffi-aspell'
11
- s.description = s.summary
12
- s.files = `git ls-files`.split("\n")
13
- s.has_rdoc = 'yard'
14
-
15
- s.add_dependency('ffi', ['>= 1.0.11'])
16
-
17
- s.add_development_dependency('rake', ['>= 0.9.2.2'])
18
- s.add_development_dependency('yard',['>= 0.7.5'])
19
- s.add_development_dependency('redcarpet', ['>= 2.1.1'])
20
- s.add_development_dependency('bacon', ['>= 1.1.0'])
21
- end
File without changes
@@ -1,107 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require File.expand_path('../../../helper', __FILE__)
4
-
5
- describe 'FFI::Aspell::Speller' do
6
- it 'Set the language in the constructor' do
7
- FFI::Aspell::Speller.new.get('lang').should == 'en_US'
8
- FFI::Aspell::Speller.new('en').get('lang').should == 'en'
9
- FFI::Aspell::Speller.new('nl').get('lang').should == 'nl'
10
- end
11
-
12
- it 'Set options in the constructor' do
13
- FFI::Aspell::Speller.new.get('personal').should == '.aspell.en_US.pws'
14
-
15
- FFI::Aspell::Speller.new('en', :personal => 'foo') \
16
- .get(:personal).should == 'foo'
17
- end
18
-
19
- it 'Raise when setting a non existing option' do
20
- should.raise(FFI::Aspell::ConfigError) do
21
- FFI::Aspell::Speller.new.set('foo', 'bar')
22
- end
23
- end
24
-
25
- it 'Raise when retrieving a non existing option' do
26
- should.raise(FFI::Aspell::ConfigError) do
27
- FFI::Aspell::Speller.new.get('foo')
28
- end
29
- end
30
-
31
- it 'Retrieve the default value of an option' do
32
- FFI::Aspell::Speller.new.get_default('personal') \
33
- .should == '.aspell.en_US.pws'
34
- end
35
-
36
- it 'Reset an option to its default value' do
37
- speller = FFI::Aspell::Speller.new
38
-
39
- speller.set('personal', 'foo')
40
-
41
- speller.get('personal').should == 'foo'
42
-
43
- speller.reset('personal')
44
-
45
- speller.get('personal').should == '.aspell.en_US.pws'
46
- end
47
-
48
- it 'Validate various English words' do
49
- speller = FFI::Aspell::Speller.new('en')
50
-
51
- speller.correct?('cookie').should == true
52
- speller.correct?('werld').should == false
53
- speller.correct?('house').should == true
54
- speller.correct?('huis').should == false
55
- end
56
-
57
- it 'Validate various Dutch words' do
58
- speller = FFI::Aspell::Speller.new('nl')
59
-
60
- speller.correct?('koekje').should == true
61
- speller.correct?('werld').should == false
62
- speller.correct?('huis').should == true
63
- end
64
-
65
- it 'Validate some UTF-8 (Greek) words' do
66
- speller = FFI::Aspell::Speller.new('el')
67
-
68
- speller.correct?('χταπόδι').should == true
69
- speller.correct?('οιρανός').should == false
70
- end
71
-
72
- it 'Change the language of an existing speller object' do
73
- speller = FFI::Aspell::Speller.new
74
-
75
- speller.correct?('house').should == true
76
- speller.correct?('huis').should == false
77
-
78
- speller.set('lang', 'nl')
79
-
80
- speller.correct?('house').should == true
81
- speller.correct?('huis').should == true
82
- end
83
-
84
- it 'Use an English personal word list' do
85
- speller = FFI::Aspell::Speller.new('en')
86
-
87
- speller.correct?('github').should == false
88
- speller.correct?('nodoc').should == false
89
-
90
- speller.set(:personal, File.join(FIXTURES, 'personal.en.pws'))
91
-
92
- speller.correct?('github').should == true
93
- speller.correct?('nodoc').should == true
94
- end
95
-
96
- it 'Use a Dutch personal word list' do
97
- speller = FFI::Aspell::Speller.new('nl')
98
-
99
- speller.correct?('github').should == false
100
- speller.correct?('nodoc').should == false
101
-
102
- speller.set(:personal, File.join(FIXTURES, 'personal.nl.pws'))
103
-
104
- speller.correct?('github').should == true
105
- speller.correct?('nodoc').should == true
106
- end
107
- end
@@ -1,57 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require File.expand_path('../../../helper', __FILE__)
4
-
5
- describe 'FFI::Aspell::Speller#suggestions' do
6
- it 'Return a list of word suggestions using the default mode' do
7
- speller = FFI::Aspell::Speller.new
8
- suggestions = speller.suggestions('cookei')
9
-
10
- suggestions.include?('coke').should == true
11
- suggestions.include?('cookie').should == true
12
- suggestions.include?('cooked').should == true
13
- end
14
-
15
- it 'Return a list of UTF-8 words' do
16
- with_internal_encoding('UTF-8') do
17
- speller = FFI::Aspell::Speller.new('el')
18
- suggestions = speller.suggestions('χταπίδι')
19
-
20
- suggestions.include?('χταπόδι').should == true
21
- suggestions.include?('απίδι').should == true
22
- end
23
- end
24
-
25
- it 'Return a list of word suggestions using the "bad-spellers" mode' do
26
- speller = FFI::Aspell::Speller.new
27
-
28
- # Get the amount of suggestions for the normal mode. The "bad-spellers" mode
29
- # should result in a lot more possible suggestions.
30
- normal_length = speller.suggestions('cookei').length
31
-
32
- speller.suggestion_mode = 'bad-spellers'
33
- suggestions = speller.suggestions('cookei')
34
-
35
- suggestions.include?('coke').should == true
36
- suggestions.include?('cookie').should == true
37
- suggestions.include?('cooked').should == true
38
-
39
- suggestions.length.should > normal_length
40
- end
41
-
42
- it 'Raise an error when an invalid suggestion mode is used' do
43
- speller = FFI::Aspell::Speller.new
44
-
45
- should.raise(FFI::Aspell::ConfigError) do
46
- speller.suggestion_mode = 'does-not-exist'
47
- end
48
-
49
- speller.suggestion_mode.should == 'normal'
50
-
51
- should.not.raise(FFI::Aspell::ConfigError) do
52
- speller.suggestion_mode = 'ultra'
53
- end
54
-
55
- speller.suggestion_mode.should == 'ultra'
56
- end
57
- end
@@ -1,3 +0,0 @@
1
- personal_ws-1.1 en 2 utf-8
2
- github
3
- nodoc
@@ -1,3 +0,0 @@
1
- personal_ws-1.1 nl 2 utf-8
2
- github
3
- nodoc
@@ -1,24 +0,0 @@
1
- require 'bacon'
2
- require File.expand_path('../../lib/ffi/aspell', __FILE__)
3
-
4
- Bacon.extend(Bacon::TapOutput)
5
- Bacon.summary_on_exit
6
-
7
- FIXTURES = File.expand_path('../fixtures', __FILE__)
8
-
9
- ##
10
- # Used to change default internal encoding for certain tests.
11
- # Ruby uses default_internal (amongst others) when presenting
12
- # strings and when calling encode! without argument.
13
- # Rails explicitly sets it to UTF-8 on bootup
14
- #
15
- # @param [String] enc The encoding to switch to
16
- #
17
- def with_internal_encoding(enc)
18
- if defined?(Encoding)
19
- old_enc = Encoding.default_internal
20
- Encoding.default_internal = enc
21
- yield
22
- Encoding.default_internal = old_enc
23
- end
24
- end
@@ -1,15 +0,0 @@
1
- namespace :build do
2
- desc 'Builds a new Gem'
3
- task :gem do
4
- root = File.expand_path('../../', __FILE__)
5
- gemspec = Gem::Specification.load(File.join(root, 'ffi-aspell.gemspec'))
6
- name = "#{gemspec.name}-#{gemspec.version.version}.gem"
7
- path = File.join(root, name)
8
- pkg = File.join(root, 'pkg', name)
9
-
10
- # Build and install the gem
11
- sh('gem', 'build', File.join(root, 'ffi-aspell.gemspec'))
12
- sh('mv' , path, pkg)
13
- sh('gem', 'install', pkg)
14
- end
15
- end
@@ -1,50 +0,0 @@
1
- # Cheap way of benchmarking the memory usage of various parts of the FFI
2
- # binding.
3
- def benchmark_block(amount = 10000)
4
- require File.expand_path('../../lib/ffi/aspell', __FILE__)
5
-
6
- start_mem = `ps -o rss= #{Process.pid}`.to_f
7
-
8
- amount.times { yield }
9
-
10
- mem = ((`ps -o rss= #{Process.pid}`.to_f - start_mem) / 1024).round(2)
11
-
12
- puts "Memory increase in Megabytes: #{mem} MB"
13
- end
14
-
15
- namespace :memory do
16
- memory = proc { `ps -o rss= #{Process.pid}`.to_i }
17
-
18
- desc 'Show memory usage of Aspell.speller_new'
19
- task :speller, [:amount] do |task, args|
20
- args.with_defaults(:amount => 10000)
21
-
22
- benchmark_block(args.amount) do
23
- speller = FFI::Aspell.speller_new(FFI::Aspell.config_new)
24
-
25
- FFI::Aspell.speller_delete(speller)
26
- end
27
- end
28
-
29
- desc 'Show memory usage of Speller#correct?'
30
- task :correct, [:amount] do |task, args|
31
- args.with_defaults(:amount => 10000)
32
-
33
- benchmark_block(args.amount) do
34
- speller = FFI::Aspell::Speller.new
35
-
36
- speller.correct?('cookie')
37
- end
38
- end
39
-
40
- desc 'Show memory usage of Speller#suggestions'
41
- task :suggestions, [:amount] do |task, args|
42
- args.with_defaults(:amount => 10000)
43
-
44
- benchmark_block(args.amount) do
45
- speller = FFI::Aspell::Speller.new
46
-
47
- speller.suggestions('cookei')
48
- end
49
- end
50
- end
@@ -1,4 +0,0 @@
1
- desc 'Runs all the tests using Bacon'
2
- task :test do
3
- Dir['./spec/ffi/aspell/**/*.rb'].sort.each { |spec| require(spec) }
4
- end