Class: DeployPin::TaskGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DeployPin::TaskGenerator
- Defined in:
- lib/generators/deploy_pin/task/task_generator.rb
Instance Method Summary collapse
- #create_task_file ⇒ Object
-
#initialize(*args) ⇒ TaskGenerator
constructor
A new instance of TaskGenerator.
- #validate ⇒ Object
Constructor Details
#initialize(*args) ⇒ TaskGenerator
Returns a new instance of TaskGenerator.
16 17 18 19 20 |
# File 'lib/generators/deploy_pin/task/task_generator.rb', line 16 def initialize(*args) super validate end |
Instance Method Details
#create_task_file ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/deploy_pin/task/task_generator.rb', line 22 def create_task_file template_file = if [:parallel] 'parallel_task.rb.erb' else 'task.rb.erb' end @author = [:author] || ENV['USER'] @group = [:group] @recurring = [:recurring] @identifier = @recurring ? [: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 |
#validate ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/generators/deploy_pin/task/task_generator.rb', line 37 def validate raise Thor::Error, set_color('Missing required option: --group', :red) if [:group].blank? return if DeployPin.groups.include?([:group]) raise Thor::Error, set_color("Group '#{[:group]}' is not defined in DeployPin.groups", :red) end |