lib/sidekiq_alive/helpers.rb in sidekiq_alive-2.3.1 vs lib/sidekiq_alive/helpers.rb in sidekiq_alive-2.4.0

- old
+ new

@@ -15,13 +15,39 @@ def sidekiq_5 current_sidekiq_version >= Gem::Version.new("5") && current_sidekiq_version < Gem::Version.new("6") end + def use_rack? + return @use_rack if defined?(@use_rack) + + require "rack" + @use_rack = current_rack_version < Gem::Version.new("3") + rescue LoadError + # currently this won't happen because rack is a dependency of sidekiq + @use_rack = false + end + + def use_rackup? + return @use_rackup if defined?(@use_rackup) + + require "rackup" + @use_rackup = current_rack_version >= Gem::Version.new("3") + rescue LoadError + if current_rack_version >= Gem::Version.new("3") + SidekiqAlive.logger.warn("rackup gem required with rack >= 3, defaulting to default server") + end + @use_rackup = false + end + private def current_sidekiq_version Gem.loaded_specs["sidekiq"].version + end + + def current_rack_version + Gem.loaded_specs["rack"].version end end end end