Sha256: 58a182dad1f52a0b50788031d4f903c396abe7129a9d5147cf9fe1495a10fd79
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require_relative 'persistence' module ArisControl class Bookkeeper attr_reader :persistence, :apps def initialize(persistence = default_persistence) @persistence = persistence @apps = persistence.load_apps end def list apps end def add(name, opts = {}) env_vars = opts[:env_vars] app = apps[name] || {} apps[name] = app.dup.tap do |h| h['email'] = opts[:email] || app.fetch('email') h['ssh_key'] = opts[:ssh_key] if opts[:ssh_key] h['env_vars'] = with_upcased_keys(env_vars) if env_vars end persistence.store_apps(apps) end def add_env_vars(name, additional_env_vars = {}) app = apps[name] or return _env_vars = with_upcased_keys(additional_env_vars) app['env_vars'] = app['env_vars'].merge(_env_vars) persistence.store_apps(apps) end def delete(name) apps.delete(name) persistence.store_apps(apps) 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.3.0 | lib/aris-control/bookkeeper.rb |