From 6ca6189c74477a782eb248582ece0b7933024993 Mon Sep 17 00:00:00 2001 From: Pere Urbon-Bayes Date: Thu, 15 Jan 2015 09:59:50 +0100 Subject: [PATCH] add a way to handle env checks using method names cleanup the method missing magic for enviroment test ammend space add a comment to the variable place Fixes #2356 --- lib/logstash/environment.rb | 12 ++++++++++++ lib/logstash/pluginmanager/install.rb | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/logstash/environment.rb b/lib/logstash/environment.rb index 0497ef60d..859eb71bc 100644 --- a/lib/logstash/environment.rb +++ b/lib/logstash/environment.rb @@ -39,6 +39,18 @@ module LogStash LOGSTASH_ENV end + def production? + env.downcase == "production" + end + + def development? + env.downcase == "development" + end + + def test? + env.downcase == "test" + end + # set GEM_PATH for logstash runtime # GEM_PATH should include the logstash gems, the plugin gems and the bootstrap gems. # the bootstrap gems are required specificly for bundler which is a runtime dependency diff --git a/lib/logstash/pluginmanager/install.rb b/lib/logstash/pluginmanager/install.rb index cb66bb4e2..f287324c0 100644 --- a/lib/logstash/pluginmanager/install.rb +++ b/lib/logstash/pluginmanager/install.rb @@ -56,7 +56,9 @@ class LogStash::PluginManager::Install < Clamp::Command FileDependencies::Gem.hook options = {} options[:document] = [] - if LogStash::Environment.env == 'test' + if LogStash::Environment.test? + # More info on what do this options means + # https://github.com/rubygems/rubygems/blob/master/lib/rubygems/dependency_installer.rb#L56 options[:dev_shallow] = true options[:development] = true end