{"id":15288800,"url":"https://github.com/opengems/polite_text","last_synced_at":"2025-04-13T08:11:11.681Z","repository":{"id":56888455,"uuid":"310021012","full_name":"OpenGems/polite_text","owner":"OpenGems","description":"Make your users' input polite 👀","archived":false,"fork":false,"pushed_at":"2020-11-07T20:46:12.000Z","size":57,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-24T17:39:34.838Z","etag":null,"topics":["input","ruby","ruby-gem","ruby-on-rails","user-interface","user-management"],"latest_commit_sha":null,"homepage":"","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/OpenGems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-04T14:07:28.000Z","updated_at":"2022-01-04T00:10:54.000Z","dependencies_parsed_at":"2022-08-20T16:50:24.395Z","dependency_job_id":null,"html_url":"https://github.com/OpenGems/polite_text","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Fpolite_text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Fpolite_text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Fpolite_text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenGems%2Fpolite_text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenGems","download_url":"https://codeload.github.com/OpenGems/polite_text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681491,"owners_count":21144700,"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":["input","ruby","ruby-gem","ruby-on-rails","user-interface","user-management"],"created_at":"2024-09-30T15:53:14.953Z","updated_at":"2025-04-13T08:11:11.658Z","avatar_url":"https://github.com/OpenGems.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PoliteText\n[![Gem Version](https://badge.fury.io/rb/polite_text.svg)](https://badge.fury.io/rb/polite_text)\n[![security](https://hakiri.io/github/OpenGems/polite_text/master.svg)](https://hakiri.io/github/OpenGems/polite_text/master)\n![Gem](https://img.shields.io/gem/dt/polite_text)\n\nPoliteText is making your users' input polite 👀\n\n👉 Replace the swear words or execute callbacks if the input is not polite based on a default swear words list or your own.\n\n## Installation 👨‍💻 👩‍💻\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'polite_text'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install polite_text\n\n## Usage with the default swear words list 🌝\n\n### Swear words  🔞\nPoliteText has a default list of forbidden words, this list includes the most common swear words used on the web. You can acces the list of swear words [here](https://github.com/OpenGems/polite_text/blob/master/lib/locales/en.yml).\n\n### Remove swear words 🤬\n```\nstr = \"This gem is a fucking big shit but let's try it\"\n\nPoliteText.be_polite!(str)\n=\u003e \"This gem is a *** big *** but let's try it\"\n```\n\n### Check if string is polite 🙅‍♂️ 🙅‍♀️\n```\nstr = \"This gem is a fucking big shit but let's try it\"\n\nPoliteText.is_polite?(str)\n=\u003e false\n```\n\n### Example for an Article model\n\n```\n# == Schema Information\n#\n# Table name: articles\n#\n#  id         :bigint           not null, primary key\n#  text      :string           default(\"\"), not null\n#  created_at :datetime         not null\n#  updated_at :datetime         not null\n#\n\nclass Article \u003c ApplicationRecord\n  # Callbacks\n  before_save :make_text_polite\n\n  # Methods\n  def make_text_polite\n    PoliteText.be_polite!(text)\n  end\nend\n```\n\n## Usage with custom swear words list 🌞\n\n### Custom swear words list  🔞\nCreate a custom list in a **YAML** file following this format :\n```\n# custom_swear_words.yml\n\nswear_words:\n  - gem\n  - big\n  - but\n```\n\nPlace it where you want in your app, we recommend here : `./lib/polite_text/my_custom_swear_words.yml`\n\n## Confirguration\n\n📄 Create an initializer named `polite_text.rb`\n\n✌️ Add the path to your custom swear words list like this :\n\n```\n# ./config/initializers/polite_text.rb\n\nPoliteText.configure do |config|\n  config.custom_swear_words_path = \"#{__dir__}/../../lib/polite_text/custom_swear_words.yml\"\nend\n```\n\nPoliteText is now configured with your custom list ✨💫\n```\nstr = \"This gem is a fucking big shit but let's try it\"\n\nPoliteText.be_polite!(str)\n=\u003e \"This *** is a fucking *** shit *** let's try it\" \n\nPoliteText.is_polite?(str)\n=\u003e false\n```\n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/OpenGems/polite_text.\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.\n\n### Todo 💪\n- [ ] Manage locales with I18N for default swear words lists by country.\n- [ ] Add default swear words lists from multiple languages.\n- [ ] Improve the default swear words list and keeping it short.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopengems%2Fpolite_text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopengems%2Fpolite_text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopengems%2Fpolite_text/lists"}