Project

one_offs

0.01
No release in over 3 years
Low commit activity in last 3 years
Track and manage your one off scripts with rake
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

< 5, >= 1.15.6
 Project Readme

One Offs

Track and manage your one off scripts, in rails applications.

Can be used to move stuff out from your rails migrations that dont belong there. For example data migrations can be moved from schema and into one-offs.

Installation

Add this line to your application's Gemfile:

gem 'one_offs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install one_offs

Usage

After installing the gem, In your Rakefile (/Rakefile) add the following line

require 'one_offs/tasks'

And setup a tracker table (creates migration).

rake one_offs:generate_tracker_table

OR using SQL query if you want to avoid a migration (Useful if you need to setup one off tasks before db:migrate).

rake one_offs:create_tracker_table_using_sql

Add scripts to lib/one_offs/

  • File name should be <number>_class_name_inside_file.rb (Rails convention for file name to class name with the order number before that)

    Example:

    File: 1_hello_world.rb
    Contents:
        class HelloWorld
            def self.process
            puts("You may write your code in this process method").
        end
    end
    

To run pending one_off scripts.

rake one_offs:run

To baseline one_offs seed them into to the tracker table.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request