Module: DeployTracking

Defined in:
lib/deploytracking.rb,
lib/deploytracking/version.rb

Constant Summary collapse

USE_SSL =

Send data via a secure socket

true
DEPLOY_TRACKING_HOST =

The domain name of the deploytracking web app

'deploytracking.heroku.com'
DEPLOY_TRACKING_PATH =

The relative end point of the service

'/deploys'
DEPLOY_TRACKING_PORT =

SSL port number that the service is available on

443
VERSION =
"0.0.9"

Class Method Summary collapse

Class Method Details

.notify(api_key, data) ⇒ Object

Notify the deploytracking webservice of a new deployment with a payload of data from capistrano.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/deploytracking.rb', line 20

def self.notify(api_key, data)
  puts "[DeployTracking] Tracking Deployment to #{DEPLOY_TRACKING_HOST}"

  params = {'api_key' => api_key, 'deploy["gem_version"]' => DeployTracking::VERSION}
  data.each {|k,v| params["deploy[#{k}]"] = v }

  http = Net::HTTP.new(DEPLOY_TRACKING_HOST, DEPLOY_TRACKING_PORT)
  http.use_ssl = USE_SSL
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Post.new(DEPLOY_TRACKING_PATH)
  request.set_form_data(params)
  response = http.request(request)

  throw "[DeployTracking] Error posting to server." unless response.is_a?(Net::HTTPSuccess)
  puts "[DeployTracking] Deployment tracked"
  return response
end