Sha256: 7d783b3b606e5567c556a3bf6b7ece61e4a6e090e726a9a336dc66652f86feb6

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

require 'twitter'

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

  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.active_consumer_key,
        :consumer_secret => @rcfile.active_consumer_secret,
        :oauth_token => @rcfile.active_token,
        :oauth_token_secret  => @rcfile.active_secret,
      )
    end

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

    def protocol
      options['no-ssl'] ? 'http' : DEFAULT_PROTOCOL
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
t-1.7.0 lib/t/requestable.rb