Sha256: 47b4bb11eae108a72fdd73ccf58ab835fcfd25e11b090ca35839acc341af19a7

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'net/https'
require 'deploytracking/version'

module DeployTracking

  # Send data via a secure socket
  USE_SSL = true

  # The domain name of the deploytracking web app
  DEPLOY_TRACKING_HOST = 'deploytracking.heroku.com'

  # The relative end point of the service
  DEPLOY_TRACKING_PATH = '/deploys'

  # SSL port number that the service is available on
  DEPLOY_TRACKING_PORT = 443

  # Notify the deploytracking webservice of a new deployment
  # with a payload of data from capistrano.
  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deploytracking-0.1.0 lib/deploytracking.rb