class Juden::Config
read keymap from yaml file
Attributes
custom_path[RW]
keymap[R]
Public Class Methods
new()
click to toggle source
# File lib/juden/config.rb, line 11 def initialize @custom_path = nil reload end
Public Instance Methods
device_name()
click to toggle source
# File lib/juden/config.rb, line 34 def device_name keymap['device_name'] end
interval_seconds()
click to toggle source
# File lib/juden/config.rb, line 26 def interval_seconds keymap['interval_seconds'] end
reload()
click to toggle source
# File lib/juden/config.rb, line 16 def reload @cache = nil @keymap = YAML.load_file(file_path) self end
threshold_percentage()
click to toggle source
# File lib/juden/config.rb, line 22 def threshold_percentage keymap['threshold_percentage'] end
webhook_url()
click to toggle source
# File lib/juden/config.rb, line 30 def webhook_url keymap['webhook_url'] end
Private Instance Methods
expand_config_path(filename)
click to toggle source
# File lib/juden/config.rb, line 59 def expand_config_path(filename) File.expand_path "#{Dir.home}/.config/#{filename}" end
expand_sample_path()
click to toggle source
# File lib/juden/config.rb, line 63 def expand_sample_path File.expand_path '../../../config.yml', __FILE__ end
file_path()
click to toggle source
# File lib/juden/config.rb, line 40 def file_path filename = 'juden/config.yml' if File.exist?(expand_config_path(filename)) expand_config_path(filename) else puts "Please create your config file to #{expand_config_path(filename)}" puts "\n" puts 'Please copy beloiw to ~/.config/juden/config.yml' puts "\n" puts "--------------------------------------------------------" puts File.read(expand_sample_path) puts "--------------------------------------------------------" puts "\n" puts 'Then, pelase edit ~/.config/juden/config.yml for your Environment' puts "\n" exit 1 end end