2018-02-16 07:20:48 +08:00
|
|
|
require 'yaml'
|
|
|
|
|
|
|
|
desc "Exports site settings"
|
|
|
|
task "site_settings:export" => :environment do
|
|
|
|
h = SiteSettingsTask.export_to_hash
|
|
|
|
puts h.to_yaml
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Imports site settings"
|
|
|
|
task "site_settings:import" => :environment do
|
|
|
|
yml = (STDIN.tty?) ? '' : STDIN.read
|
|
|
|
if yml == ''
|
2018-03-24 04:55:17 +08:00
|
|
|
puts
|
2018-02-16 07:20:48 +08:00
|
|
|
puts "Please specify a settings yml file"
|
|
|
|
puts "Example: rake site_settings:import < settings.yml"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2018-03-24 04:55:17 +08:00
|
|
|
puts
|
2018-02-16 07:20:48 +08:00
|
|
|
puts "starting import..."
|
2018-03-24 04:55:17 +08:00
|
|
|
puts
|
2018-02-16 07:20:48 +08:00
|
|
|
|
2018-03-24 04:55:17 +08:00
|
|
|
log, counts = SiteSettingsTask.import(yml)
|
2018-02-16 07:20:48 +08:00
|
|
|
|
2018-03-24 04:55:17 +08:00
|
|
|
puts log
|
|
|
|
|
|
|
|
puts
|
2018-02-16 07:20:48 +08:00
|
|
|
puts "Results:"
|
|
|
|
puts " Updated: #{counts[:updated]}"
|
|
|
|
puts " Not Found: #{counts[:not_found]}"
|
|
|
|
puts " Errors: #{counts[:errors]}"
|
|
|
|
end
|