Sha256: 67a590456040b0b30d67f6d282b347dd3a4a238ca2ad12ff8b3b57b1a65a26bf

Contents?: true

Size: 741 Bytes

Versions: 15

Compression:

Stored size: 741 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

15 entries across 15 versions & 1 rubygems

Version Path
t-1.7.2 lib/t/requestable.rb
t-1.7.1 lib/t/requestable.rb
t-1.6.0 lib/t/requestable.rb
t-1.5.1 lib/t/requestable.rb
t-1.5.0 lib/t/requestable.rb
t-1.4.0 lib/t/requestable.rb
t-1.3.1 lib/t/requestable.rb
t-1.3.0 lib/t/requestable.rb
t-1.2.0 lib/t/requestable.rb
t-1.1.1 lib/t/requestable.rb
t-1.1.0 lib/t/requestable.rb
t-1.0.1 lib/t/requestable.rb
t-1.0.0 lib/t/requestable.rb
t-0.9.9 lib/t/requestable.rb
t-0.9.8 lib/t/requestable.rb