diff options
author | azul <azul@riseup.net> | 2017-09-23 15:11:20 +0000 |
---|---|---|
committer | azul <azul@riseup.net> | 2017-09-23 15:11:20 +0000 |
commit | fac140a8ff76e98c275194845125d4c97f4ba07b (patch) | |
tree | 08ffafb2c70935892e975704911080b9da84e391 /lib/nickserver/config.rb | |
parent | 787287318c54b019a12ef79525c9f5b10d93724d (diff) | |
parent | 8ac6bb8492c9a3b9ec5d7b5bf2b35907a1f8c332 (diff) |
Merge branch 'rubocop' into 'master'
Style fixes based on Rubocop
See merge request leap/nickserver!19
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 |