Sha256: 245aa2f6d04f22d7a5e8c0c23db0be7b422f51604330aa9ce0975ab85c8a2656

Contents?: true

Size: 610 Bytes

Versions: 10

Compression:

Stored size: 610 Bytes

Contents

require "net/http"
require "uri"

module Firehose
  class HttpPublisher
    attr_reader :uri

    class RequestBuilder
      attr_reader :uri, :message, :channel

      def initialize(uri, message)
        @uri, @message = uri, message
      end

      def to(channel)
        req = Net::HTTP::Put.new(channel)
        req.body = message
        res = Net::HTTP.start(uri.host, uri.port) do |http|
          response = http.request(req)
        end
      end
    end

    def initialize(uri)
      @uri = URI.parse(uri)
    end

    def publish(message)
      RequestBuilder.new(uri, message)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
firehose-0.0.12 lib/firehose/http_publisher.rb
firehose-0.0.11 lib/firehose/http_publisher.rb
firehose-0.0.10 lib/firehose/http_publisher.rb
firehose-0.0.9 lib/firehose/http_publisher.rb
firehose-0.0.8 lib/firehose/http_publisher.rb
firehose-0.0.7 lib/firehose/http_publisher.rb
firehose-0.0.6 lib/firehose/http_publisher.rb
firehose-0.0.5 lib/firehose/http_publisher.rb
firehose-0.0.4 lib/firehose/http_publisher.rb
firehose-0.0.3 lib/firehose/http_publisher.rb