diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-26 01:12:58 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-26 01:12:58 +0000 |
commit | 647130d7ff43c91c5be14e27a9bcd1ad4a61985e (patch) | |
tree | efbffb80efc603c6a2b8f86b4cc46e6e2533a9d8 /railties/lib/rails_generator/commands.rb | |
parent | d94af9a61f059a16306486b363640c71ee4a2810 (diff) | |
download | rails-647130d7ff43c91c5be14e27a9bcd1ad4a61985e.tar.gz rails-647130d7ff43c91c5be14e27a9bcd1ad4a61985e.tar.bz2 rails-647130d7ff43c91c5be14e27a9bcd1ad4a61985e.zip |
Added collision option to template generation in generators (closes #3329) [anna@wota.jp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3663 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib/rails_generator/commands.rb')
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index dd72436fc8..3e02e3cc41 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -163,11 +163,13 @@ module Rails # Copy a file from source to destination with collision checking. # - # The file_options hash accepts :chmod and :shebang options. + # The file_options hash accepts :chmod and :shebang and :collision options. # :chmod sets the permissions of the destination file: # file 'config/empty.log', 'log/test.log', :chmod => 0664 # :shebang sets the #!/usr/bin/ruby line for scripts # file 'bin/generate.rb', 'script/generate', :chmod => 0755, :shebang => '/usr/bin/env ruby' + # :collision sets the collision option only for the destination file: + # file 'settings/server.yml', 'config/server.yml', :collision => :skip # # Collisions are handled by checking whether the destination file # exists and either skipping the file, forcing overwrite, or asking @@ -188,7 +190,7 @@ module Rails # Make a choice whether to overwrite the file. :force and # :skip already have their mind made up, but give :ask a shot. - choice = case options[:collision].to_sym #|| :ask + choice = case (file_options[:collision] || options[:collision]).to_sym #|| :ask when :ask then force_file_collision?(relative_destination) when :force then :force when :skip then :skip |