Permalink
Browse files

I can haz initial commit?

Signed-off-by: Yorick Peterse <yorickpeterse@gmail.com>
  • Loading branch information...
0 parents commit 164f65a465649106e00057e3a1d695fd4b5c2c63 @YorickPeterse committed Apr 13, 2012
Showing with 300 additions and 0 deletions.
  1. +4 −0 .gems
  2. +2 −0 .gitignore
  3. +1 −0 .rvmrc
  4. +9 −0 .yardopts
  5. +19 −0 LICENSE
  6. +64 −0 README.md
  7. +3 −0 Rakefile
  8. +20 −0 ffi-aspell.gemspec
  9. +55 −0 lib/ffi/aspell.rb
  10. +11 −0 lib/ffi/aspell/error.rb
  11. +61 −0 lib/ffi/aspell/speller.rb
  12. +5 −0 lib/ffi/aspell/version.rb
  13. 0 pkg/.gitkeep
  14. +15 −0 spec/ffi/aspell/aspell.rb
  15. +7 −0 spec/ffi/aspell/speller.rb
  16. +5 −0 spec/helper.rb
  17. +15 −0 task/build.rake
  18. +4 −0 task/test.rake
4 .gems
@@ -0,0 +1,4 @@
+ffi
+redcarpet
+yard
+bacon
2 .gitignore
@@ -0,0 +1,2 @@
+pkg/*.gem
+doc
1 .rvmrc
@@ -0,0 +1 @@
+rvm use --create 1.9.3@ffi-aspell
9 .yardopts
@@ -0,0 +1,9 @@
+./lib/ffi/**/*.rb
+-m markdown
+-M redcarpet
+-o ./doc
+-r ./README.md
+--private
+--protected
+-
+LICENSE
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2012, Yorick Peterse
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
64 README.md
@@ -0,0 +1,64 @@
+# FFI::Aspell
+
+FFI::Aspell is an FFI binding for the Aspell library. It was mainly written as
+[Raspell][raspell], a C binding for Aspell, is buggy and no longer maintained by
+the main author as of April 2012.
+
+## Requirements
+
+* FFI: `gem install ffi`
+* Aspell (`sudo pacman -S aspell` if you're on Arch Linux)
+
+## Usage
+
+Install the gem:
+
+ $ gem install ffi-aspell
+
+Load it:
+
+ require 'ffi/aspell'
+
+The primary class is `FFI::Aspell::Speller`, this class can be used to check for
+spelling errors and the like:
+
+ speller = FFI::Aspell::Speller.new('en_US')
+
+ if speller.correct?('cookie')
+ puts 'The word "cookie" is correct'
+ else
+ puts 'The word "cookie" is incorrect'
+ end
+
+For more information see the YARD documentation.
+
+## Hacking & Contributing
+
+1. Make sure that Aspell and the English and Dutch dictionaries for it are
+ installed as well. On Arch Linux this can be done by running `sudo pacman -S
+ aspell aspell-en aspell-nl`.
+2. Import the gems using RVM: `rvm gemset import .gems`.
+3. Run the tests to see if everything is working: `rake test`
+4. Hack away!
+
+## Coding Standards
+
+* FFI functions go in FFI::Aspell
+* Attached function names should resemble the C function names as much as
+ possible.
+* No more than 80 characters per line of code.
+* Document your code, pull requests with big changes but without documentation
+ will be rejected.
+* Git commits should be signed off, this can be done by running `git commit
+ --sign`. Commits that are not signed off will be rejected.
+* Follow the Git commit standards are described here:
+ <http://ramaze.net/documentation/file.contributing.html#Commit_Messages>.
+* Test your code! Pull requests without tests will not be accepted.
+
+## License
+
+The code in this repository is licensed under the MIT license. A copy of this
+license can be found in the file "LICENSE" in the root directory of this
+repository.
+
+[raspell]: https://github.com/evan/raspell
3 Rakefile
@@ -0,0 +1,3 @@
+Dir['./task/*.rake'].each { |task| import(task) }
+
+task :default => :test
20 ffi-aspell.gemspec
@@ -0,0 +1,20 @@
+require File.expand_path('../lib/ffi/aspell/version', __FILE__)
+
+Gem::Specification.new do |s|
+ s.name = 'ffi-aspell'
+ s.version = FFI::Aspell::VERSION
+ s.date = '2012-04-13'
+ s.authors = ['Yorick Peterse']
+ s.email = 'yorickpeterse@gmail.com'
+ s.summary = 'FFI bindings for Aspell'
+ s.homepage = 'https://github.com/YorickPeterse/ffi-aspell'
+ s.description = s.summary
+ s.files = Dir['./lib/**/*.rb']
+ s.has_rdoc = 'yard'
+
+ s.add_dependency('ffi', ['>= 1.0.11'])
+
+ s.add_development_dependency('yard',['>= 0.7.5'])
+ s.add_development_dependency('redcarpet', ['>= 2.1.1'])
+ s.add_development_dependency('bacon', ['>= 1.1.0'])
+end
55 lib/ffi/aspell.rb
@@ -0,0 +1,55 @@
+require 'ffi'
+
+$:.unshift(File.expand_path('../', __FILE__))
+
+require 'aspell/error'
+require 'aspell/speller'
+
+module FFI
+ ##
+ # FFI::Aspell is an FFI binding for the Aspell spell checking library.
+ #
+ # @since 13-04-2012
+ #
+ module Aspell
+ extend FFI::Library
+ ffi_lib 'aspell'
+
+ # Configuration functions.
+ attach_function 'config_new',
+ 'new_aspell_config',
+ [],
+ :pointer
+
+ attach_function 'config_retrieve',
+ 'aspell_config_retrieve',
+ [:pointer, :string],
+ :string
+
+ attach_function 'config_get_default',
+ 'aspell_config_get_default',
+ [:pointer, :string],
+ :string
+
+ attach_function 'config_replace',
+ 'aspell_config_replace',
+ [:pointer, :string, :string],
+ :bool
+
+ attach_function 'config_remove',
+ 'aspell_config_remove',
+ [:pointer, :string],
+ :bool
+
+ # Spell checking related functions.
+ attach_function 'speller_new',
+ 'new_aspell_speller',
+ [:pointer],
+ :pointer
+
+ attach_function 'speller_check',
+ 'aspell_speller_check',
+ [:pointer, :string, :int],
+ :bool
+ end # Aspell
+end # FFI
11 lib/ffi/aspell/error.rb
@@ -0,0 +1,11 @@
+module FFI
+ module Aspell
+ ##
+ # Error class used by methods such as {FFI::Aspell::Speller#get} and
+ # {FFI::Aspell::Speller#set}.
+ #
+ # @since 13-04-2012
+ #
+ class ConfigError < StandardError; end
+ end # Aspell
+end # FFI
61 lib/ffi/aspell/speller.rb
@@ -0,0 +1,61 @@
+module FFI
+ module Aspell
+ ##
+ # The Speller class is used for spell checking individual words as well as
+ # generating a list of suggestions.
+ #
+ # @since 13-04-2012
+ #
+ class Speller
+ ##
+ # Creates a new instance of the class, sets the language as well as the
+ # options specified in the `options` hash.
+ #
+ # @since 13-04-2012
+ # @param [String] language The language to use.
+ # @param [Hash] options A hash containing extra configuration options,
+ # such as the "personal" option to set.
+ #
+ def initialize(language, options = {})
+
+ end
+
+ ##
+ # Checks if the given word is correct or not.
+ #
+ # @since 13-04-2012
+ # @param [String] word The word to check.
+ # @return [TrueClass|FalseClass]
+ #
+ def correct?(word)
+
+ end
+
+ ##
+ # Sets a configuration option.
+ #
+ # @since 13-04-2012
+ # @param [#to_s] key The configuration key to set.
+ # @param [#to_s] value The value of the configuration key.
+ # @raise [FFI::Aspell::ConfigError] Raised when the configuration value
+ # could not be set.
+ #
+ def set(key, value)
+
+ end
+
+ ##
+ # Retrieves the value of the specified configuration item.
+ #
+ # @since 13-04-2012
+ # @param [String] key The configuration key to retrieve.
+ # @return [String]
+ # @raise [FFI::Aspell::ConfigError] Raised when the configuration item
+ # does not exist.
+ #
+ def get(key)
+
+ end
+ end # Speller
+ end # Aspell
+end # FFI
5 lib/ffi/aspell/version.rb
@@ -0,0 +1,5 @@
+module FFI
+ module Aspell
+ VERSION = '0.0.1'
+ end # Aspell
+end # FFI
0 pkg/.gitkeep
No changes.
15 spec/ffi/aspell/aspell.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../helper', __FILE__)
+
+# Basic set of specs to verify if FFI was able to create all the required
+# functions.
+describe 'FFI::Aspell' do
+ it 'All required C functions should exist' do
+ FFI::Aspell.respond_to?(:config_new).should == true
+ FFI::Aspell.respond_to?(:config_retrieve).should == true
+ FFI::Aspell.respond_to?(:config_get_default).should == true
+ FFI::Aspell.respond_to?(:config_replace).should == true
+ FFI::Aspell.respond_to?(:config_remove).should == true
+ FFI::Aspell.respond_to?(:speller_new).should == true
+ FFI::Aspell.respond_to?(:speller_check).should == true
+ end
+end
7 spec/ffi/aspell/speller.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../helper', __FILE__)
+
+describe 'FFI::Aspell::Speller' do
+ it 'Create a new instance of FFI::Aspell::Speller' do
+ speller = FFI::Aspell::Speller.new('en')
+ end
+end
5 spec/helper.rb
@@ -0,0 +1,5 @@
+require 'bacon'
+require File.expand_path('../../lib/ffi/aspell', __FILE__)
+
+Bacon.extend(Bacon::TapOutput)
+Bacon.summary_on_exit
15 task/build.rake
@@ -0,0 +1,15 @@
+namespace :build do
+ desc 'Builds a new Gem'
+ task :gem do
+ root = File.expand_path('../../', __FILE__)
+ gemspec = Gem::Specification.load(File.join(root, 'ffi-aspell.gemspec'))
+ name = "#{gemspec.name}-#{gemspec.version.version}.gem"
+ path = File.join(root, name)
+ pkg = File.join(root, 'pkg', name)
+
+ # Build and install the gem
+ sh('gem', 'build', File.join(root, 'ffi-aspell.gemspec'))
+ sh('mv' , path, pkg)
+ sh('gem', 'install', pkg)
+ end
+end
4 task/test.rake
@@ -0,0 +1,4 @@
+desc 'Runs all the tests using Bacon'
+task :test do
+ Dir['./spec/ffi/aspell/**/*.rb'].each { |spec| require(spec) }
+end

0 comments on commit 164f65a

Please sign in to comment.