Permalink
Browse files

Chat.setup requires default chat room

  • Loading branch information...
1 parent 93e9747 commit 5bba134f5829630bed800247cbfd5592a89eed4a @sr sr committed Jan 2, 2012
Showing with 13 additions and 12 deletions.
  1. +2 −3 lib/janky.rb
  2. +11 −9 lib/janky/chat.rb
View
@@ -146,10 +146,9 @@ def self.setup(settings)
chat_settings[key] = value
end
end
- # Backward compatibility
- chat_settings["JANKY_CHAT_DEFAULT_ROOM"] ||=
+ chat_room = ["JANKY_CHAT_DEFAULT_ROOM"] ||
settings["JANKY_CAMPFIRE_DEFAULT_ROOM"]
- Chat.setup(chat_name, chat_settings)
+ Chat.setup(chat_name, chat_settings, chat_room)
Notifier.setup(Notifier::Chat)
end
View
@@ -1,27 +1,29 @@
module Janky
module Chat
- # Setup the Chat.
+ # Setup service used to notify chat rooms of build status.
#
- # settings - environment variables
+ # name - Service name as a string.
+ # settings - Service-specific setting hash.
+ # default - Name of the default chat room as a String.
#
# Returns nothing.
- def self.setup(name, settings)
+ def self.setup(name, settings, default)
if !adapters[name]
raise Error, "Unknown chat service: #{name.inspect}. Available " \
"services are #{adapters.keys.join(", ")}"
end
@adapter = adapters[name].new(settings)
- @default_room_name = settings["JANKY_CHAT_DEFAULT_ROOM"]
+ @default_room_name = default
end
- def self.adapters
- @adapters ||= {}
+ class << self
+ attr_accessor :adapter, :default_room_name
end
- class << self
- attr_accessor :adapter
- attr_accessor :default_room_name
+ # Registry of available chat implementations.
+ def self.adapters
+ @adapters ||= {}
end
def self.default_room_id

0 comments on commit 5bba134

Please sign in to comment.