Module: LogStash::Environment
- Extended by:
- Environment
- Included in:
- Environment
- Defined in:
- lib/logstash/environment.rb,
lib/logstash/environment.rb
Constant Summary collapse
- LOGSTASH_HOME =
Stud::Temporary.directory("logstash-home")
- LOGSTASH_CORE =
::File.(::File.join(::File.dirname(__FILE__), "..", ".."))
- LOGSTASH_ENV =
(ENV["LS_ENV"] || 'production').to_s.freeze
- LINUX_OS_RE =
/linux/
- WINDOW_OS_RE =
/mswin|msys|mingw|cygwin|bccwin|wince|emc/
- MACOS_OS_RE =
/darwin/
Instance Method Summary collapse
-
#add_plugin_path(path) ⇒ Object
add path for bare/ungemified plugins lookups.
- #development? ⇒ Boolean
- #env ⇒ Object
- #find_jars(pattern) ⇒ Object
- #jruby? ⇒ Boolean
- #linux? ⇒ Boolean
- #load_jars!(pattern) ⇒ Object
- #load_locale! ⇒ Object
- #load_runtime_jars!(dir_name = "vendor", package = "jar-dependencies") ⇒ Object
- #load_test_jars!(dir_name = "vendor", package = "jar-dependencies") ⇒ Object
- #locales_path(path) ⇒ Object
- #production? ⇒ Boolean
- #require_jars!(files) ⇒ Object
- #ruby_bin ⇒ Object
- #runtime_jars_root(dir_name, package) ⇒ Object
- #test? ⇒ Boolean
- #test_jars_root(dir_name, package) ⇒ Object
- #windows? ⇒ Boolean
Instance Method Details
#add_plugin_path(path) ⇒ Object
add path for bare/ungemified plugins lookups. the path must be the base path that will include the dir structure ‘logstash/TYPE/NAME.rb’ where TYPE is ‘inputs’ ‘filters’, ‘outputs’ or ‘codecs’ and NAME is the name of the plugin
155 156 157 |
# File 'lib/logstash/environment.rb', line 155 def add_plugin_path(path) $LOAD_PATH << path end |
#development? ⇒ Boolean
78 79 80 |
# File 'lib/logstash/environment.rb', line 78 def development? env.downcase == "development" end |
#env ⇒ Object
70 71 72 |
# File 'lib/logstash/environment.rb', line 70 def env LOGSTASH_ENV end |
#find_jars(pattern) ⇒ Object
109 110 111 112 113 114 |
# File 'lib/logstash/environment.rb', line 109 def find_jars(pattern) require 'java' jar_files = Dir.glob(pattern) raise(LogStash::EnvironmentError, I18n.t("logstash.environment.missing-jars", :pattern => pattern)) if jar_files.empty? jar_files end |
#jruby? ⇒ Boolean
127 128 129 |
# File 'lib/logstash/environment.rb', line 127 def jruby? @jruby ||= !!(RUBY_PLATFORM == "java") end |
#linux? ⇒ Boolean
135 136 137 |
# File 'lib/logstash/environment.rb', line 135 def linux? RbConfig::CONFIG['host_os'] =~ LINUX_OS_RE end |
#load_jars!(pattern) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/logstash/environment.rb', line 102 def load_jars!(pattern) raise(LogStash::EnvironmentError, I18n.t("logstash.environment.jruby-required")) unless LogStash::Environment.jruby? jar_files = find_jars(pattern) require_jars! jar_files end |
#load_locale! ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/logstash/environment.rb', line 143 def load_locale! require "i18n" I18n.enforce_available_locales = true I18n.load_path << LogStash::Environment.locales_path("en.yml") I18n.reload! fail "No locale? This is a bug." if I18n.available_locales.empty? end |
#load_runtime_jars!(dir_name = "vendor", package = "jar-dependencies") ⇒ Object
94 95 96 |
# File 'lib/logstash/environment.rb', line 94 def load_runtime_jars!(dir_name="vendor", package="jar-dependencies") load_jars!(::File.join(runtime_jars_root(dir_name, package), "*.jar")) end |
#load_test_jars!(dir_name = "vendor", package = "jar-dependencies") ⇒ Object
98 99 100 |
# File 'lib/logstash/environment.rb', line 98 def load_test_jars!(dir_name="vendor", package="jar-dependencies") load_jars!(::File.join(test_jars_root(dir_name, package), "*.jar")) end |
#locales_path(path) ⇒ Object
139 140 141 |
# File 'lib/logstash/environment.rb', line 139 def locales_path(path) return ::File.join(LOGSTASH_CORE, "locales", path) end |
#production? ⇒ Boolean
74 75 76 |
# File 'lib/logstash/environment.rb', line 74 def production? env.downcase == "production" end |
#require_jars!(files) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/logstash/environment.rb', line 116 def require_jars!(files) files.each do |jar_file| loaded = require jar_file puts("Loaded #{jar_file}") if $DEBUG && loaded end end |
#ruby_bin ⇒ Object
123 124 125 |
# File 'lib/logstash/environment.rb', line 123 def ruby_bin ENV["USE_RUBY"] == "1" ? "ruby" : File.join("vendor", "jruby", "bin", "jruby") end |
#runtime_jars_root(dir_name, package) ⇒ Object
86 87 88 |
# File 'lib/logstash/environment.rb', line 86 def runtime_jars_root(dir_name, package) ::File.join(dir_name, package, "runtime-jars") end |
#test? ⇒ Boolean
82 83 84 |
# File 'lib/logstash/environment.rb', line 82 def test? env.downcase == "test" end |
#test_jars_root(dir_name, package) ⇒ Object
90 91 92 |
# File 'lib/logstash/environment.rb', line 90 def test_jars_root(dir_name, package) ::File.join(dir_name, package, "test-jars") end |
#windows? ⇒ Boolean
131 132 133 |
# File 'lib/logstash/environment.rb', line 131 def windows? RbConfig::CONFIG['host_os'] =~ WINDOW_OS_RE end |