lib/td/command/common.rb in td-0.16.9 vs lib/td/command/common.rb in td-0.16.10

- old
+ new

@@ -65,17 +65,15 @@ end Client.new(apikey, opts) end - DEFAULT_IMPORT_ENDPOINT = "https://" + TreasureData::API::DEFAULT_IMPORT_ENDPOINT - def get_import_client import_endpoint = begin - Config.import_endpoint || DEFAULT_IMPORT_ENDPOINT + Config.import_endpoint || nil rescue TreasureData::ConfigNotFoundError - DEFAULT_IMPORT_ENDPOINT + nil end get_client(endpoint: import_endpoint) end def get_ssl_client(opts={}) @@ -105,11 +103,11 @@ when 'csv', 'tsv' require 'csv' headers = options[:fields] csv_opts = {} csv_opts[:col_sep] = "\t" if format == 'tsv' - CSV.generate('', csv_opts) { |csv| + CSV.generate('', **csv_opts) { |csv| csv << headers rows.each { |row| r = [] headers.each { |field| r << row[field] @@ -366,15 +364,12 @@ end end def self.get_http_class # use Net::HTTP::Proxy in place of Net::HTTP if a proxy is provided - http_proxy = ENV['HTTP_PROXY'] - if http_proxy - http_proxy = (http_proxy =~ /\Ahttp:\/\/(.*)\z/) ? $~[1] : http_proxy - host, port = http_proxy.split(':', 2) - port = (port ? port.to_i : 80) - return Net::HTTP::Proxy(host, port) + if ENV['HTTP_PROXY'] + uri = URI.parse(ENV['HTTP_PROXY']) + return Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password) else return Net::HTTP end end