8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/jun/cli/commands/generate/migration.rb', line 8
def process(*args)
migration_name = args.first
template_filepath = File.expand_path("../../generator_templates/migration.rb.erb", __dir__)
template = Tilt::ERBTemplate.new(template_filepath)
template_locals = { migration_name: migration_name }
filename = "#{Time.now.to_i}_#{migration_name}.rb"
filepath = Jun.root.join("db/migrate/#{filename}")
file_body = template.render(nil, template_locals)
filepath.dirname.mkpath
File.open(filepath, "w") { |f| f.write(file_body) }
puts "created #{filename}"
end
|