Class: MaintenanceTasks::TaskGenerator Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Generator used for creating maintenance tasks in the host application.

Instance Method Summary collapse

Instance Method Details

#create_task_fileObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates the Task file.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/generators/maintenance_tasks/task_generator.rb', line 25

def create_task_file
  if options[:csv] && options[:no_collection]
    raise "Multiple Task type options provided. Please use either " \
      "--csv or --no-collection."
  end
  template_file = File.join(
    "app/tasks/#{tasks_module_file_path}",
    class_path,
    "#{file_name}_task.rb",
  )
  if options[:csv]
    template("csv_task.rb", template_file)
  elsif no_collection?
    template("no_collection_task.rb", template_file)
  else
    template("task.rb", template_file)
  end
end

#create_test_fileObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates the Task test file, according to the app’s test framework. A spec file is created if the app uses RSpec. Otherwise, an ActiveSupport::TestCase test is created.



47
48
49
50
51
52
53
54
55
# File 'lib/generators/maintenance_tasks/task_generator.rb', line 47

def create_test_file
  return unless test_framework

  if test_framework == :rspec
    create_task_spec_file
  else
    create_task_test_file
  end
end