Class: Alerty::Config
- Inherits:
-
Object
- Object
- Alerty::Config
- Defined in:
- lib/alerty/config.rb
Class Attribute Summary collapse
-
.opts ⇒ Object
readonly
Returns the value of attribute opts.
Class Method Summary collapse
- .config ⇒ Object
- .config_path ⇒ Object
- .configure(opts) ⇒ Object
- .lock_path ⇒ Object
- .log_level ⇒ Object
- .log_path ⇒ Object
- .log_shift_age ⇒ Object
- .log_shift_size ⇒ Object
- .plugins ⇒ Object
-
.reset ⇒ Object
for debug.
- .retry_interval ⇒ Object
- .retry_limit ⇒ Object
- .retry_wait ⇒ Object
- .timeout ⇒ Object
Class Attribute Details
.opts ⇒ Object (readonly)
Returns the value of attribute opts.
7 8 9 |
# File 'lib/alerty/config.rb', line 7 def opts @opts end |
Class Method Details
.config ⇒ Object
17 18 19 |
# File 'lib/alerty/config.rb', line 17 def config @config ||= Hashie::Mash.new(YAML.load_file(config_path)) end |
.config_path ⇒ Object
13 14 15 |
# File 'lib/alerty/config.rb', line 13 def config_path @config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/alerty/alerty.yml' end |
.configure(opts) ⇒ Object
9 10 11 |
# File 'lib/alerty/config.rb', line 9 def configure(opts) @opts = opts end |
.lock_path ⇒ Object
41 42 43 |
# File 'lib/alerty/config.rb', line 41 def lock_path opts[:lock_path] || config.lock_path end |
.log_level ⇒ Object
25 26 27 |
# File 'lib/alerty/config.rb', line 25 def log_level opts[:log_level] || config.log_level || 'warn' end |
.log_path ⇒ Object
21 22 23 |
# File 'lib/alerty/config.rb', line 21 def log_path opts[:log_path] || config.log_path || 'STDOUT' end |
.log_shift_age ⇒ Object
29 30 31 |
# File 'lib/alerty/config.rb', line 29 def log_shift_age opts[:log_shift_age] || config.shift_age || 0 end |
.log_shift_size ⇒ Object
33 34 35 |
# File 'lib/alerty/config.rb', line 33 def log_shift_size opts[:log_shift_size] || config.shift_size || 1048576 end |
.plugins ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/alerty/config.rb', line 59 def plugins @plugins ||= config.fetch('plugins').map do |plugin| require "alerty/plugin/#{plugin.type}" class_name = "Alerty::Plugin::#{StringUtil.camelize(plugin.type)}" Object.const_get(class_name).new(plugin) end end |
.reset ⇒ Object
for debug
68 69 70 71 72 |
# File 'lib/alerty/config.rb', line 68 def reset @config_path = nil @config = nil @plugins = nil end |
.retry_interval ⇒ Object
53 54 55 56 57 |
# File 'lib/alerty/config.rb', line 53 def retry_interval @random ||= Random.new randomness = retry_wait * 0.125 retry_wait + @random.rand(-randomness .. randomness) end |
.retry_limit ⇒ Object
45 46 47 |
# File 'lib/alerty/config.rb', line 45 def retry_limit opts[:retry_limit] || config.retry_limit || 0 end |
.retry_wait ⇒ Object
49 50 51 |
# File 'lib/alerty/config.rb', line 49 def retry_wait opts[:retry_wait] || config.retry_wait || 1.0 end |
.timeout ⇒ Object
37 38 39 |
# File 'lib/alerty/config.rb', line 37 def timeout opts[:timeout] || config.timeout end |