forked from engaging-computing/rSENSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
93 lines (79 loc) · 2.43 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
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
# Temporary fix for last_comment deprecation
# Probably has to do with rspec or rake version
module LastCommentFix
def last_comment
last_description
end
end
Rake::Application.send :include, LastCommentFix
Rsense::Application.load_tasks
namespace :ckeditor do
desc 'Create nondigest versions of some ckeditor assets (e.g. moono skin png)'
task :create_nondigest_assets do
fingerprint = /\-[0-9a-f]{32}\./
Dir['public/assets/ckeditor/contents-*.css', 'public/assets/ckeditor/skins/moono/*.png', 'public/assets/vis/*.png'].each do |file|
next unless file =~ fingerprint
nondigest = file.sub fingerprint, '.'
FileUtils.cp file, nondigest, verbose: true
end
end
end
# auto run ckeditor:create_nondigest_assets after assets:precompile
Rake::Task['assets:precompile'].enhance do
Rake::Task['ckeditor:create_nondigest_assets'].invoke
end
namespace :db do
task :preprep do
if ENV['DB']
puts "Switching db config to #{ENV['DB']}"
system("cp config/database.#{ENV['DB']}.yml config/database.yml")
else
puts 'No DB variable set'
end
end
end
namespace :test do
task :pg do
system('DB=postgres rake db:preprep')
system('rake test')
system('DB=default rake db:preprep')
end
end
task :dump do
system('rake db:data:dump')
system('mv db/data.yml public/media')
system('tar czvf /tmp/dump.tar.gz public/media')
system('mv /tmp/dump.tar.gz public')
end
task :load do
system("mkdir /tmp/#{$PROCESS_ID}")
system("mv public/media /tmp/#{$PROCESS_ID}")
system('tar xzvf public/dump.tar.gz')
system('mv public/media/data.yml db')
system('rake db:data:load')
end
if %w(development test).include? Rails.env
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.formatters = ['fuubar']
end
task(:coffeelint).clear
task :coffeelint do
conf = Rails.root.join('.coffeelint')
success = true
['app', 'lib'].each do |dd|
success &&= Coffeelint.run_test_suite(dd, config_file: conf.to_s)
end
fail 'Goats! (you probably failed coffeelint)' unless success
end
task(:default).clear
task :default do
Rake::Task['coffeelint'].invoke
Rake::Task['rubocop'].invoke
Rake::Task['test'].invoke
end
end