Module: LogStash::Environment
Constant Summary collapse
- LOGSTASH_CORE =
::File.(::File.join(::File.dirname(__FILE__), "..", ".."))
- LOGSTASH_ENV =
(ENV["LS_ENV"] || 'production').to_s.freeze
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
- #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
- #pattern_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
- #vendor_path(path) ⇒ 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
108 109 110 |
# File 'lib/logstash/environment.rb', line 108 def add_plugin_path(path) $LOAD_PATH << path end |
#development? ⇒ Boolean
27 28 29 |
# File 'lib/logstash/environment.rb', line 27 def development? env.downcase == "development" end |
#env ⇒ Object
19 20 21 |
# File 'lib/logstash/environment.rb', line 19 def env LOGSTASH_ENV end |
#find_jars(pattern) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/logstash/environment.rb', line 58 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
76 77 78 |
# File 'lib/logstash/environment.rb', line 76 def jruby? @jruby ||= !!(RUBY_PLATFORM == "java") end |
#load_jars!(pattern) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/logstash/environment.rb', line 51 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
96 97 98 99 100 101 102 |
# File 'lib/logstash/environment.rb', line 96 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
43 44 45 |
# File 'lib/logstash/environment.rb', line 43 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
47 48 49 |
# File 'lib/logstash/environment.rb', line 47 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
92 93 94 |
# File 'lib/logstash/environment.rb', line 92 def locales_path(path) return ::File.join(LOGSTASH_CORE, "locales", path) end |
#pattern_path(path) ⇒ Object
88 89 90 |
# File 'lib/logstash/environment.rb', line 88 def pattern_path(path) return ::File.join(LOGSTASH_HOME, "patterns", path) end |
#production? ⇒ Boolean
23 24 25 |
# File 'lib/logstash/environment.rb', line 23 def production? env.downcase == "production" end |
#require_jars!(files) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/logstash/environment.rb', line 65 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
72 73 74 |
# File 'lib/logstash/environment.rb', line 72 def ruby_bin ENV["USE_RUBY"] == "1" ? "ruby" : File.join("vendor", "jruby", "bin", "jruby") end |
#runtime_jars_root(dir_name, package) ⇒ Object
35 36 37 |
# File 'lib/logstash/environment.rb', line 35 def runtime_jars_root(dir_name, package) ::File.join(dir_name, package, "runtime-jars") end |
#test? ⇒ Boolean
31 32 33 |
# File 'lib/logstash/environment.rb', line 31 def test? env.downcase == "test" end |
#test_jars_root(dir_name, package) ⇒ Object
39 40 41 |
# File 'lib/logstash/environment.rb', line 39 def test_jars_root(dir_name, package) ::File.join(dir_name, package, "test-jars") end |
#vendor_path(path) ⇒ Object
84 85 86 |
# File 'lib/logstash/environment.rb', line 84 def vendor_path(path) return ::File.join(LOGSTASH_HOME, "vendor", path) end |
#windows? ⇒ Boolean
80 81 82 |
# File 'lib/logstash/environment.rb', line 80 def windows? ::Gem.win_platform? end |