From 74d2fe2b0429901cd658823219ec4a17f17d043f Mon Sep 17 00:00:00 2001 From: Colin Surprenant Date: Tue, 1 Apr 2014 20:23:45 -0400 Subject: [PATCH] refactor valid_caller? into autorun? --- lib/logstash/runner.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/logstash/runner.rb b/lib/logstash/runner.rb index 260508faa..f279a4eee 100644 --- a/lib/logstash/runner.rb +++ b/lib/logstash/runner.rb @@ -233,8 +233,10 @@ class LogStash::Runner return args end # def run - def self.valid_caller? - caller.none?{|entry| entry =~ /rspec/} + # @return true if this file is the main file being run and not via rspec + def self.autorun? + # caller is the current execution stack + $0 == __FILE__ && caller.none?{|entry| entry =~ /rspec/} end private @@ -244,6 +246,4 @@ class LogStash::Runner end end # class LogStash::Runner -if $0 == __FILE__ && LogStash::Runner.valid_caller? - LogStash::Runner.new.main(ARGV) -end +LogStash::Runner.new.main(ARGV) if LogStash::Runner.autorun?