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