Sha256: 31fdcbb3f253023d243a44a079a71e5c4a155351401120850fd074b0e3756dc1
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'stream/signer' require 'stream/feed' module Stream STREAM_URL_RE = /https\:\/\/(?<key>\w+)\:(?<secret>\w+).*site=(?<site>\d+)/i class Client attr_reader :api_key attr_reader :api_secret attr_reader :site def initialize(api_key='', api_secret='', site=0) if ENV['STREAM_URL'] =~ Stream::STREAM_URL_RE and (api_key.nil? || api_key.empty?) matches = Stream::STREAM_URL_RE.match(ENV['STREAM_URL']) api_key = matches['key'] api_secret = matches['secret'] site = matches['site'] end if api_key.nil? || api_key.empty? raise ArgumentError, 'empty api_key parameter and missing or invalid STREAM_URL env variable' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
stream-ruby-1.0.5 | lib/stream/client.rb |
stream-ruby-1.0.4 | lib/stream/client.rb |
stream-ruby-1.0.3 | lib/stream/client.rb |