class ArisControl::Bookkeeper
Attributes
apps[R]
persistence[R]
Public Class Methods
new(persistence = default_persistence)
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 7 def initialize(persistence = default_persistence) @persistence = persistence @apps = persistence.load_apps end
Public Instance Methods
add(name, opts = {})
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 16 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
add_env_vars(name, additional_env_vars = {})
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 27 def add_env_vars(name, additional_env_vars = {}) app = apps[name] or return env_vars = app['env_vars'] || {} app['env_vars'] = env_vars.merge(with_upcased_keys(additional_env_vars)) persistence.store_apps(apps) end
default_persistence()
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 39 def default_persistence ArisControl::Persistence.new end
delete(name)
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 34 def delete(name) apps.delete(name) persistence.store_apps(apps) end
list()
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 12 def list apps end
Private Instance Methods
with_upcased_keys(hash)
click to toggle source
# File lib/aris-control/bookkeeper.rb, line 45 def with_upcased_keys(hash) hash or return hash.each_with_object({}) {|(k,v),h| h[k.to_s.upcase] = v } end