secret shared password recovery
[opencorn.git] / lib / opencorn / config.rb
blobc3a168ea90ee79fba05813532dd34051fa06f09c
1 require 'singleton'
2 require 'yaml'
4 module OpenCorn
5         class Config
6                 include Singleton
7                 attr_reader :cfg
8                 def initialize
9                         begin
10                                 @cfg = open(File.join(File.expand_path('~'), '.opencorn.cfg')) do |f|
11                                         YAML.load(f)
12                                 end
13                         rescue Errno::ENOENT
14                                 STDERR.puts "Error loading config file!"
15                                 exit 10
16                         end
17                 end
18                 def self.[](key)
19                         self.instance.cfg[key]
20                 end
21         end
22 end