Sha256: 9f8efba96922c6670949e965798a61ef4dcf82eab5059656407fc8b817276689
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'net/http' module Smoke module Client class Connection DEFAULT_OPTIONS = { :hostname => "localhost", :port => 8935, :ssl => false, :path => '/signals', :timeout => 3 } attr_reader :configuration def initialize(configuration = {}) @configuration = DEFAULT_OPTIONS.merge(configuration) @user_agent = if configuration[:ssl] Net::HTTPS else Net::HTTP end.new(configuration[:hostname], configuration[:port]) @user_agent.read_timeout = configuration[:timeout] end def send_signal(signal) report_signal = Net::HTTP::Post.new(configuration[:path]) if configuration[:username] && configuration[:password] report_signal.basic_auth configuration[:username], configuration[:password] end response = @user_agent.request report_signal, signal.to_xml(:root => :signal) case response when Net::HTTPCreated true else response.error! end rescue => e STDERR.puts "#{e.message}\n\n#{e.backtrace.join("\n")}\n\n" raise end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smoke-0.0.3 | lib/smoke/client/connection.rb |
smoke-0.0.1 | lib/smoke/client/connection.rb |