diff options
Diffstat (limited to 'lib/keyring/user_config.rb')
-rw-r--r-- | lib/keyring/user_config.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/keyring/user_config.rb b/lib/keyring/user_config.rb index 21a8c33..c6d48e6 100644 --- a/lib/keyring/user_config.rb +++ b/lib/keyring/user_config.rb @@ -22,17 +22,24 @@ module Keyring class UserConfig include Singleton - def initialize - self.load + def initialize(path = nil) + self.loadMainConfig self.check end - def load + def loadMainConfig @user_config = ENV['HOME'] + '/.keyringer/config' @keyrings = Backend::parse_config(@user_config) @path = @keyrings.get_value($keyring) end + # TODO + def saveMainConfig + # TODO: copy each keyring definition to a hash + # update path of the current keyring + file = open(@user_config, 'w') + end + def keyrings @keyrings end @@ -41,7 +48,13 @@ module Keyring @path end + def setPath(path) + @path = path + saveMainConfig + end + def check + raise "Not a directory: #{@path}" if !File::directory?(@path) raise "No keydir configured for #{$keyring} keyring." if @path.nil? end end |