refactor valid_caller? into autorun?

This commit is contained in:
Colin Surprenant 2014-04-01 20:23:45 -04:00
parent 323f42fdfd
commit 74d2fe2b04

View file

@ -233,8 +233,10 @@ class LogStash::Runner
return args return args
end # def run end # def run
def self.valid_caller? # @return true if this file is the main file being run and not via rspec
caller.none?{|entry| entry =~ /rspec/} def self.autorun?
# caller is the current execution stack
$0 == __FILE__ && caller.none?{|entry| entry =~ /rspec/}
end end
private private
@ -244,6 +246,4 @@ class LogStash::Runner
end end
end # class LogStash::Runner end # class LogStash::Runner
if $0 == __FILE__ && LogStash::Runner.valid_caller? LogStash::Runner.new.main(ARGV) if LogStash::Runner.autorun?
LogStash::Runner.new.main(ARGV)
end