Sha256: 143e44bfd35e54c0649b0bc4433a5d901a6f3ad09aa3c3aeaf6b051a547a9811
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
require 'fileutils' Rails::Generator::Commands::Create.class_eval do def delete(file) logger.delete "Deleting '#{file}'" FileUtils.rm_f file end def copy_files(base, source, template_path = nil) logger.copy "Copying '#{source}' to '#{base}'" FileUtils.cp_r File.join(source_root, template_path || '', base, source), File.join(destination_root, base) end # override the migration template method so that we can continue the generation and not fail if the migration already exists def migration_template(relative_source, relative_destination, template_options = {}) migration_directory relative_destination migration_file_name = template_options[:migration_file_name] || file_name # override the default behavior of halting the generator if the file is found and instead provide a warning for the migration and continue if migration_exists?(migration_file_name) puts "Another migration is already named #{migration_file_name}: #{existing_migrations(migration_file_name).first}... skipping" return end template(relative_source, "#{relative_destination}/#{next_migration_string}_#{migration_file_name}.rb", template_options) end end Rails::Generator::Commands::Destroy.class_eval do def delete(file) logger.delete "Deleting '#{file}'" FileUtils.rm_f file end def copy_files(base, source) logger.copy "Removing '#{source}' from '#{base}'" FileUtils.rm_rf File.join(destination_root, base, source) end end Rails::Generator::Commands::List.class_eval do def delete(file) logger.delete "Deleting '#{file}'" end def copy_files(base, source) logger.copy "Copying '#{source}' to '#{base}'" end end
Version data entries
3 entries across 3 versions & 1 rubygems