diff options
author | Azul <azul@riseup.net> | 2017-09-23 11:07:32 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2017-09-23 16:53:27 +0200 |
commit | 40916407517f4bdb75a295caf29e02d4f403349b (patch) | |
tree | 8219567c0ecdf583fdd916594ec7915ab9eb2f19 /lib/nickserver/config.rb | |
parent | 22c6c80310a8d3d3abbd1006598b4fbaec98ffd0 (diff) |
style: rubocop mostly auto-correct
Diffstat (limited to 'lib/nickserver/config.rb')
-rw-r--r-- | lib/nickserver/config.rb | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/lib/nickserver/config.rb b/lib/nickserver/config.rb index b1def7c..62623c1 100644 --- a/lib/nickserver/config.rb +++ b/lib/nickserver/config.rb @@ -5,7 +5,7 @@ module Nickserver PATHS = [ File.expand_path('../../../config/default.yml', __FILE__), '/etc/nickserver.yml' - ] + ].freeze class << self attr_accessor :hkp_url @@ -29,22 +29,21 @@ module Nickserver def self.load self.loaded ||= begin PATHS.each do |file_path| - self.load_config(file_path) + load_config(file_path) end true end - self.validate + validate end def self.couch_url - [ 'http://', - couch_auth, - couch_host, - ':', - couch_port, - '/', - couch_database - ].join + ['http://', + couch_auth, + couch_host, + ':', + couch_port, + '/', + couch_database].join end def self.couch_auth @@ -70,22 +69,20 @@ module Nickserver end def self.load_config(file_path) - begin - YAML.load(File.read(file_path)).each do |key, value| - begin - self.send("#{key}=", value) - rescue NoMethodError - STDERR.puts "ERROR in file #{file_path}, '#{key}' is not a valid option" - exit(1) - end + YAML.safe_load(File.read(file_path)).each do |key, value| + begin + send("#{key}=", value) + rescue NoMethodError + STDERR.puts "ERROR in file #{file_path}, '#{key}' is not a valid option" + exit(1) end - puts "Loaded #{file_path}" if Config.verbose - rescue Errno::ENOENT => exc - puts "Skipping #{file_path}" if Config.verbose - rescue Exception => exc - STDERR.puts exc.inspect - exit(1) end + puts "Loaded #{file_path}" if Config.verbose + rescue Errno::ENOENT => exc + puts "Skipping #{file_path}" if Config.verbose + rescue Exception => exc + STDERR.puts exc.inspect + exit(1) end end end |