Sha256: 7c1c2b434cd852fbca085e9dc5cf73da8e35291d2107c4431bd5c2705c2b5d48
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
#!/usr/bin/env ruby require 'ruby-clock' require "ruby-clock/dsl" RubyClock.detect_and_load_rails_app require 'rufus_monkeypatch' RubyClock.instance.listen_to_signals RubyClock.instance.prepare_rake RubyClock.instance.schedule.pause RubyClock.instance.add_rails_executor_to_around_actions check_syntax = false check_slug_uniqueness = false generate_dummy_crontab = false if ARGV[0] && '--' == ARGV[0][0..1] case ARGV[0] when '--environment-and-syntax-check' check_syntax = true when '--check-slug-uniqueness' check_slug_uniqueness = true when '--generate-dummy-crontab' generate_dummy_crontab = true else raise 'unknown option' end if ARGV[1] clockfiles = ARGV[1..] else clockfiles = ['Clockfile'] end else if ARGV[0] clockfiles = ARGV[0..] else clockfiles = ['Clockfile'] end end clockfiles.each do |clockfile| begin load clockfile rescue => clockfile_error if RubyClock.instance.on_error RubyClock.instance.on_error.call("An error has occured while parsing the clockfile #{clockfile}", clockfile_error) end raise end end RubyClock.instance.ensure_around_trigger_has_not_been_redefined RubyClock.instance.freeze_around_actions if check_syntax puts "✨ Environment & Syntax OK ✨" elsif check_slug_uniqueness slugs = {} RubyClock.instance.schedule.jobs.each do |j| if slugs[j.slug] slugs[j.slug] +=1 else slugs[j.slug] = 1 end end slugs_with_duplicates = [] slugs.each{|s,count| slugs_with_duplicates << s if count > 1 } if slugs_with_duplicates.any? puts "The following slugs have duplicates: #{slugs_with_duplicates}" exit(false) else puts "✨ All Slugs Are Unique ✨" end elsif generate_dummy_crontab text = '' RubyClock.instance.schedule.jobs.each do |j| if j.respond_to?(:cron_line) text << "#{j.cron_line.original} #{j.slug}\n" else text << "# every-#{j.frequency}-seconds #{j.slug}\n" end end puts text else RubyClock.instance.run_jobs end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-clock-2.0.1 | exe/clock |