Sha256: ef98fe95339ff7fed1c52dd60cf87ad728ce25317cf92c223e33037c47d3ea15

Contents?: true

Size: 825 Bytes

Versions: 6

Compression:

Stored size: 825 Bytes

Contents

require 'twitter'

module T
  module Requestable
    DEFAULT_HOST = 'api.twitter.com'
    DEFAULT_PROTOCOL = 'https'

    def self.included(base)

    private

      def base_url
        "#{protocol}://#{host}"
      end

      def client
        return @client if @client
        @rcfile.path = options['profile'] if options['profile']
        @client = Twitter::Client.new(
          :endpoint => base_url,
          :consumer_key => @rcfile.default_consumer_key,
          :consumer_secret => @rcfile.default_consumer_secret,
          :oauth_token => @rcfile.default_token,
          :oauth_token_secret  => @rcfile.default_secret
        )
      end

      def host
        options['host'] || DEFAULT_HOST
      end

      def protocol
        options['no_ssl'] ? 'http' : DEFAULT_PROTOCOL
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
t-0.7.0 lib/t/requestable.rb
t-0.6.4 lib/t/requestable.rb
t-0.6.3 lib/t/requestable.rb
t-0.6.2 lib/t/requestable.rb
t-0.6.1 lib/t/requestable.rb
t-0.6.0 lib/t/requestable.rb