Sha256: 7b21cb8b9c498769750fc4374d1256435a8e8c930ec9e3060b776133fbca66c1

Contents?: true

Size: 821 Bytes

Versions: 11

Compression:

Stored size: 821 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.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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
t-0.9.6 lib/t/requestable.rb
t-0.9.5 lib/t/requestable.rb
t-0.9.4 lib/t/requestable.rb
t-0.9.3 lib/t/requestable.rb
t-0.9.2 lib/t/requestable.rb
t-0.9.1 lib/t/requestable.rb
t-0.9.0 lib/t/requestable.rb
t-0.8.3 lib/t/requestable.rb
t-0.8.2 lib/t/requestable.rb
t-0.8.1 lib/t/requestable.rb
t-0.8.0 lib/t/requestable.rb