naughty_words 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d84f228f93cc6af5a7794aa4c42a56a45d1d8dd575982a687672cefa9991341
4
- data.tar.gz: d2a64141e31b2a293fceef6fc5c58e8fe0a150db75c7d3be7227da5415948427
3
+ metadata.gz: d57b97899577e770df8be076a260356960598772f8b35d14b70f0c1fcd346ddf
4
+ data.tar.gz: '093ef5e005fb5c73516ce20d78ec205b37b814232ac62ebb6cf3b2aac40380b0'
5
5
  SHA512:
6
- metadata.gz: eecf8555f6d2cfff3951c386caf6bdd428a0abaa9742ff552b773b33df938116553ffe859cbd2f365a332f428b6ce1be4743304512e948a668a474ce3d1ba1a1
7
- data.tar.gz: 9817e7590058a2691b606acaecab6bff48a3a7abdd97ae3d914a96d53bf69c3fc4e2a2d943d7704902b6f7428ffb599c5fa771b732d3903413395628287c8cfe
6
+ metadata.gz: 684f809efaac39ce2261e50f5d63886ab50e310a6192295c22745d3f3082551d2acb5d9e8bd9822947c78a02bfee54a730387dc5fc2a572c9a5a372036b746cc
7
+ data.tar.gz: c032f4abd47b5b1990540dbaa914234912ea80d2ae2980f5d6238f661f463072ce654e3600526bc489c4f180b7426368f0f8208881b0850db7ee21b06cc2e038
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- naughty_words (0.1.2)
4
+ naughty_words (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -58,4 +58,4 @@ DEPENDENCIES
58
58
  rubocop (~> 1.21)
59
59
 
60
60
  BUNDLED WITH
61
- 2.2.30
61
+ 2.3.24
data/README.md CHANGED
@@ -45,13 +45,15 @@ The `filter` method takes a `string:` argument and an optional `replacement:` ar
45
45
  NaughtyWords.filter(string: "hello asshole")
46
46
  => "hello *******"
47
47
 
48
+ # you can filter out consecutive naughty words
49
+ NaughtyWords.filter(string: "shitshitshityeah")
50
+ => "************yeah"
51
+
48
52
  # you can use in your own filter character by passing it in as an argument ("*" is by default)
49
53
  NaughtyWords.filter(string: "hello asshole", replacement: "!")
50
54
  => "hello !!!!!!!"
51
55
  ```
52
56
 
53
- Note: Current, this is comically easy to circumvent. String like "shitshitshit" will only filter out the first match, returning "*****shitshit". A fix is enroute.
54
-
55
57
  ### Validating in Rails example
56
58
  We can use a custom validator in our User model to make sure a user cannot sign up with a username containing profanities in tandem with our normal `validates` methods.
57
59
 
@@ -16,7 +16,6 @@ module NaughtyWords
16
16
  end
17
17
 
18
18
  def filter(string:, replacement:)
19
- # TODO: Fix filtering full words ending with 'ing' and repeated words such as 'fuckfuckfuck'
20
19
  deny_list_array.each do |line|
21
20
  word = line
22
21
  string.gsub!(word, replacement * word.length)
@@ -42,13 +41,15 @@ module NaughtyWords
42
41
  private
43
42
 
44
43
  def deny_list_array
45
- file = File.open(File.join(File.dirname(File.expand_path(__FILE__)), "config/deny_list.txt"))
44
+ file = File.open(File.join(File.dirname(File.expand_path(__FILE__)),
45
+ "config/deny_list.txt"))
46
46
 
47
47
  @deny_list_array ||= File.readlines(file, chomp: true)
48
48
  end
49
49
 
50
50
  def allow_list_array
51
- file = File.open(File.join(File.dirname(File.expand_path(__FILE__)), "config/allow_list.txt"))
51
+ file = File.open(File.join(File.dirname(File.expand_path(__FILE__)),
52
+ "config/allow_list.txt"))
52
53
 
53
54
  @allow_list_array ||= File.readlines(file, chomp: true)
54
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NaughtyWords
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naughty_words
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Arnold
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-03 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem will detect simple profanity and can substitute them with a
14
14
  specified replacement.