diff --git a/README.md b/README.md index 73a8de1..a6f109a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ -# periodicity -Job scheduler for Rails +Periodicity — Job scheduler for Rails +————————————————————————————— + +Under Construction diff --git a/bin/periodicity b/bin/periodicity index fd7fe14..1bf1b67 100644 --- a/bin/periodicity +++ b/bin/periodicity @@ -1,2 +1,7 @@ #!/usr/bin/env ruby +require 'rails' +require File.expand_path("config/environment.rb") +::Rails.application.eager_load! + +logger.info "Running in #{RUBY_DESCRIPTION}" diff --git a/lib/periodicity/extensions/active_job.rb b/lib/periodicity/extensions/active_job.rb new file mode 100644 index 0000000..2c01783 --- /dev/null +++ b/lib/periodicity/extensions/active_job.rb @@ -0,0 +1,8 @@ +module Periodicity + module Extensions + class ActiveJob + def perform_every(period, *args) + end + end + end +end diff --git a/lib/periodicity/rails.rb b/lib/periodicity/rails.rb new file mode 100644 index 0000000..f4f79ce --- /dev/null +++ b/lib/periodicity/rails.rb @@ -0,0 +1,13 @@ +module Periodicity + def self.hook_rails! + ActiveSupport.on_load(:active_job) do + extend Sidekiq::Extensions::ActiveJob + end + end + + class Rails < ::Rails::Engine + initializer 'periodicity' do + Periodicity.hook_rails! + end + end if defined?(::Rails) +end