Module: HoptoadTasks

Defined in:
lib/hoptoad_tasks.rb

Class Method Summary collapse

Class Method Details

.deploy(opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hoptoad_tasks.rb', line 6

def self.deploy(opts = {})
  if HoptoadNotifier.api_key.blank?
    puts "I don't seem to be configured with an API key.  Please check your configuration."
    return false
  end

  if opts[:rails_env].blank?
    puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
    return false
  end

  params = {:api_key => HoptoadNotifier.api_key}
  opts.each {|k,v| params["deploy[#{k}]"] = v }

  url = URI.parse("http://#{HoptoadNotifier.host}/deploys.txt")
  response = Net::HTTP.post_form(url, params)
  puts response.body
  return Net::HTTPSuccess === response
end