Class: PostCommit::Hooks::LightHouse
- Defined in:
- lib/post_commit/hooks/light_house.rb
Overview
To send a Campifire post commit, you have to setup your subdomain, API token and room.
post_commit :lighthouse do
:subdomain => "mycompany", :project => 47533, :token => "TVfD8rB0x1sze8nZ4P1vaO5wOWM"
post "Some title", "Some message"
end
Instance Attribute Summary
Attributes inherited from Base
#credentials, #options, #request, #response, #uri
Instance Method Summary collapse
-
#post(title, message) ⇒ Object
Post message to Lighthouse.
Methods inherited from Base
#authorize, #convert_to_params, #convert_to_xml, inherited, #initialize, #set
Constructor Details
This class inherits a constructor from PostCommit::Hooks::Base
Instance Method Details
#post(title, message) ⇒ Object
Post message to Lighthouse.
post "Some nice title", "Hi Lighthouse!"
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/post_commit/hooks/light_house.rb', line 13 def post(title, ) @uri = URI.parse("http://#{credentials[:subdomain]}.lighthouseapp.com/projects/#{credentials[:project]}/messages.json") http = Net::HTTP.new(uri.host, uri.port) @request = Net::HTTP::Post.new(uri.path) @request.content_type = "application/json" @request["X-LighthouseToken"] = credentials[:token] @request.body = {:message => { :title => title.to_s, :body => .to_s }}.to_json @response = http.request(@request) if @response.code == "201" JSON.parse response.body else false end rescue Exception false end |