Hey devs βοΈ,
At stanza.dev we help developers to share coding concepts and learn from each others. π¨βπ» π©βπ»
We can't monitor each post by hand but as Stanza must be a place full of love π, we have developed a gem that removes the bad words from the website : polite_text
Remove swear words π€¬
include PoliteText
str = "This gem is a fucking big shit but let's try it"
PoliteText.be_polite!(str)
=> "This gem is a *** big *** but let's try it"
Check if string is polite π ββοΈ π ββοΈ
include PoliteText
str = "This gem is a fucking big shit but let's try it"
PoliteText.is_polite?(str)
=> false
Example for an Article model
# == Schema Information
#
# Table name: articles
#
# id :bigint not null, primary key
# text :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Article < ApplicationRecord
include PoliteText
# Callbacks
before_save :make_text_polite
# Methods
def make_text_polite
PoliteText.be_polite!(text)
end
end
Custom swear words list π
You can even pass your custom swear words list that is relevant for your app.
We have opensourced it and we hope that you will like it and contribute to improve it if you want π
π stanza.dev - Learn coding concepts faster
Access the gem repo here
Top comments (2)
Definitely book marking this.
Thank you very much ! :)
I've just made the config for custom swear words list even simpler now, feel free to contribute or to send me your feedbacks if I can improve some stuffs !