Sha256: fb0717851f5e0ca5235c32c8325c695258cd3c68f9ba8b1d931157e1f6b31942

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 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-0.9.7 lib/t/requestable.rb