No commit activity in last 3 years
No release in over 3 years
Generator for oneshot rake task
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 10.0
~> 3.0

Runtime

>= 3.0.0
 Project Readme

Build Status Gem Version

OneshotTaskGenerator

Simple rake task generator for oneshot tasks.

$ bin/rails generate oneshot FooBar
      create  lib/tasks/oneshot/20180205_foo_bar.rake

Then, skeleton file for oneshot rake task will be generated.

# Skeleton for this file was generated by `bin/rails generate oneshot FooBar`
# For copy and paste: `bin/rake oneshot:foo_bar_20180205`
namespace :oneshot do
  desc ''
  task foo_bar_20180205: :environment do
  end
end

Installation

Add this line to your application's Gemfile:

gem 'oneshot_task_generator', group: :development

And then execute:

$ bundle

Customization

Task Body

# config/initializers/oneshot_task_generator.rb
OneshotGenerator.configure do |config|
  config.body = <<-BODY
ActiveRecord::Base.transaction do
  # Write transactional code here
end
  BODY
end
# Skeleton for this file was generated by `bin/rails generate oneshot FooBar`
# For copy and paste: `bin/rake oneshot:foo_bar_20180208`
namespace :oneshot do
  desc ''
  task foo_bar_20180208: :environment do
    ActiveRecord::Base.transaction do
      # Write transactional code here
    end
  end
end

Arguments

# config/initializers/oneshot_task_generator.rb
OneshotGenerator.configure do |config|
  config.arguments = ['task', 'args']
end
# Skeleton for this file was generated by `bin/rails generate oneshot FooBar`
# For copy and paste: `bin/rake oneshot:foo_bar_20180208`
namespace :oneshot do
  desc ''
  task foo_bar_20180208: :environment do |task, args|
  end
end

Directory

# config/initializers/oneshot_task_generator.rb
OneshotGenerator.configure do |config|
  config.directory = 'your/favorite/directory' # Default: lib/tasks/oneshot
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/s-osa/oneshot_task_generator.