Module: Honeybadger::Config::Env Private
- Defined in:
- lib/honeybadger/config/env.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- CONFIG_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\AHONEYBADGER_(.+)\Z/.freeze
- CONFIG_MAPPING =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Hash[DEFAULTS.keys.map {|k| [k.to_s.upcase.gsub(KEY_REPLACEMENT, '_'), k] }].freeze
- ARRAY_VALUES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regexp.new('\s*,\s*').freeze
- IGNORED_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .cast_value(value, type = String) ⇒ Object private
- .new(env = ENV) ⇒ Object private
Class Method Details
.cast_value(value, type = String) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/honeybadger/config/env.rb', line 25 def self.cast_value(value, type = String) v = value.to_s if type == Boolean !!(v =~ /\A(true|t|1)\z/i) elsif type == Array v.split(ARRAY_VALUES).map(&method(:cast_value)) elsif type == Integer v.to_i elsif type == Float v.to_f else v end end |
.new(env = ENV) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/honeybadger/config/env.rb', line 11 def self.new(env = ENV) hash = {} env.each_pair do |k,v| next unless k.match(CONFIG_KEY) next unless config_key = CONFIG_MAPPING[$1] type = OPTIONS[config_key][:type] next if IGNORED_TYPES.include?(type) hash[config_key] = cast_value(v, type) end hash end |