Class: MaintenanceScriptGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/maintenance_script/maintenance_script_generator.rb

Overview

Generates a maintenance script file from a template.

This generator creates a new maintenance script file in the directory specified by ‘Dekiru::DataMigration.configuration.maintenance_script_directory`. The generated file is named with the current date (in YYYYMMDD format) followed by the provided name.

Example usage:

rails generate maintenance_script MyScript

Instance Method Summary collapse

Instance Method Details

#copy_maintenance_script_fileObject



16
17
18
19
20
21
22
# File 'lib/generators/maintenance_script/maintenance_script_generator.rb', line 16

def copy_maintenance_script_file
  @filename_date = filename_date
  @class_name = "#{name.classify}#{@filename_date}"

  template "maintenance_script.rb.erb",
           "#{Dekiru::DataMigration.configuration.maintenance_script_directory}/#{@filename_date}_#{file_name}.rb"
end