Class: PostCommit::Hooks::LightHouse
- Inherits:
-
Base
- Object
- Base
- PostCommit::Hooks::LightHouse
- Defined in:
- lib/post_commit/hooks/light_house.rb
Overview
To send a LightHouse post commit, you have to setup your subdomain, API token and project id.
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)
-
- (Object) post(title, message)
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
- (Object) post(title, message)
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 |