Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created November 10, 2010 20:59
Show Gist options
  • Save mhorbul/671507 to your computer and use it in GitHub Desktop.
Save mhorbul/671507 to your computer and use it in GitHub Desktop.
resque-schedule yaml config template generator
require 'yaml'; Dir.glob("app/jobs/*").map {|j| File.basename(j, ".rb")}.reduce({}) { |r,k| r[k] = {"cron" => "* * * * *", "custom_job_class" => k.gsub(/(_(.)|^(.))/) {|m| m.gsub(/_/,"").upcase}, "queue" => "resque", "description" => k.gsub(/(_(.)|^(.))/) {|m| "#{m.gsub(/_/," ").upcase}"} }; r }.to_yaml
__END__
---
awesome_worker_one:
cron: "* * * * *"
custom_job_class: AwesomeWorkerOne
queue: resque
description: Awesome Worker One
awesome_worker_two:
cron: "* * * * *"
custom_job_class: AwesomeWorkerTwo
queue: resque
description: Awesome Worker Two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment