force_file_collision?(destination, src, dst, file_options = {}, &block)
private
Ask the user interactively whether to force collision.
Show source
def force_file_collision?(destination, src, dst, file_options = {}, &block)
$stdout.print "overwrite #{destination}? (enter \"h\" for help) [Ynaqdh] "
case $stdin.gets.chomp
when /\Ad\z/i
Tempfile.open(File.basename(destination), File.dirname(dst)) do |temp|
temp.write render_file(src, file_options, &block)
temp.rewind
$stdout.puts `
end
puts "retrying"
raise 'retry diff'
when /\Aa\z/i
$stdout.puts "forcing #{spec.name}"
options[:collision] = :force
when /\Aq\z/i
$stdout.puts "aborting #{spec.name}"
raise SystemExit
when /\An\z/i then :skip
when /\Ay\z/i then :force
else
$stdout.puts "Y - yes, overwrite\nn - no, do not overwrite\na - all, overwrite this and all others\nq - quit, abort\nd - diff, show the differences between the old and the new\nh - help, show this help\n"
raise 'retry'
end
rescue
retry
end