forked from manyfold3d/manyfold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
47 lines (42 loc) · 1.4 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
# 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_relative "config/application"
Rails.application.load_tasks
unless ENV["RACK_ENV"] === "production"
require "rubocop/rake_task"
RuboCop::RakeTask.new
end
locales = [
:de,
:es,
:fr,
:pl
]
namespace :translation do
namespace :clobber_and_sync do
task all: locales
locales.each do |locale|
task locale => :environment do
puts "-- Clobbering #{locale}.yml files"
system "find config/locales -name #{locale}.yml | xargs rm -v"
puts "-- Downloading from translation.io"
system "rake translation:sync"
system "find config/locales -name translation.*.yml | grep -v #{locale} | xargs rm"
puts "-- Normalizing files"
system "i18n-tasks normalize -p"
puts "-- Done!"
end
end
end
end
namespace :db do
task chown: :environment do
# Only do this for SQLite
if ActiveRecord::Base.connection.is_a? ActiveRecord::ConnectionAdapters::SQLite3Adapter
# Find all the database files
files = Dir.glob(ActiveRecord::Base.connection.instance_variable_get(:@config)[:database] + "*")
# Change ownership - this will fail safe if the env vars aren't set
FileUtils.chown(ENV.fetch("PUID", nil), ENV.fetch("PGID", nil), files, verbose: true)
end
end
end