spam_email 0.0.5 → 0.0.6

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.
@@ -1,36 +0,0 @@
1
- require 'ruby-progressbar'
2
-
3
- module SpamEmail
4
- class ListCompiler
5
- # this method takes the list from data/provider_list.txt, resolves all mx
6
- # entries and builds the blacklist-array
7
- def self.compile_list
8
- progress_bar = ProgressBar.create(total: File.size("data/provider_list.txt"), format: '%e |%b>>%i| %p%% %t')
9
-
10
- resolving = []
11
- file = File.open("data/provider_list.txt")
12
- file.each_line do |domain|
13
- domain.strip!
14
- domain.downcase!
15
- next if domain.empty?
16
-
17
- mx = []
18
- Resolv::DNS.open do |dns|
19
- mx.concat dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
20
- end
21
-
22
- if mx.any?
23
- resolving << domain
24
- end
25
- progress_bar.progress = file.tell
26
- end
27
-
28
- hash_elements = resolving.collect { |v| "\"#{v}\" => true" }
29
-
30
- dest_file = File.open("lib/spam_email/blacklist.rb", "w")
31
- dest_file.write("module SpamEmail\n BLACKLIST = { ")
32
- dest_file.write(hash_elements.join(",\n "))
33
- dest_file.write(" }\nend")
34
- end
35
- end
36
- end