class Meshchat::Configuration::AppConfig

Constants

DEFAULTS

Attributes

_options[R]

Public Class Methods

new(options) click to toggle source
# File lib/meshchat/configuration/app_config.rb, line 15
def initialize(options)
  @_options = DEFAULTS.merge(options)
  @_options[:user] = Configuration::Settings.new

  locale_path = 'locale/'
  # I18n.load_path = Dir[locale_path + '*.yml']
  # puts File.read(locale_path)
  root_path = File.dirname(__FILE__)
  full_path = "#{root_path}/../#{locale_path}"
  I18n.backend.store_translations(:en,
    YAML.load(File.read(full_path + 'en.yml')))

  if notifier = options[:notifier]
    notifier_instance = notifier.new
    Meshchat.const_set(:Notify, notifier_instance)
  end

  # The display has to be created right away so that
  # we can start outputting to it
  manager = Ui::Display::Manager.new(options[:display])
  Meshchat.const_set(:Display, manager)
  Meshchat.const_set(:APP_CONFIG, self)

  Meshchat::Display.start
end

Public Instance Methods

[](key) click to toggle source
# File lib/meshchat/configuration/app_config.rb, line 56
def [](key)
  _options[key]
end
[]=(key, value) click to toggle source
# File lib/meshchat/configuration/app_config.rb, line 60
def []=(key, value)
  _options[key] = value
end
user() click to toggle source
# File lib/meshchat/configuration/app_config.rb, line 64
def user
  _options[:user]
end
validate() click to toggle source
# File lib/meshchat/configuration/app_config.rb, line 41
def validate
  # Check user config, go through initial setup if we haven't done so already.
  # This should only need to be done once per user.
  #
  # This will also generate a whatever-alias-you-choose.json that the user
  # can pass around to someone gain access to the network.
  #
  # Personal settings are stored in settings.json. This should never be
  # shared with anyone.
  Identity.check_or_create

  # setup the storage - for keeping track of nodes on the network
  Database.setup_storage
end