Class: DeployPin::TaskGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/deploy_pin/task/task_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_task_fileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/deploy_pin/task/task_generator.rb', line 15

def create_task_file
  template_file = if options[:parallel]
                    'parallel_task.rb.erb'
                  else
                    'task.rb.erb'
                  end

  @author = options[:author] || ENV['USER']
  @group = options[:group]
  @recurring = options[:recurring]
  @identifier = @recurring ? options[:identifier] : Time.now.strftime('%Y%m%d%H%M%S')
  filename = @recurring ? "r_#{@identifier}_#{title}.rb" : "#{@identifier}_#{title}.rb"
  template template_file, "#{DeployPin.tasks_path}/#{filename}"
end