Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.
force_file_collision?(destination, src, dst, file_options = {}, &block)private
Ask the user interactively whether to force collision.
# File railties/lib/rails_generator/commands.rb, line 100
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 `#{diff_cmd} "#{dst}" "#{temp.path}"`
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 Related methods
- Instance methods
- class_collisions
- dependency
- invoke!
- readme
- Protected methods
-
current_migration_number -
existing_migrations -
gsub_file -
migration_directory -
migration_exists? -
next_migration_number -
next_migration_string - Private methods
-
diff_cmd -
force_file_collision? -
render_template_part -
template_part_mark