Class: PostCommit::Hooks::Basecamp
- Inherits:
-
Base
- Object
- Base
- PostCommit::Hooks::Basecamp
- Defined in:
- lib/post_commit/hooks/basecamp.rb
Overview
To send a Basecamp post commit, you have to setup your subdomain, API token and project.
post_commit :basecamp do
:subdomain => "mycompany", :token => "TVfD8rB0x1sze8nZ4P1vaO5wOWM", :project => 666, :ssl => true
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 Basecamp.
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 Basecamp.
post "Some title", "Some message"
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/post_commit/hooks/basecamp.rb', line 14 def post(title, ) protocol = credentials[:ssl] ? "https" : "http" @uri = URI.parse("#{protocol}://#{credentials[:subdomain]}.basecamphq.com/projects/#{credentials[:project]}/posts.xml") http = Net::HTTP.new(uri.host, uri.port) @request = Net::HTTP::Post.new(uri.path) @request.basic_auth credentials[:token], "x" @request.content_type = "application/xml" @request.body = <<-TXT <post> <title><![CDATA[#{title}]]></title> <body><![CDATA[#{}]]></body> </post> TXT @response = http.request(@request) if @response.code == "201" true else false end rescue Exception false end |