Sha256: 5af56d4ee7bc2826b90e1474a632086be42ee1cf2f2edd0c7ae0899d240980b8

Contents?: true

Size: 1020 Bytes

Versions: 4

Compression:

Stored size: 1020 Bytes

Contents

require 'stream/signer'
require 'stream/feed'

module Stream
    class Client
        attr_reader :api_key
        attr_reader :api_secret
        attr_reader :site

        def initialize(api_key='', api_secret='', site=0)
            # Support the Heroku STREAM_URL environment variable
            
            if ENV['STREAM_URL'] != nil and api_key == ''
                matches = /https\:\/\/(?<key>\w+)\:(?<secret>\w+).*site=(?<site>\d+)/i.match(ENV['STREAM_URL'])
                api_key = matches['key']
                api_secret = matches['secret']
                site = matches['site']
            end
          
            @api_key = api_key
            @api_secret = api_secret
            @site = site
            @signer = Stream::Signer.new(api_secret)
        end

        def feed(feed_id)
            cleaned_feed_id = Stream::clean_feed_id(feed_id)
            signature = @signer.signature(cleaned_feed_id)
            Stream::Feed.new(self, feed_id, @api_key, signature)
        end

    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stream-ruby-0.8.2 lib/stream/client.rb
stream-ruby-0.8.1 lib/stream/client.rb
stream-ruby-0.7.0 lib/stream/client.rb
stream-ruby-0.6.0 lib/stream/client.rb