class Shoutbox::Configuration
Attributes
auth_token[RW]
default_group[RW]
host[RW]
proxy_host[RW]
proxy_port[RW]
Public Class Methods
new()
click to toggle source
# File lib/shoutbox/configuration.rb, line 5 def initialize config_file_exists? ? read_config_file : default_config end
Public Instance Methods
config_file=( filename )
click to toggle source
# File lib/shoutbox/configuration.rb, line 9 def config_file=( filename ) @config_file = filename config_file_exists? ? read_config_file : default_config end
Private Instance Methods
config_file()
click to toggle source
# File lib/shoutbox/configuration.rb, line 20 def config_file @config_file || File.join(ENV['HOME'], '.shoutbox') end
config_file_exists?()
click to toggle source
# File lib/shoutbox/configuration.rb, line 16 def config_file_exists? File.exists?(config_file) end
default_config()
click to toggle source
# File lib/shoutbox/configuration.rb, line 24 def default_config @host = 'http://shoutbox.io/' @default_group = 'Home' @auth_token = 'invalid-auth-token' @proxy_host = nil @proxy_port = nil end
read_config_file()
click to toggle source
# File lib/shoutbox/configuration.rb, line 32 def read_config_file config_data = YAML::load_file(config_file) @host = config_data["host"] @default_group = config_data["default_group"] || 'Home' @auth_token = config_data["auth_token"] @proxy_host = config_data["proxy_host"] @proxy_port = config_data["proxy_port"] end