Sha256: 2183e249d7b2cf9d27b10039b97b77d81ba0afadd3fd204a58ac191755d446d8
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
#!/usr/bin/env ruby begin require './config/environment.rb' puts "Detected rails app has been loaded." rescue LoadError end require 'ruby-clock' require 'method_source' class Rufus::Scheduler::Job def identifier @identifier ||= begin name || handler.source.split("\n").reject(&:empty?).grep_v(/#.*/)[-2].strip rescue begin source_location.join('-') rescue 'error-calculating-job-identifier' end end end end RubyClock.instance.listen_to_signals RubyClock.instance.prepare_rake RubyClock.instance.schedule.pause ## Add methods to top-level namespace def schedule RubyClock.instance.schedule end def on_error(&on_error_block) RubyClock.instance.on_error = on_error_block def schedule.on_error(job, error) RubyClock.instance.on_error.call(job, error) end end def cron(...) RubyClock.instance.schedule.cron(...) end def every(...) RubyClock.instance.schedule.every(...) end def shell(string) RubyClock.instance.shell(string) end ##################################### load ARGV[0] || 'Clockfile' if defined?(::Rails) schedule.instance_eval do @old_around_trigger = method :around_trigger def around_trigger(job) ::Rails.application.reloader.wrap do @old_around_trigger.call(job){ yield } end end end end RubyClock.instance.run_jobs
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-clock-2.0.0.beta2 | exe/clock |