Sha256: e61b14af3b77f1ca1825cd0dfcd641434bb81e8d457ba6a950f536452eb8c629
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
require_relative 'persistence' module ArisControl class Bookkeeper attr_reader :persistence, :users def initialize(persistence = default_persistence) @persistence = persistence @users = persistence.load_users end def list users end def add(name, opts = {}) user = users[name] || {} ssh_key = opts[:ssh_key] env_vars = opts[:env_vars] _opts = Hash.new.tap do |h| h['email'] = opts[:email] || user.fetch('email') h['ssh_key'] = ssh_key || user['ssh_key'] || '' h['env_vars'] = with_upcased_keys(env_vars) if env_vars end users[name] = user.merge(_opts) persistence.store_users(users) end def delete(name) users.delete(name) persistence.store_users(users) end def default_persistence ArisControl::Persistence.new end private def with_upcased_keys(hash) hash or return hash.each_with_object({}) {|(k,v),h| h[k.to_s.upcase] = v } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aris-control-3.0.0 | lib/aris-control/bookkeeper.rb |