Skip to content

Commit

Permalink
add support to require rails
Browse files Browse the repository at this point in the history
  • Loading branch information
Nando Sousa committed Aug 2, 2018
1 parent 2e37ff9 commit b18e14a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/upperkut/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ def initialize(args = ARGV)
end

def start
if file = @options[:file]
require file
if target_required = @options[:require]
if File.directory?(target_required)
require 'rails'
if ::Rails::VERSION::MAJOR == 4
require File.expand_path("#{@options[:require]}/config/application.rb")
::Rails::Application.initializer "upperkut.eager_load" do
::Rails.application.config.eager_load = true
end

require File.expand_path("#{@options[:require]}/config/environment.rb")
else
require 'sidekiq/rails'
require File.expand_path("#{@options[:require]}/config/environment.rb")
end
else
require file
end
end

if log_level = @options[:log_level]
Expand Down Expand Up @@ -71,7 +86,7 @@ def parse_options(args)
@options[:worker] = arg
end
o.on('-r', '--require FILE', 'Indicate a file to be required') do |arg|
@options[:file] = arg
@options[:require] = arg
end
o.on('-c', '--concurrency INT', 'Numbers of threads to spawn') do |arg|
@options[:concurrency] = Integer(arg)
Expand Down

0 comments on commit b18e14a

Please sign in to comment.