検索すると古い記事にて Twitter.config から指定できるとあるが,少なくとも4.6.2では動作しない.
@t = Twitter::Client.new
@t.connection_options[:proxy] = 'http://proxy:8080'
とやれば指定できる.自分は定型句として
auth.yaml
consumer_key: hoge
consumer_secret: fuga
oauth_token: foo
oauth_token_secret: bar
と書いた auth.yaml を用意して
base.rb
require 'twitter'
class Base
def initialize
config = YAML.load_file("./auth.yaml")
@t = Twitter::Client.new
config.each_pair do |k, v|
@t.send("#{k}=", v)
end
@t.connection_options[:proxy] = 'proxy:8080'
end
end
という感じで初期化している.