Created
September 7, 2012 16:20
-
-
Save mperham/3667520 to your computer and use it in GitHub Desktop.
Campfire in 10 lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## | |
| # Broadcast a message to Campfire | |
| # | |
| # campfire = Campfire.new(options) | |
| # campfire.say("#{self.class.name} finished successfully!") | |
| # campfire.say("trombone", :Sound) | |
| # | |
| def say(msg, type=:Text) | |
| http = Net::HTTP.new("#{options[:subdomain]}.campfirenow.com", 443) | |
| http.use_ssl = true | |
| request = Net::HTTP::Post.new("/room/#{options[:roomid]}/speak.json") | |
| request['Content-Type'] = 'application/json' | |
| request.basic_auth options[:token], 'X' | |
| request.body = Sidekiq.dump_json({:message => {:body => msg, :type => "#{type}Message"}}) | |
| response = http.request(request) | |
| raise response.inspect if response.code != "201" | |
| msg | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment