naughty_words 1.0.1 → 1.0.2

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: 174cee498fcc6e2135e97252d0521a9052b1eeb77a1e1c54272475211d0519a4
4
- data.tar.gz: c281e2aaa26b5a7c20eae4c1cc428da7df7ba5e2f4737429e3ccff110a03016d
3
+ metadata.gz: 5cf88a0fd1e82f3e4cecb2d6d768c15c71995cdf8897f728bd1a2d8436f52e7f
4
+ data.tar.gz: 8cfd6713a8c3a81c44994036df6208c8b92cdfc4c26a00d33e291b3ee302d376
5
5
  SHA512:
6
- metadata.gz: f6fa83d7a9fa6b852562c7e351a16df173af4233c07c928691338d966f1582ffb687868f1b621ac98bbf52fd62c2c8b1fb19371e1a718a13192740a0de14fcf0
7
- data.tar.gz: ed588ea954e299291b8d938fb6452af974352449df759621e41e21559a1d0e0d94a0a2f99d5161455e305d58210301864750e598cf7a2a818ce76d021170f7cd
6
+ metadata.gz: a5677af2c030e24321dd55d1d3931b18d57b0d5d85f2b349807fadf9520f1337de836b5e54ee514f012f65dbb388f096a16e73b8544c1300166bd1aeedfb7431
7
+ data.tar.gz: 6b2f7959635c02f2422e318acca920890756cd1bd4c1ed4dab3073813bb3ae8f57672d6e9b7da00eca3087b4f613342078f17bbb829a3b85ec0666b8b9d33990
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.0.2] - 2026-06-30
4
+
5
+ ### Fixed
6
+ - `filter` now respects file and DB allow lists, not just runtime overrides — a word in the allow list is no longer masked by `filter` even if it appears verbatim in a deny list
7
+ - `show_list(include_metadata: true)` no longer raises `NoMethodError` when ActiveRecord is not loaded
8
+ - Built-in word lists are now always loaded from file on first access; toggling `use_built_in_lists` off and back on no longer returns stale empty lists
9
+ - Migration template now uses `ActiveRecord::Migration.current_version` instead of a hardcoded `[7.0]`, fixing Rails 6/6.1 compatibility
10
+
3
11
  ## [0.1.0] - 2022-05-18
4
12
 
5
13
  - Initial release
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class CreateNaughtyWordsLists < ActiveRecord::Migration[7.0]
3
+ class CreateNaughtyWordsLists < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
4
4
  def change
5
5
  create_table :naughty_words_lists do |t|
6
6
  t.string :word, null: false
@@ -29,7 +29,9 @@ module NaughtyWords
29
29
  denied_words = Config.deny_overrides.dup
30
30
  denied_words += deny_list_from_files if Config.use_built_in_lists
31
31
  denied_words += deny_list_from_db
32
- denied_words -= Config.allow_overrides # Remove any allowed overrides
32
+ denied_words -= Config.allow_overrides
33
+ denied_words -= allow_list_from_files if Config.use_built_in_lists
34
+ denied_words -= allow_list_from_db
33
35
  denied_words = denied_words.sort_by(&:length).reverse
34
36
 
35
37
  denied_words.each do |word|
@@ -43,7 +45,7 @@ module NaughtyWords
43
45
  def show_list(list:, include_metadata: false)
44
46
  validate_list!(list)
45
47
 
46
- if include_metadata && defined?(WordList)
48
+ if include_metadata && defined?(ActiveRecord::Base) && defined?(WordList)
47
49
  WordList.where(list_type: list)
48
50
  else
49
51
  words = []
@@ -96,7 +98,6 @@ module NaughtyWords
96
98
  end
97
99
 
98
100
  def load_list(path)
99
- return [] unless Config.use_built_in_lists
100
101
  File.readlines(path, chomp: true).reject(&:empty?)
101
102
  rescue Errno::ENOENT
102
103
  raise Error, "List file not found: #{path}"
@@ -115,15 +116,6 @@ module NaughtyWords
115
116
  str.downcase
116
117
  end
117
118
 
118
- def word_pattern(word)
119
- escaped = Regexp.escape(word)
120
- if Config.word_boundaries
121
- /(?:^|[^a-zA-Z0-9])#{escaped}(?:$|[^a-zA-Z0-9])/i
122
- else
123
- /#{escaped}/i
124
- end
125
- end
126
-
127
119
  def word_match?(string, word)
128
120
  pattern = Config.word_boundaries ?
129
121
  /(?:^|[^a-zA-Z0-9])#{Regexp.escape(word)}(?:$|[^a-zA-Z0-9])/i :
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NaughtyWords
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Arnold
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-18 00:00:00.000000000 Z
11
+ date: 2026-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake