Permalink
Browse files

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
  • Loading branch information...
dhh committed Feb 26, 2006
1 parent d94af9a commit 647130d7ff43c91c5be14e27a9bcd1ad4a61985e
Showing with 9 additions and 2 deletions.
  1. +5 −0 railties/CHANGELOG
  2. +4 −2 railties/lib/rails_generator/commands.rb
View
@@ -1,5 +1,10 @@
*SVN*
+* Added collision option to template generation in generators #3329 [anna@wota.jp]. Examples:
+
+ m.template "stuff.config" , "config/stuff.config" , :collision => :skip
+ m.template "auto-stamping", "config/generator.log", :collision => :force
+
* Added more information to script/plugin's doings to ease debugging #3755 [Rick Olson]
* Changed the default configuration for lighttpd to use tmp/sockets instead of log/ for the FastCGI sockets [DHH]
@@ -163,11 +163,13 @@ def class_collisions(*class_names)
# 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 @@ def file(relative_source, relative_destination, file_options = {}, &block)
# 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

0 comments on commit 647130d

Please sign in to comment.