Commit 9a6ebcb
Changed files (2)
lib
lib/del/configuration.rb
@@ -15,7 +15,7 @@ module Del
attr_accessor :socket_file
def initialize(settings = {})
- @default_rooms = settings[:rooms]
+ @default_rooms = settings.fetch(:rooms, [])
@host = settings.fetch(:host, 'chat.hipchat.com')
@jid = settings.fetch(:jid)
@logger = Logger.new(STDOUT)
@@ -25,7 +25,7 @@ module Del
@password = settings.fetch(:password)
@rooms = Repository.new
@router = DefaultRouter.new
- @socket_file = SOCKET_FILE
+ @socket_file = settings.fetch(:socket_file, SOCKET_FILE)
@users = Repository.new
end
lib/del.rb
@@ -22,15 +22,14 @@ require "del/version"
module Del
def self.start(configuration_file:, startup_file: nil, start_server: true, socket_file: nil)
puts "Loading... #{configuration_file}"
- @configuration ||= Configuration.new(YAML.load(IO.read(configuration_file)))
- Del.configure do |config|
- config.socket_file = socket_file if socket_file
- config.router.register(/.*/) do |message|
- logger.debug(message.to_s)
- end
- config.load(startup_file)
+ settings = YAML.load(IO.read(configuration_file)).merge(socket_file: socket_file)
+ @configuration ||= Configuration.new(settings)
+ @configuration.socket_file = socket_file if socket_file
+ @configuration.router.register(/.*/) do |message|
+ logger.debug(message.to_s)
end
- del = Robot.new(configuration: configuration)
+ @configuration.load(startup_file)
+ del = Robot.new(configuration: @configuration)
del.get_funky!(start_server: start_server)
end