class Urbit::Config

Injected into a Ship to provide configuration

Constants

DEFAULT_CODE
DEFAULT_CONFIG_FILE
DEFAULT_HOST
DEFAULT_NAME
DEFAULT_PORT

Attributes

code[R]
config_file[R]
host[R]
name[R]
port[R]

Public Class Methods

new(code: nil, config_file: nil, host: nil, name: nil, port: nil) click to toggle source
# File lib/urbit/config.rb, line 14
def initialize(code: nil,  config_file: nil, host: nil, name: nil, port: nil)
  @config_file = config_file || DEFAULT_CONFIG_FILE
  @code = code || loaded_config['code'] || DEFAULT_CODE
  @host = host || loaded_config['host'] || DEFAULT_HOST
  @name = name || loaded_config['ship'] || DEFAULT_NAME
  @port = port || loaded_config['port'] || DEFAULT_PORT
end

Public Instance Methods

api_base_url() click to toggle source
# File lib/urbit/config.rb, line 22
def api_base_url
  @api_base_url ||= "#{host}:#{port}"
end

Private Instance Methods

loaded_config() click to toggle source
# File lib/urbit/config.rb, line 28
def loaded_config
  @loaded_config ||= begin
    return {} unless File.exist?(config_file)

    YAML.load_file(config_file)
  end
end