class Console1984::Config

Container for config options.

These config options are accessible via first-level reader methods at Console1984.

Constants

PROPERTIES
PROTECTIONS_CONFIG_FILE_PATH

Public Class Methods

new() click to toggle source
# File lib/console1984/config.rb, line 20
def initialize
  set_defaults
end

Public Instance Methods

freeze() click to toggle source
Calls superclass method
# File lib/console1984/config.rb, line 35
def freeze
  super
  [ protected_urls, protections_config ].each(&:freeze)
end
protections_config() click to toggle source

Initialize lazily so that it only gets instantiated during console sessions

# File lib/console1984/config.rb, line 31
def protections_config
  @protections_config ||= Console1984::ProtectionsConfig.new(YAML.safe_load(File.read(PROTECTIONS_CONFIG_FILE_PATH)).symbolize_keys)
end
set_from(properties) click to toggle source
# File lib/console1984/config.rb, line 24
def set_from(properties)
  properties.each do |key, value|
    public_send("#{key}=", value) if value.present?
  end
end

Private Instance Methods

set_defaults() click to toggle source
# File lib/console1984/config.rb, line 41
def set_defaults
  self.session_logger = Console1984::SessionsLogger::Database.new
  self.username_resolver = Console1984::Username::EnvResolver.new("CONSOLE_USER")
  self.shield = Console1984::Shield.new
  self.command_executor = Console1984::CommandExecutor.new

  self.protected_environments = []
  self.protected_urls = []

  self.production_data_warning = DEFAULT_PRODUCTION_DATA_WARNING
  self.enter_unprotected_encryption_mode_warning = DEFAULT_ENTER_UNPROTECTED_ENCRYPTION_MODE_WARNING
  self.enter_protected_mode_warning = DEFAULT_ENTER_PROTECTED_MODE_WARNING

  self.incinerate = true
  self.incinerate_after = 30.days
  self.incineration_queue = "console1984_incineration"

  self.debug = false
  self.test_mode = false
end