lib/wayfarer/cli/base.rb in wayfarer-0.4.3 vs lib/wayfarer/cli/base.rb in wayfarer-0.4.4

- old
+ new

@@ -14,14 +14,32 @@ def mock_redis Wayfarer.config.redis.factory = ->(_) { MockRedis.new } end def load_environment - Wayfarer::CLI::Runner.loader.setup + load_rails || load_plain end def free_agent_pool Wayfarer::Networking::Pool.instance.free + end + + def load_rails + begin + require "rails/app_loader" + rescue LoadError + return + end + + return unless Rails::AppLoader.find_executable + + require File.expand_path("config/application", Dir.pwd) + require File.expand_path("config/boot", Dir.pwd) + require File.expand_path("config/environment", Dir.pwd) + end + + def load_plain + Wayfarer::CLI::Runner.loader.setup end end end end