class Del::Configuration
This is used to contain all configuration.
Constants
- SOCKET_FILE
Attributes
default_rooms[W]
host[W]
jid[W]
logger[W]
muc_domain[W]
name[W]
password[W]
router[RW]
settings[R]
socket_file[W]
users[RW]
Public Class Methods
new(settings = {})
click to toggle source
# File lib/del/configuration.rb, line 18 def initialize(settings = {}) @settings = settings @router = DefaultRouter.new @users = Repository.new(mapper: User) end
Public Instance Methods
default_rooms()
click to toggle source
# File lib/del/configuration.rb, line 57 def default_rooms @default_rooms ||= settings.fetch(:rooms, []) end
host()
click to toggle source
# File lib/del/configuration.rb, line 28 def host @host ||= settings.fetch(:host, 'chat.hipchat.com') end
jid()
click to toggle source
# File lib/del/configuration.rb, line 24 def jid @jid ||= settings.fetch(:jid) end
load(file)
click to toggle source
# File lib/del/configuration.rb, line 61 def load(file) return if file.nil? return Kernel.load(file) if File.exist?(file) download(file) end
logger()
click to toggle source
# File lib/del/configuration.rb, line 44 def logger @logger ||= begin x = Logger.new(STDOUT) x.level = settings.fetch(:log_level, Logger::INFO).to_i x end end
muc_domain()
click to toggle source
# File lib/del/configuration.rb, line 32 def muc_domain @muc_domain ||= settings.fetch(:muc_domain, 'conf.hipchat.com') end
name()
click to toggle source
# File lib/del/configuration.rb, line 36 def name @name ||= settings.fetch(:full_name) end
password()
click to toggle source
# File lib/del/configuration.rb, line 40 def password @password ||= settings.fetch(:password) end
socket_file()
click to toggle source
# File lib/del/configuration.rb, line 53 def socket_file @socket_file ||= settings.fetch(:socket_file, SOCKET_FILE) end
Private Instance Methods
download(url)
click to toggle source
# File lib/del/configuration.rb, line 72 def download(url) Net::Hippie.logger = logger response = Net::Hippie::Client.new.yield_self do |x| x.with_retry { |y| y.get(url) } end path = Tempfile.new('del').path IO.write(path, response.body) load(path) end