polite_text 0.1.2 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 975a036dc2224dc4f4511c9bb9c10e2cebf2b5e9ff53c5a832dbc1a8321ab885
4
- data.tar.gz: b64fc451921d3d344ec50e1c406718abc36290a55ade06181390adf877b8e6db
3
+ metadata.gz: 574591328155e7985751a85bfdb2610376f9c976b4d0a589c1d735ec9bfb9816
4
+ data.tar.gz: b0f61d51a49c6882dbd666a495b20b2e0f12a5a2ae716c20350b2739e3910afe
5
5
  SHA512:
6
- metadata.gz: 90cf022213168d75beec317b0e4b2e2eb50e62d3036a27c29c135efed9b2068d15c91a92de09f125dd3bcec61755e0e228d45c2a1d4ac5fd55de56835dd75ca4
7
- data.tar.gz: bc51b523c94300e81e2243c839bdf8e54a570f25e6b159d11c58994ac2d304adf10c346161d3024af721fb90e56dce542abee6a46410c5e56cb261e3e3de72bd
6
+ metadata.gz: d678889edb60886cfb83f6a186335e6371238cd45669eec435f1cf0f52f981cd074cfa04cbb8181243314edb68c371b0e9ca45805d9184719a1b8f1518839064
7
+ data.tar.gz: 705cbb3d6f397a4292aa858fc734d3dea33d7fa4c6989d4d848b3968948b2f9b57ca367c076a00968eafb9d931b58ab823b24e3c0b2421594ee4c5f13ceeba2f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polite_text (0.1.1)
4
+ polite_text (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -25,6 +25,9 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
+ ### Swear words 🔞
29
+ PoliteText 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).
30
+
28
31
  ### Remove swear words 🤬
29
32
  ```
30
33
  include PoliteText
@@ -47,16 +50,43 @@ PoliteText.is_polite?(str)
47
50
  => false
48
51
  ```
49
52
 
53
+ ### Example for an Article model
54
+
55
+ ```
56
+ # == Schema Information
57
+ #
58
+ # Table name: articles
59
+ #
60
+ # id :bigint not null, primary key
61
+ # text :string default(""), not null
62
+ # created_at :datetime not null
63
+ # updated_at :datetime not null
64
+ #
65
+
66
+ class Article < ApplicationRecord
67
+ include Politetext
68
+
69
+ # Callbacks
70
+ before_save :make_text_polite
71
+
72
+ # Methods
73
+ def make_text_polite
74
+ PoliteText.be_polite!(text)
75
+ end
76
+ end
77
+ ```
78
+
50
79
  ## Contributing
51
80
 
52
81
  Bug reports and pull requests are welcome on GitHub at https://github.com/OpenGems/polite_text.
53
82
  This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
54
83
 
55
84
  ### Todo 💪
56
- - [ ] Allow users to add their own swear words list
57
- - [ ] Allow users to remove swear words from the default list
58
- - [ ] Manage locales with I18N
59
- - [ ] Add swear words from multiple languages
85
+ - [ ] Allow users to add their own swear words list.
86
+ - [ ] Allow users to remove swear words from the default list.
87
+ - [ ] Manage locales with I18N.
88
+ - [ ] Add swear words from multiple languages.
89
+ - [ ] Improve swear words list and keeping it short.
60
90
 
61
91
  ## License
62
92
 
@@ -4,18 +4,24 @@ swear_words:
4
4
  - fuck
5
5
  - fuckyou
6
6
  - fucker
7
+ - fuckers
7
8
  - fucking
8
9
  - dick head
9
10
  - dick
10
11
  - dickhole
11
12
  - cock
12
13
  - asshole
14
+ - assholes
13
15
  - son of a bitch
14
16
  - bitch
17
+ - bitches
15
18
  - biatch
16
19
  - whore
20
+ - whores
17
21
  - bastard
22
+ - bastards
18
23
  - wanker
24
+ - wankers
19
25
  - shit
20
26
  - piss
21
27
  - pussy
@@ -3,8 +3,6 @@ require 'polite_text/text_scanner'
3
3
  require 'polite_text/text_cleaner'
4
4
 
5
5
  module PoliteText
6
- class Error < StandardError; end
7
-
8
6
  class << self
9
7
  def be_polite!(text)
10
8
  PoliteText::TextCleaner.new(text).clean!
@@ -16,7 +16,7 @@ module PoliteText
16
16
 
17
17
  private
18
18
 
19
- # Todo: Implement dynamic locale with I18N
19
+ # TODO: Implement dynamic locale with I18N
20
20
  def locale
21
21
  @locale ||= 'en'
22
22
  end
@@ -3,19 +3,13 @@ module PoliteText
3
3
  attr_reader :text
4
4
 
5
5
  def initialize(text)
6
- @text = text.to_s
6
+ raise ArgumentError.new('The text can not be nil') if text.nil?
7
7
 
8
- validate_text!
8
+ @text = text.to_s
9
9
  end
10
10
 
11
11
  def clean!
12
12
  text.gsub!(swear_words, '***')
13
13
  end
14
-
15
- private
16
-
17
- def validate_text!
18
- raise ArgumentError.new('The text can not be empty') if @text.empty?
19
- end
20
14
  end
21
15
  end
@@ -3,19 +3,13 @@ module PoliteText
3
3
  attr_reader :text
4
4
 
5
5
  def initialize(text)
6
- @text = text.to_s
6
+ raise ArgumentError.new('The text can not be nil') if text.nil?
7
7
 
8
- validate_text!
8
+ @text = text.to_s
9
9
  end
10
10
 
11
11
  def match_swear_word?
12
12
  !@text.match?(swear_words)
13
13
  end
14
-
15
- private
16
-
17
- def validate_text!
18
- raise ArgumentError.new('The text can not be empty') if @text.empty?
19
- end
20
14
  end
21
15
  end
@@ -1,3 +1,3 @@
1
1
  module PoliteText
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.21"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  end
23
23
  spec.bindir = 'exe'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polite_text
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - DumasOlivier