filters_spam 0.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.
- data/lib/filters_spam.rb +8 -3
- data/readme.md +13 -2
- metadata +4 -4
data/lib/filters_spam.rb
CHANGED
|
@@ -9,9 +9,14 @@ def filters_spam(options = {})
|
|
|
9
9
|
}.update(options)
|
|
10
10
|
|
|
11
11
|
self.module_eval do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if Rails.version < '3.0.0'
|
|
13
|
+
named_scope :ham, :conditions => {:spam => false}
|
|
14
|
+
named_scope :spam, :conditions => {:spam => true}
|
|
15
|
+
else
|
|
16
|
+
scope :ham, :conditions => {:spam => false}
|
|
17
|
+
scope :spam, :conditions => {:spam => true}
|
|
18
|
+
end
|
|
19
|
+
before_validation(:on => :create) { |spammable| spammable.send(:calculate_spam_score) }
|
|
15
20
|
|
|
16
21
|
cattr_accessor :spam_words
|
|
17
22
|
self.spam_words = %w{
|
data/readme.md
CHANGED
|
@@ -12,12 +12,23 @@ that allows models to attach to it to provide spam filtering functionality.
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Once you have the plugin installed, you
|
|
15
|
+
Once you have the plugin installed, you need to add a column to the table you will be
|
|
16
|
+
using this for. For example, if you have a table called ``comments``:
|
|
17
|
+
|
|
18
|
+
script/generate migration add_spam_to_comments spam:boolean
|
|
19
|
+
rake db:migrate
|
|
20
|
+
|
|
21
|
+
The same thing in Rails 3:
|
|
22
|
+
|
|
23
|
+
rails generate migration add_spam_to_comments spam:boolean
|
|
24
|
+
rake db:migrate
|
|
25
|
+
|
|
26
|
+
Now, you can use it by calling the function in your model like so:
|
|
16
27
|
|
|
17
28
|
filters_spam
|
|
18
29
|
|
|
19
30
|
If you want to change the default fields that are used by ``filters_spam``
|
|
20
|
-
then you can pass them in to the method as options.
|
|
31
|
+
then you can pass them in to the method as options. All options are optional.
|
|
21
32
|
|
|
22
33
|
All of the possible options are outlined below with the default values for each:
|
|
23
34
|
|
metadata
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: filters_spam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 15
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: "0.
|
|
8
|
+
- 2
|
|
9
|
+
version: "0.2"
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Philip Arndt
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-08-
|
|
18
|
+
date: 2010-08-30 00:00:00 +12:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|