2018-02-15 18:20:48 -05: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-23 16:55:17 -04:00
|
|
|
puts
|
2018-02-15 18:20:48 -05:00
|
|
|
puts "Please specify a settings yml file"
|
|
|
|
puts "Example: rake site_settings:import < settings.yml"
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
2018-03-23 16:55:17 -04:00
|
|
|
puts
|
2018-02-15 18:20:48 -05:00
|
|
|
puts "starting import..."
|
2018-03-23 16:55:17 -04:00
|
|
|
puts
|
2018-02-15 18:20:48 -05:00
|
|
|
|
2018-03-23 16:55:17 -04:00
|
|
|
log, counts = SiteSettingsTask.import(yml)
|
2018-02-15 18:20:48 -05:00
|
|
|
|
2018-03-23 16:55:17 -04:00
|
|
|
puts log
|
|
|
|
|
|
|
|
puts
|
2018-02-15 18:20:48 -05:00
|
|
|
puts "Results:"
|
|
|
|
puts " Updated: #{counts[:updated]}"
|
|
|
|
puts " Not Found: #{counts[:not_found]}"
|
|
|
|
puts " Errors: #{counts[:errors]}"
|
2018-10-11 03:57:57 -04:00
|
|
|
|
|
|
|
if counts[:not_found] + counts[:errors] > 0
|
|
|
|
exit 1
|
|
|
|
end
|
2018-02-15 18:20:48 -05:00
|
|
|
end
|