-
Notifications
You must be signed in to change notification settings - Fork 37
/
Rakefile
executable file
·118 lines (101 loc) · 3.13 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env rake
RAILS_ROOT = File.expand_path('../', __FILE__)
require_relative 'config/application'
AcpcPokerGuiClient::Application.load_tasks
namespace :in do
desc 'Change to production environment'
task :prod do
Rails.env = 'production'
end
desc 'Change to test environment'
task :test do
Rails.env = 'test'
end
desc 'Change to development environment'
task :dev do
Rails.env = 'development'
end
end
namespace :compile do
desc 'Compile acpc_dealer'
task :dealer do
sh %{ acpc_dealer compile }
end
# Assets
desc 'Precompiles assets. Only do in production.'
task :assets => ['in:prod', 'assets:precompile']
end
namespace :install do
# Project hierarchy
VENDOR_DIRECTORY = "#{RAILS_ROOT}/vendor"
directory VENDOR_DIRECTORY
DB_DATA_DIRECTORY = "#{RAILS_ROOT}/db/data"
directory DB_DATA_DIRECTORY
# MongoDB
MONGODB_DIRECTORY = "#{VENDOR_DIRECTORY}/mongoDB"
file MONGODB_DIRECTORY do
puts(
"Please download a MongoDB version compatible with your system " +
"from http://www.mongodb.org/downloads, unpack the compressed file to " +
"`<project root>/vendor`, and rename the resulting directory to `mongoDB`."
)
raise
end
MONGOD_EXECUTABLE = "#{MONGODB_DIRECTORY}/bin/mongod"
file MONGOD_EXECUTABLE => MONGODB_DIRECTORY
desc 'Complete MongoDB setup'
task :mongodb => [DB_DATA_DIRECTORY, MONGOD_EXECUTABLE]
# Redis
REDIS_DIRECTORY = File.join(VENDOR_DIRECTORY, 'redis-stable')
file REDIS_DIRECTORY => VENDOR_DIRECTORY do
Dir.chdir(VENDOR_DIRECTORY) do
sh %{ wget http://download.redis.io/redis-stable.tar.gz }
sh %{ tar xvzf redis-stable.tar.gz }
sh %{ rm -f xvzf redis-stable.tar.gz }
end
end
REDIS_EXECUTABLE = File.join(REDIS_DIRECTORY, 'src', 'redis-server')
file REDIS_EXECUTABLE => REDIS_DIRECTORY do
Dir.chdir(File.join(REDIS_DIRECTORY, 'src')) do
sh %{ make }
end
end
desc 'Complete Redis setup'
task :redis => [REDIS_EXECUTABLE]
# Gems
namespace :gems do
desc 'Installs gem dependencies for development'
task :dev do
sh %{ bundle install }
end
desc 'Installs gem dependencies for production'
task :prod do
sh %{ bundle install --without development test }
end
end
# Full installation
desc 'Installs all dependencies for development'
task :dev => ['in:dev', :mongodb, :redis, 'gems:dev', 'compile:dealer']
desc 'Installs all dependencies for production, other than production web server'
task :prod => ['in:prod', :mongodb, :redis, 'gems:prod', 'compile:dealer', 'compile:assets']
end
namespace :update do
desc 'Update gems and assets in production'
task :prod => ['in:prod', 'install:gems:prod', 'install:assets']
desc 'Update gems and assets in development'
task :prod => ['in:dev', 'install:gems:dev']
end
desc 'Delete incompatible (deprecated) User instances'
task :delete_deprecated_users do
require_relative 'lib/database_config'
User.all.map do |u|
begin
unless u.respond_to?(:hotkeys) && u.hotkeys.all? { |key| key.is_a?(Hotkey) }
puts "Deleted #{u.name}"
u.delete
end
rescue TypeError
u.delete
end
end
end