-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
82 lines (71 loc) · 1.53 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# frozen_string_literal: true
# Fixes em-mysql2 error when running rake.
require 'bundler'
Bundler.setup
# Add the root to the load path.
$LOAD_PATH << File.dirname(__FILE__)
# Require items we need for rake tasks
require 'sinatra/activerecord/rake'
require 'rake/testtask'
# Silence warnings
ENV['RUBYOPT'] = "-W0 #{ENV['RUBYOPT']}"
# Setup test rake task, and make it default
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
task :console do
ENV['RACK_ENV'] ||= 'test'
exec 'tux'
end
namespace :db do
task :load_config do
require 'shorty_app'
end
task :cleanup do
bad = [
".*by2.io.*",
".*\\.ru/.*",
".*sex.*",
".*onion.*",
".*dating.*",
".*\\.top.*",
".*amazon.*",
".*\\.online.*",
".*dates.*",
".*bxss.me.*",
".*fuck.*",
".*gethost.*",
".*print.*",
".*import.*",
".*\\.su/.*",
".*inexistent.*",
".*insigit.*",
".*submit.*",
".*\\.la/.*",
".*\\.claims.*",
".*\\.br/.*",
".*atsnx\\.com.*",
".*\\.id/.*",
".*response\\.write.*"
]
ShortenedUrl.all.each do |u|
bad.each do |b|
if /#{b}/ =~ u.url
puts u.url
u.destroy
end;nil
end
end;nil
end
end
namespace :docker do
desc 'build docker image'
task :build do
# TODO: Stream output
puts 'Building em-shorty docker image'
puts `docker build -f Dockerfile -t em-shorty .`
end
end
task default: :test