instance method force_file_collision?

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18 Private

Available in: v2.2.3 v2.3.18

Signature

force_file_collision?(destination, src, dst, file_options = {}, &block)

Ask the user interactively whether to force collision.

Parameters

destination req
src req
dst req
file_options opt = {}
block block
Source
# File railties/lib/rails_generator/commands.rb, line 99
          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 <<-HELP
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
HELP
                raise 'retry'
            end
          rescue
            retry
          end

Defined in railties/lib/rails_generator/commands.rb line 99 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generator::Commands::Base

Type at least 2 characters to search.

↑↓ navigate · open · esc close