Sha256: ecbc1f4034b91195399ed81364eeac735988f9b12366f4e01e22c755c857bf61

Contents?: true

Size: 1.23 KB

Versions: 9

Compression:

Stored size: 1.23 KB

Contents

require 'fileutils'

Rails::Generator::Commands::Create.class_eval do
  def copy_files(base, source)
    logger.copy "Copying '#{source}' to '#{base}'"
    FileUtils.cp_r File.join(source_root, 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
    puts "Another migration is already named #{migration_file_name}: #{existing_migrations(migration_file_name).first}... skipping" and return if migration_exists?(migration_file_name)
    template(relative_source, "#{relative_destination}/#{next_migration_string}_#{migration_file_name}.rb", template_options)
  end
end

Rails::Generator::Commands::Destroy.class_eval do
  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 copy_files(base, source)
    logger.copy "Copying '#{source}' to '#{base}'"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
liquid_cms-0.2.0.12 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.11 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.10 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.9 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.8 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.7 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.6 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.5 generators/liquid_cms/lib/insert_commands.rb
liquid_cms-0.2.0.4 generators/liquid_cms/lib/insert_commands.rb