{"id":25534905,"url":"https://github.com/diegojromerolopez/alfonsox","last_synced_at":"2025-11-11T20:21:21.075Z","repository":{"id":51222880,"uuid":"158870142","full_name":"diegojromerolopez/alfonsox","owner":"diegojromerolopez","description":"A spellchecking tool for ruby code files","archived":false,"fork":false,"pushed_at":"2021-05-19T20:24:57.000Z","size":64111,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-17T03:08:36.546Z","etag":null,"topics":["code-quality","dictionaries","hunspell","ruby","ruby-gem","spell-check","spellcheck","spellchecker"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diegojromerolopez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-23T19:18:19.000Z","updated_at":"2023-09-08T17:47:33.000Z","dependencies_parsed_at":"2022-08-21T02:10:31.840Z","dependency_job_id":null,"html_url":"https://github.com/diegojromerolopez/alfonsox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/diegojromerolopez/alfonsox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegojromerolopez%2Falfonsox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegojromerolopez%2Falfonsox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegojromerolopez%2Falfonsox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegojromerolopez%2Falfonsox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diegojromerolopez","download_url":"https://codeload.github.com/diegojromerolopez/alfonsox/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diegojromerolopez%2Falfonsox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259991210,"owners_count":22942586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-quality","dictionaries","hunspell","ruby","ruby-gem","spell-check","spellcheck","spellchecker"],"created_at":"2025-02-20T03:29:14.134Z","updated_at":"2025-11-11T20:21:16.048Z","avatar_url":"https://github.com/diegojromerolopez.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alfonso X\n\n[![Gem Version](https://badge.fury.io/rb/alfonsox.svg)](https://badge.fury.io/rb/alfonsox)\n[![Build Status](https://travis-ci.org/diegojromerolopez/alfonsox.svg?branch=master)](https://travis-ci.org/diegojromerolopez/alfonsox)\n[![Maintainability](https://api.codeclimate.com/v1/badges/053783a6bcd2404df5b1/maintainability)](https://codeclimate.com/github/diegojromerolopez/alfonsox/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/053783a6bcd2404df5b1/test_coverage)](https://codeclimate.com/github/diegojromerolopez/alfonsox/test_coverage)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"250\" src=\"https://github.com/diegojromerolopez/alfonsox/raw/master/resources/images/alfonsox.jpg\"\u003e\n\u003c/p\u003e\n\nA simple spellchecking tool to make easy the spellchecking of code files.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'alfonsox'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install alfonsox\n```\n\n## Setup\n\nMake sure you have [hunspell](http://hunspell.github.io/) installed\nin your system.\n\nNo installation of dictionaries is required as this package already contains\nLibreOffice dictionaries from\n[LibreOffice dictionaries repository](https://github.com/LibreOffice/dictionaries).\n\n## Usage\n\n### Terminal\n\n#### Define a configuration file\n\nCreate a YML file with the following structure to set up configuration of the spellchecking process:\n\n```yaml\n\n# Paths the files to ve spellchecked are\nPaths:\n  - 'lib/**.rb'\n  - 'test/**.rb'\n  - '... other paths that will be spellcheck'\n\n# Dictionaries, choose one or all of these options\n#Note the name of these subsections can be customized,\n# i.e. instead of MyEnglishDictionaryFromLocalPath you can write\n# LocalDictionary, for example.\nDictionaries:\n\n  # Use a hunspell dictionary included in your project\n  MyEnglishDictionaryFromLocalPath:\n    type: 'hunspell'\n    # Local hunspell dictionaries (.aff and .dic files)\n    path: 'my-local-path/dictionaries'\n    language: 'en_US'\n  \n  # Use a hunspell dictionary from this gem\n  MyEnglishDictionaryFromGem:\n      type: 'hunspell'\n      language: 'en_US'\n  \n  # If you use Rubymine, it is very useful to\n  # include your custom dictionary\n  MyRubymineDictionary:\n    type: 'rubymine'\n    # Optional, by default is '.idea/dictionary.xml'\n    path: '.idea/dictionary.xml'\n\n  # Include in this section a file path with a list of custom words or words\n  # Note the file must contain a word per line\n  # that do not appear in other dictionaries\n  WordListFileictionary:\n   type: 'word_list'\n   path: 'your/word/list/file/path'\n \n  # Include in this section a list of custom words or words\n  # that do not appear in other dictionaries\n  WordListDictionary:\n   type: 'word_list'\n   word_list:\n    - 'alfonso'\n    - 'babik'\n    - 'queryset'\n    - 'txt'\n```\n\ne.g.\n\n```yaml\nPaths:\n  - 'app/*/**.rb'\n  - 'lib/**.rb'\n  - 'test/**.rb'\nDictionaries:\n  EnglishDictionaryFromGem:\n      type: 'hunspell'\n      language: 'en_US'\n  RubymineDictionary:\n    type: 'rubymine'\n```\n\n#### Command line tool\n\nJust call **bundle exec alfonsox** and it should work fine, informing of any orthographic error in your code files.\n\nThe arguments must be the full paths of the file to be checked. If no arguments are passed to this tool, all files\nthat fulfill the paths defined in the configuration file will be checked.\n\n##### Output\n\n###### Successful Output\n\nNote the output is written in standard output (STDOUT).\n\n```bash\n$ bundle exec alfonsox file1 file2 #...\n✔ Code is spell-checked correctly\n```\n\nNote the exit code is 0\n\n```bash\n$ echo $?\n0\n```\n\n###### Non-successful Output\n\nNote the output is written in error standard output (STDERR).\n\n```bash\n$ bundle exec alfonsox file1 file2 #...\n/Users/diegoj/proyectos/blobik/app/models/post.rb:2 incorrektword\n✗ Errors in code spellchecking\n```\n\nNote the exit code is 1\n\n```bash\n$ echo $?\n1\n```\n\n### Overcommit integration\n\nEasiest way of use this project is to use [Overcommit](https://github.com/sds/overcommit).\nFor those of you that don't know it, it is a project whose aim is to provide developers\nwith tools to check code quality easily.\n\nIt has a\n[CodeSpellCheck](https://github.com/sds/overcommit/blob/master/lib/overcommit/hook/pre_commit/code_spell_check.rb)\npre-commit hook that accepts an Alfonso X configuration, by default is:\n\n```yml\nPaths:\n- 'app/*/**.rb'\n- 'lib/**.rb'\n- 'test/**.rb'\nDictionaries:\n  EnglishDictionaryFromGem:\n    type: 'hunspell'\n    language: 'en_US'\n  RubymineDictionary:\n    type: 'rubymine'\n```\n\nIf you want to overwrite it, create an **.alfonsox.yml** file in your\nhome directory and write your custom spell-check configuration there.\n\n### From code\n\n#### Load dictionaries\n\n```ruby\n# Load Hunspell dictionary from your system\n# Make sure you have installed your dictionaries \ndictionary = AlfonsoX::SpellChecker::Dictionary::Hunspell.new('en_US')\n\n# Or, alternatively you can load Hunspell dictionary from a local path\n# Make sure the following files exist:\n# - YOUR_PATH/dictionaries/en_US/en_US.aff \n# - YOUR_PATH/dictionaries/en_US/en_US.dic \ndictionary = AlfonsoX::SpellChecker::Dictionary::Hunspell.new(\n  'en_US', \"YOUR_PATH/dictionaries\"\n)\n```\n\n#### Spellcheck some files\n\n```ruby\ndictionaries = [\n  AlfonsoX::SpellChecker::Dictionary::Hunspell.new('en_US'),\n  AlfonsoX::SpellChecker::Dictionary::Hunspell.new('es_US')\n]\n# Create spellchecker\nspellchecker = AlfonsoX::SpellChecker::Main.new(\n  \"directory/with/files/**/*.rb\",\n  dictionaries\n)\n\n# Check the files\nincorrect_words = spellchecker.check\n\n# incorrect_words is a dict where\n# the keys area the path of each one of the files that have at least one wrong word\n# and the values are a list of incorrect words \n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/diegojromerolopez/alfonsox]([https://github.com/diegojromerolopez/alfonsox).\n\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nTo sum up, we only talk about this software and respect each other.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nAll dictionaries included in [resources/dictionaries/hunspell](resources/dictionaries/hunspell) are part of the LibreOffice hunspell dictionaries. Each one has its own license.\nVisit [LibreOffice dictionaries repository](https://github.com/LibreOffice/dictionaries) for more information.\n\nThe en_US dictionary included in the tests has MIT and BSD license and has been copied from\n[Titus Wormer's dictionary repository](https://github.com/wooorm/dictionaries/tree/master/dictionaries/en-US).\n\n[King Alfonso X image is Public Domain](https://commons.wikimedia.org/wiki/File:Retrato_de_Alfonso_X.jpg).\n\nRubyMine is a trademark of JetBrains. This project is no way endorsed, supported by or related with JetBrains.\n\n## Code of Conduct\n\nEveryone interacting in the Alfonso X project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/diegojromerolopez/alfonsox/blob/master/CODE_OF_CONDUCT.md).\n\n## Contributions\n\nI accept contribution and feature requests via PR (GitHub pull requests).\n\nCreate an issue or send me an email before making a PR\nif you are unsure about if your PR is going to be accepted.\n\nAny suggestion, issue or constructive criticism is also welcomed.\n\n## Why the name?\n\n[Alfonso X](https://en.wikipedia.org/wiki/Alfonso_X_of_Castile), called *The Wise*,\nwas a king that reigned [Castile](https://en.wikipedia.org/wiki/Crown_of_Castile) (in Spain) during medieval times.\nHe was a patron of the languages and pushed for the first orthography rules of Spanish.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegojromerolopez%2Falfonsox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiegojromerolopez%2Falfonsox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiegojromerolopez%2Falfonsox/lists"}