title | description | type | created_at |
---|---|---|---|
Usage |
how_to_guide |
2021-12-21 |
The first step to adding a onesie is to create a new template task. This can be achieved with either the Rails generator or the Rake task
Usage:
rails generate onesie:task NAME PRIORITY [options]
Options:
[--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated applications)
Runtime options:
-f, [--force] # Overwrite files that already exist
-p, [--pretend], [--no-pretend] # Run but do not make any changes
-q, [--quiet], [--no-quiet] # Suppress status output
-s, [--skip], [--no-skip] # Skip files that already exist
bundle exec rails generate onesie:task MyTask # creates a normal priority task
bundle exec rails generate onesie:task MyTask high # creates a high priority task
rake onesie:new[name,priority] # Generates a new Onesie Task
bundle exec rake onesie:new['MyTask'] # creates a normal priority task
bundle exec rake onesie:new['MyTask','high'] # creates a high priority task
The generator will create a onesie template file. The task must include the
#run
method. Add your code to the new task file.
For details about the Task class and the class macros, see the Task document.
There are three Rake tasks to assist with running onesies.
rake onesie:run[filename] # Manually run a specific Onesie Tasks
rake onesie:run_all # Run all unprocessed Onesie Tasks
rake onesie:run_tasks[priority_level] # Run all tasks by priority level
!!! Note
Manual tasks must be ran individually with the onesie:run
rake task.
be rake onesie:run['20220105140152_my_task'] # Run 20220105140152_my_task.rb
be rake onesie:run_tasks['high'] # Run all high priority tasks
be rake onesie:run_tasks # Run all tasks without priority
During the development process, it may be useful to rerun a Onesie Task.
Use the onesie:rerun
rake task to:
- Rerun the most recent Task
- Specify a Task filename to rerun a specific Task
bundle exec rake onesie:rerun # Reruns the last task
bundle exec rake onesie:rerun['20220105140152_my_task'] # Reruns MyTask
rake onesies:describe # Prints a list of available onesies to run