Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new todo task directory.

  • Loading branch information...
commit e55b0b98343d2b077a70d741baf1e7603820d1b4 1 parent e279d1e
@berlin-ab authored
Showing with 68 additions and 0 deletions.
  1. +68 −0 tasks/to_do.rake
View
68 tasks/to_do.rake
@@ -0,0 +1,68 @@
+require 'to_do'
+
+namespace :todo do
+ class CreateStatuses < ActiveRecord::Migration
+ def self.up
+ create_table :to_dos do |t|
+ t.string :name
+ t.string :hook
+ t.string :timestamp
+ end
+ end
+
+ def self.down
+ drop_table :to_dos
+ end
+ end
+
+ task :setup => [:environment] do
+ ToDo::Configuration.setup
+ end
+
+ task :install => [:setup] do
+ CreateStatuses.up
+ end
+
+ task :uninstall => [:setup] do
+ CreateStatuses.down
+ ToDo.configuration.remove
+ end
+
+ task :before => ["todo:setup"] do
+ jobs = ToDo::Status.all_before
+ exit_todo_with_no_jobs if jobs.blank?
+
+ jobs.each do |job|
+ puts "Running #{job.name}..."
+ job.run
+ puts "Done!"
+ end
+ end
+
+ def exit_todo_with_no_jobs
+ puts "No jobs to run."
+ exit(0)
+ end
+
+ task :after => ["todo:setup"] do
+ jobs = ToDo::Status.all_after
+ exit_todo_with_no_jobs if jobs.blank?
+
+ jobs.each do |job|
+ puts "Running #{job.name}..."
+ job.run
+ puts "Done!"
+ end
+ end
+
+ task :create, :hook, :name, :needs => ["todo:setup"] do |task, args|
+ hook = args[:hook]
+ name = args[:name]
+
+ raise "invalid hook. please provide 'before' or 'after'." unless ['before', 'after'].include?(hook)
+ raise "invalid name. please provide a name for your new job." if name.blank?
+
+ job = ToDo::Job.create(hook, name)
+ puts "Created #{job.name} in #{job.file_path}"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.