Class: CollinsNotify::HipchatAdapter
- Defined in:
- lib/collins_notify/adapter/hipchat.rb
Defined Under Namespace
Modules: HipchatStatus
Instance Method Summary collapse
- #configure! ⇒ Object
-
#notify!(message_obj = OpenStruct.new, to = nil) ⇒ Object
Bindings available room_name - hipchat room username - user message being sent as at - If we are at’ing a person.
Methods inherited from Notifier
adapter_name, adapters, get_adapter, #initialize, mimetypes, register_name, require_config, required_config_keys, requires_config?, #supports_html?, supports_mimetype, #supports_text?
Constructor Details
This class inherits a constructor from CollinsNotify::Notifier
Instance Method Details
#configure! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/collins_notify/adapter/hipchat.rb', line 19 def configure! @client = HipChat::Client.new api_token cfg_colors = .fetch(:colors, {}) @colors = { :success => cfg_colors.fetch(:success, HipchatStatus::SUCCESS), :warning => cfg_colors.fetch(:warning, HipchatStatus::WARNING), :error => cfg_colors.fetch(:error, HipchatStatus::ERROR), :status => cfg_colors.fetch(:status, HipchatStatus::STATUS), :random => cfg_colors.fetch(:random, HipchatStatus::RANDOM) } logger.info "Configured Hipchat client" end |
#notify!(message_obj = OpenStruct.new, to = nil) ⇒ Object
Bindings available
room_name - hipchat room
username - user message being sent as
at - If we are at'ing a person
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/collins_notify/adapter/hipchat.rb', line 36 def notify! = OpenStruct.new, to = nil room_name = get_room username = get_from_username if room_name.nil? then raise CollinsNotify::CollinsNotifyException.new "No obj.room or hipchat.room specified" end = (binding).strip.gsub(/[\n\r]/, ' ') = "@#{to} #{}" unless to.nil? logger.info "Notifying #{room_name} from #{username} with message #{}" if config.test? then logger.info "Not sending hipchat message in test mode" return true end opts = () logger.debug "Using hipchat options #{opts.inspect}" client[room_name].send(username, , ()) end |