-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
35 lines (31 loc) · 832 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class String
def shuffle
split('').shuffle.join
end
def shuffle!
replace shuffle
end
end
task :default do
system "echo Rake tasks"
system "rake --tasks"
end
desc 'Generate an obfuscated email address to stop spammers'
task :email do
puts 'Please type in an email address then press ENTER/RETURN'
address = STDIN.gets.chomp.downcase
key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
key.shuffle!
puts "\nInstallation:\nUpdate src/data/contacts.yml with the following pairs.\n\nemail-key: #{key}"
scrambled = ''
shift = address.length
(0..shift-1).each do |i|
if key.index(address[i]) == nil
scrambled += address[i]
else
chr = (key.index(address[i]) + shift) % key.length
scrambled += key[chr]
end
end
puts "email-encoded: #{scrambled}\n"
end