spambox 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spambox.rb +3 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d2e15076ec8f7a3dbcf9eb33d79ccb54da7de0a
|
4
|
+
data.tar.gz: 382e699bb82ffed011f74d48f9726c806b0f8b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cb1c44a1346a459e4284b7e55c4e9ec160afca1f1cc70caf5b2ff9d60b39383d66f9b184a1e4b8921d78743b452e2647e0538406e65c8c3dbcc2963869908ab
|
7
|
+
data.tar.gz: c2887e89d6c4adf169e2c48899978648da41b39cd3c592ba0208ce7d12e92e4411e86196103ca1b37d70e6206eda820d76f56b0f60b61633271098e49b8bc77c
|
data/lib/spambox.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
require "json"
|
2
|
-
require "open-uri"
|
3
2
|
require "sanitize"
|
4
3
|
|
5
4
|
class Spambox
|
6
|
-
FORMBOX_BLACKLIST_URL = "https://formbox.es/spam-keywords.json"
|
7
|
-
|
8
5
|
def initialize(object, options = { allow_html: false })
|
9
6
|
@object = object
|
10
7
|
@options = options
|
@@ -16,13 +13,6 @@ class Spambox
|
|
16
13
|
(count_occurences.to_f / string_length * 100).round
|
17
14
|
end
|
18
15
|
|
19
|
-
def update_blacklist
|
20
|
-
request = open(FORMBOX_BLACKLIST_URL)
|
21
|
-
|
22
|
-
Dir.mkdir("tmp") unless Dir.exist?("tmp")
|
23
|
-
File.open("tmp/spam_triggers.json", "w") { |f| f.write(request.read) }
|
24
|
-
end
|
25
|
-
|
26
16
|
private
|
27
17
|
|
28
18
|
def sanitized_string
|
@@ -62,17 +52,9 @@ class Spambox
|
|
62
52
|
end
|
63
53
|
|
64
54
|
def blacklist
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def spam_triggers
|
69
|
-
tmp_filename = "tmp/spam_triggers.json"
|
70
|
-
|
71
|
-
update_blacklist unless File.exist?(tmp_filename) && File.mtime(tmp_filename) > Time.now - (60 * 24 * 7)
|
72
|
-
|
73
|
-
File.read(tmp_filename)
|
74
|
-
rescue OpenURI::HTTPError, Errno::ECONNREFUSED
|
75
|
-
"{}"
|
55
|
+
path = File.expand_path(File.dirname(__FILE__))
|
56
|
+
file = File.read("#{path}/spam-keywords.json")
|
57
|
+
JSON.parse(file)
|
76
58
|
end
|
77
59
|
|
78
60
|
def flatten_hash_values(hash)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spambox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Jansen
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
-
description: Spambox uses
|
27
|
+
description: Spambox uses spam-keywords json file to check for spam.
|
28
28
|
email:
|
29
29
|
- joshuajansen88@gmail.com
|
30
30
|
executables: []
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
54
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.6.8
|
56
56
|
signing_key:
|
57
57
|
specification_version: 4
|
58
58
|
summary: Spambox is a gem that checks your objects for unsafe keywords and returns
|