Method: Toadhopper#initialize

Defined in:
lib/toadhopper.rb

#initialize(api_key, params = {}) ⇒ Toadhopper

Initialize and configure a Toadhopper

Parameters:

  • Your (String)

    api key

  • params (Hash) (defaults to: {})
    optional

    :notify_host - [String] The default host to use :error_url - [String] Absolute URL to use for error reporting :deploy_url - [String] Absolute URL to use for deploy tracking :transport - [Net::HTTP|Net::HTTP::Proxy] A customized Net::* object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/toadhopper.rb', line 33

def initialize(api_key, params = {})
  @filters    = []
  @api_key    = api_key

  notify_host = URI.parse(params[:notify_host] || DEFAULT_NOTIFY_HOST)
  @transport  = params.delete :transport
  if @transport and not params[:notify_host]
    notify_host.scheme  = 'https' if @transport.use_ssl?
    notify_host.host    = @transport.address
    notify_host.port    = @transport.port
  end

  @error_url  = URI.parse(params.delete(:error_url)  || "#{notify_host}/notifier_api/v2/notices")
  @deploy_url = URI.parse(params.delete(:deploy_url) || "#{notify_host}/deploys.txt")

  validate!
end